How Can I Solve Odoo Server Error Traceback (most recent call last):? - upgrade
While Upgrading Odoo V12 to V13 i got this error how can i fix it and why this error appeared.?
I have removed #api_multi from all of the custom module and run it. When I tired to run it. it's giving me Odoo Server Error Traceback (most recent call last):
Here is the my xml code:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="sh_res_config_setting_form_view" model="ir.ui.view">
<field name="name">sh.res.config.setting.form.view</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_setup.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[#data-key='general_settings']//div[#id='business_documents']" position="before">
<div>
<h2>Product Internal Reference Generator Feature</h2>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<div class="content-group">
<div class="mt16 row">
<label for="sh_product_int_ref_generator" string="Product Internal Reference Generator Feature" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_int_ref_generator"/>
</div>
<div class="mt16 row" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}">
<label for="sh_new_product_int_ref_generator" string="Auto Generate Internal Reference For New Products" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_new_product_int_ref_generator"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<div class="content-group">
<div class="mt16 row">
<button name="action_generate_int_ref" string="Generate Internal Reference for All Product" type="object" class="oe_highlight" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}"/>
</div>
<div class="mt16 row" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_sequence_separate" string="Product Sequence Separate" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_sequence_separate"/>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<span class="o_form_label" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}">Product Name Config</span>
<div class="content-group">
<div class="mt16 row" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_name_config" string="Product Name Config" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_name_config"/>
</div>
<div class="mt16 row" attrs="{'invisible':['|',('sh_product_name_config','=',False),('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_name_digit" string="Product Name Digit" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_name_digit"/>
</div>
<div class="mt16 row" attrs="{'invisible':['|',('sh_product_name_config','=',False),('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_name_separate" string="Product Name Separate" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_name_separate"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<span class="o_form_label" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}">Product Attribute Config</span>
<div class="content-group">
<div class="mt16 row" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_attribute_config" string="Product Attribute Config" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_attribute_config"/>
</div>
<div class="mt16 row" attrs="{'invisible':['|',('sh_product_attribute_config','=',False),('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_attribute_name_digit" string="Product Attribute Name Digit" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_attribute_name_digit"/>
</div>
<div class="mt16 row" attrs="{'invisible':['|',('sh_product_attribute_config','=',False),('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_attribute_name_separate" string="Product Attribute Name Separate" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_attribute_name_separate"/>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<span class="o_form_label" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}">Product Category Config</span>
<div class="content-group">
<div class="mt16 row" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_cataegory_config" string="Product Category Config" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_cataegory_config"/>
</div>
<div class="mt16 row" attrs="{'invisible':['|',('sh_product_cataegory_config','=',False),('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_category_digit" string="Product Category Digit" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_category_digit"/>
</div>
<div class="mt16 row" attrs="{'invisible':['|',('sh_product_cataegory_config','=',False),('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_catagory_separate" string="Product Category Separate" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_catagory_separate"/>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<span class="o_form_label" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}">Product Sequence Config</span>
<div class="content-group">
<div class="mt16 row" attrs="{'invisible':[('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_sequence_config" string="Product Sequence Config" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_sequence_config"/>
</div>
<div class="mt16 row" attrs="{'invisible':['|',('sh_product_sequence_config','=',False),('sh_product_int_ref_generator','=',False)]}">
<label for="sh_product_sequence" string="Product Sequence" class="col-3 col-lg-3 o_light_label"/>
<field name="sh_product_sequence"/>
</div>
</div>
</div>
</div>
</div>
</div>
</xpath>
</field>
</record>
</data>
</odoo>
Here is the my .py file code:
from odoo import models, fields, api, _
class ShResCompany(models.Model):
_inherit = 'res.company'
sh_product_int_ref_generator = fields.Boolean(string="Product Internal Reference Generator Feature")
sh_product_name_config = fields.Boolean(string="Product Name Config")
sh_product_name_digit = fields.Char(string="Product Name Digit", default="1")
sh_product_name_separate = fields.Char(string="Product Name Separate")
sh_product_attribute_config = fields.Boolean(string="Product Attribute Config")
sh_product_attribute_name_digit = fields.Char(string="Product Attribute Name Digit", default="1")
sh_product_attribute_name_separate = fields.Char(string="Product Attribute Name Separate")
sh_product_cataegory_config = fields.Boolean(string="Product Category Config")
sh_product_category_digit = fields.Char(string="Product Category Digit", default="1")
sh_product_catagory_separate = fields.Char(string="Product Category Separate")
sh_product_sequence_config = fields.Boolean(string="Product Sequence Config")
sh_product_sequence = fields.Many2one('ir.sequence', string="Product Sequence")
sh_product_sequence_separate = fields.Char(string="Product Sequence Separate")
sh_new_product_int_ref_generator = fields.Boolean(string="Auto Generate Internal Reference For New Products")
class ShResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
sh_product_int_ref_generator = fields.Boolean(string="Product Internal Reference Generator Feature", related="company_id.sh_product_int_ref_generator", readonly=False)
sh_product_name_config = fields.Boolean(string="Product Name Config", related="company_id.sh_product_name_config", readonly=False)
sh_product_name_digit = fields.Char(string="Product Name Digit", default="1", related="company_id.sh_product_name_digit", readonly=False)
sh_product_name_separate = fields.Char(string="Product Name Separate", related="company_id.sh_product_name_separate", readonly=False)
sh_product_attribute_config = fields.Boolean(string="Product Attribute Config", related="company_id.sh_product_attribute_config", readonly=False)
sh_product_attribute_name_digit = fields.Char(string="Product Attribute Name Digit", default="1", related="company_id.sh_product_attribute_name_digit", readonly=False)
sh_product_attribute_name_separate = fields.Char(string="Product Attribute Name Separate", related="company_id.sh_product_attribute_name_separate", readonly=False)
sh_product_cataegory_config = fields.Boolean(string="Product Category Config", related="company_id.sh_product_cataegory_config", readonly=False)
sh_product_category_digit = fields.Char(string="Product Category Digit", default="1", related="company_id.sh_product_category_digit", readonly=False)
sh_product_catagory_separate = fields.Char(string="Product Category Separate", related="company_id.sh_product_catagory_separate", readonly=False)
sh_product_sequence_config = fields.Boolean(string="Product Sequence Config", related="company_id.sh_product_sequence_config", readonly=False)
sh_product_sequence = fields.Many2one('ir.sequence', string="Product Sequence", related="company_id.sh_product_sequence", readonly=False)
sh_product_sequence_separate = fields.Char(string="Product Sequence Separate", related="company_id.sh_product_sequence_separate", readonly=False)
sh_new_product_int_ref_generator = fields.Boolean(string="Auto Generate Internal Reference For New Products", related="company_id.sh_new_product_int_ref_generator", readonly=False)
def action_generate_int_ref(self):
return {
'name':'Generate Internal Reference',
'type':'ir.actions.act_window',
'binding_view_types':'form',
'view_mode':'form',
'res_model':'internal.reference.wizard',
'target':'new',
}
Related
I have a nested group Angular form. I want to take the group's controls values and match the name of the controls to my JSON object
I have a small contact form that I have built using Angular. I want to validate the form and change the form data to JSON object. Here's my Form: <form [formGroup]="addContactForm" (ngSubmit)="onSubmit()" novalidate > <div [hidden]="addcontactForm.submitted"> <div class="modal-body" style="overflow: auto"> <!-- create contact --> <div style="padding: 0 0px 0px 25px;margin-top:30px;"> <div class="form-horizontal"> <span *ngIf="ACname.invalid && (ACname.dirty || ACname.touched)" class="has-error"> <span *ngIf="ACname.errors.required"> Last Name is required. </span> </span> <!-- name --> <div FormGroupName="ACname"> <div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': ACname.addContactFirstName.invalid && (ACname.addContactFirstName.dirty || ACname.addContactFirstName.touched) }"> <label class="col-sm-3" for="addContactFirstName">First Name</label> <div class="col-sm-7"> <input id="addFirstName" formControlName="addContactFirstName" class="form-control" placeholder="Enter First Name" /> </div> </div> <div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': ACname.addContactLastName.invalid && (ACname.addContactLastName.dirty || ACname.addContactLastName.touched) }"> <label class="col-sm-3" for="addContactLastName">Last Name</label> <div class="col-sm-7"> <input id="addLastName" class="form-control" formControlName="addContactLastName" placeholder="Enter Last Name" /> </div> </div> </div> <div FormGroupName="ACcontactMethod"> <!-- office phone --> <div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': ACcontactMethod.addcontactForm.submitted && !ACcontactMethod.addContactOfficePhone.valid }"> <label class="col-sm-3" for="addContactOfficePhone">Office Phone</label> <div class="col-sm-7"> <input id="addofcPhone" type="text" class="form-control" formControlName="addContactOfficePhone" placeholder="Enter Office Number" /> <span *ngIf="addContactOfficePhone.invalid && (addContactOfficePhone.dirty || addContactOfficePhone.touched)" class="has-error"> <span *ngIf="addContactLastName.errors.required"> Name is required. </span> </span> </div> </div> <!-- mobile phone --> <div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactMobilePhone.valid }"> <label class="col-sm-3" for="addContactMobilePhone">Mobile Phone</label> <div class="col-sm-7"> <input id="addmobPhone" type="text" class="form-control" formControlName="addContactMobilePhone" placeholder="Enter Mobile Number" /> <span *ngIf="addContactMobilePhone.invalid && (addContactMobilePhone.dirty || addContactMobilePhone.touched)" class="has-error"> <span *ngIf="addContactMobilePhone.errors.required"> Name is required. </span> </span> </div> </div> <!-- home phone --> <div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactHomePhone.valid }"> <label class="col-sm-3" for="addContactHomePhone">Home Phone</label> <div class="col-sm-7"> <input id="addhomPhone" type="text" class="form-control" formControlName="addContactHomePhone" placeholder="Enter Home Number" /> <span *ngIf="addContactHomePhone.invalid && (addContactHomePhone.dirty || addContactHomePhone.touched)" class="has-error"> <span *ngIf="addContactHomePhone.errors.required"> Name is required. </span> </span> </div> </div> <!-- email --> <div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactEmail.valid }"> <label class="col-sm-3" for="addContactEmail">Email</label> <div class="col-sm-7"> <input id="addEmail" type="email" class="form-control" formControlName="addContactEmail" placeholder="Enter Email" /> <span *ngIf="addContactEmail.invalid && (addContactEmail.dirty || addContactEmail.touched)" class="has-error"> <span *ngIf="addContactEmail.errors.required"> Name is required. </span> </span> </div> </div> <!-- chat id --> <div class="form-group" style="text-align:right" [ngClass]="{ 'has-error': addcontactForm.submitted && !addContactChatId.valid }"> <label class="col-sm-3" for="addContactChatId">Chat ID</label> <div class="col-sm-7"> <input id="addChatID" type="text" class="form-control" formControlName="addContactChatId" placeholder="Enter Chat ID" /> <span *ngIf="addContactChatId.invalid && (addContactChatId.dirty || addContactChatId.touched)" class="has-error"> <span *ngIf="addContactChatId.errors.required"> Name is required. </span> </span> </div> </div> </div> </div> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default pull-left" (click)="addcontactForm.reset()" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary" [disabled]="!addcontactForm.valid" (click)="addContact(model);"> Add Contact </button> </div> </div> <div class="submitted-message" *ngIf="addcontactForm.submitted"> <p>You've submitted your contact, {{ addcontactForm.value.addContactFirstName }} {{ addcontactForm.value.addContactLastName }}!</p> <button type="button" class="btn btn-default pull-left" (click)="addcontactForm.reset()" data-dismiss="modal">Close</button> <button (click)="addcontactForm.resetForm({})">Add new Contact </button> </div> </form> Here's my ts: import { Component} from '#angular/core'; import { AppComponent } from '../app.component'; import { FormBuilder, Validators, FormGroup, FormControl } from '#angular/forms'; #Component({ selector: 'addcontactmodal', templateUrl: 'addcontact.component.html' }) export class AddContactModalComponent { id: any; addContactForm: FormGroup; constructor(private _appComponent: AppComponent, private fb: FormBuilder) { this.id = localStorage.getItem('Id'); this.addContactForm = this.fb.group({ ACname: new FormGroup({ addContactFirstName: new FormControl('', Validators.minLength(40)), addContactLastName: new FormControl('', Validators.minLength(40)), }), ACcontactMethod: new FormGroup({ addContactOfficePhone: new FormControl('', Validators.minLength(20)), addContactMobilePhone: new FormControl('', Validators.minLength(20)), addContactHomePhone: new FormControl('', Validators.minLength(20)), addContactEmail: new FormControl('', Validators.minLength(127)), addContactChatId: new FormControl('', Validators.minLength(127)) }) }); } // private method(s) private addContact() { let data = { ChatId: this.fb.group('addContactChatId').value, Email: addContactEmail, FirstName: addContactFirstName, HomePhone: addContactHomePhone, MobilePhone: addContactMobilePhone, LastName: addContactLastName, OfficePhone: this.model.addContactOfficePhone } this._appComponent.signalRService.setAgentContact(this.id, data); } } I want to: Validate the form Have the data output to JSON I do not get any of the validation the form promises. It doesn't submit. Errors: nhandled Promise rejection: Cannot read property 'invalid' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'invalid' of undefined at Object.View_AddContactModalComponent_0.co [as updateDirectives]
You are not using complete property paths for your validation messages. Here's a simplified template of yours: <form [formGroup]="addContactForm" (ngSubmit)="onSubmit()" novalidate > <!-- formGroupName - mark all form controls belonging to this group inside tag --> <div formGroupName="ACname"> <input formControlName="addContactFirstName" /> <!-- use complete property path or do like follows! --> <span *ngIf="addContactForm.hasError('minlength', 'ACname.addContactFirstName')"> Minlength 40 </span> </div> </form> StackBlitz
Unable to get submit action to occur in TYPO3 Fluid contact form
We are trying to manage to get a simple contact form running. But regardless of what we try, we get nothing at all. The form itself is on the front-end and configured like this : <f:section name="Main"> <div class="ext-frame container"> <h2>{record.header}</h2> <f:form action="submit" name="order" object="{order}" class="form-horizontal"> <f:for each="{settings.offer}" as="obj" key="id"> <div class="row offer"> <f:if condition="{obj.offer.img}"> <f:then> <div class="col-sm-4 col-md-4 offer-img-container"> <img src="../{obj.offer.img}" class="offer-image" alt="{obj.offer.img.alternative}" /> </div> </f:then> </f:if> <div class="col-sm-8 col-md-8 {f:if(condition: '{obj.offer.img} == \'\'', then: 'col-sm-offset-4 col-md-offset-4')}"> <label class="offer-label"> <f:form.radio property="offer" value="{id}" /> <div class="pull-right"> <p class="lead"> {obj.offer.title}<br/> <small>{obj.offer.subtitle}</small> </p> <p class="small">{obj.offer.description}</p> </div> </label> </div> </div> <hr /> </f:for> <div class="form-group row"> <label for="salut" class="col-sm-3 control-label">Anrede*</label> <div class="col-sm-5"> <f:form.select property="salut" options="{herr: 'Herr', frau: 'Frau'}" class="form-control" /> </div> </div> <div class="form-group row"> <label for="name" class="col-sm-3 control-label">Vorname*</label> <div class="col-sm-5"> <f:form.textfield property="name" value="" class="form-control" /> </div> </div> <div class="form-group row"> <label for="surname" class="col-sm-3 control-label">Nachname*</label> <div class="col-sm-5"> <f:form.textfield property="surname" value="" class="form-control" /> </div> </div> <div class="form-group row"> <div class="col-sm-3 cusnr"> <label for="cusNr" class="control-label">Kundennummer</label> <span id="helpBlock" class="help-block">(wenn bekannt)</span> </div> <div class="col-sm-5"> <f:form.textfield property="cusNr" value="" class="form-control" /> </div> </div> <div class="form-group row"> <label for="addr" class="col-sm-3 control-label">Straße/Hausnr.*</label> <div class="col-sm-5"> <f:form.textfield property="addr" value="" class="form-control" /> </div> </div> <div class="form-group row"> <label for="zip" class="col-sm-3 control-label">PLZ*</label> <div class="col-sm-3"> <div class="input-group"> <span class="input-group-addon">D-</span> <f:form.textfield property="zip" value="" class="form-control" type="number" maxlength="5" /> </div> </div> </div> <div class="form-group row"> <label for="city" class="col-sm-3 control-label">Ort*</label> <div class="col-sm-5"> <f:form.textfield property="city" value="" class="form-control" /> </div> </div> <div class="form-group row"> <label for="mail" class="col-sm-3 control-label">E-Mail*</label> <div class="col-sm-5"> <f:form.textfield property="mail" value="" class="form-control" type="email" /> </div> </div> <div class="form-group row"> <label for="phone" class="col-sm-3 control-label">Telefon</label> <div class="col-sm-5"> <f:form.textfield property="phone" value="" class="form-control" type="tel" /> </div> </div> <div class="form-group row"><div class="col-sm-offset-3 col-sm-5"> <f:form.select property="know" options="{ 0: 'a?*', 1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e', 6: 'f', 7: 'g' }" class="form-control" /> </div></div> <div class="form-group row"> <div class="col-sm-offset-3 col-sm-9"> <div class="checkbox"> <label> <f:form.checkbox name="term" value="1" /> Ich habe die AGB gelesen und erkläre mich mit ihnen einverstanden. Ich wurde über mein <a href="widerruf.php" target="_blank"> Widerrufsrecht</a> informiert. </label> </div> </div> </div> <div class="form-group row"> <f:form.submit name="submit" value="Send" class="col-xs-12 col-sm-5 col-sm-offset-3 btn" /> </div> </f:form> </div> </f:section> In our ContentController.php there is also a submitAction given but it seems that this Action is never called : public function submitAction() { echo 'Testoutput';exit; }
Where does the form lead you after submitting? Check out the final HTML action="" if everything is correct. Try to set the form "method" to POST. I've just had some problems with forms using GET because the target PID got lost for unknown reasons so I had to add a <input type="hidden" name="id" value="{targetPid}" /> to get it working.
JSF Form with a null value
I got a issue with my view, that I can't solve. My view has 6 forms but when I do the main submit a entire form has null values and a inputText in another form has null too, that's my view: <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"> <h:head> <title>Novo Cliente</title> </h:head> <h:body> <ui:composition template="templateAdmin.xhtml"> <ui:define name="conteudoAdmin"> <!-- inicio conteudo de novo cliente --> <div class="row mt"> <div class="col-lg-12"> <div class="form-panel"> <h4 class="mb"><i class="fa fa-angle-right"></i> Novo Cliente</h4> <h:form class="form-horizontal style-form" id="tipoCliente"> <th></th> <h:commandButton class="btn btn-primary" value="Pessoa Física" action="#{clienteController.pessoaFisica()}" /> <p:spacer width="75" height="10" /> <h:commandButton class="btn btn-success" value="Pessoa Jurídica" action="#{clienteController.pessoaJuridica()}" /> <br></br> <br></br> <br></br> </h:form> <h:form class="form-horizontal style-form" id="buscaCliente" > <!--inicio condicao CPF CNPJ--> <div class="form-group"> <h:outputLabel class="col-sm-2 col-sm-2 control-label" value="CPF" for="cpf" rendered="#{clienteController.cliente.tipoPessoa == 0}" /> <h:outputLabel class="col-sm-2 col-sm-2 control-label" value="CNPJ" for="cnpj" rendered="#{clienteController.cliente.tipoPessoa == 1}" /> <div class="col-sm-10"> <p:inputMask mask="999.999.999-99" id="cpf" value="#{clienteController.cliente.identificacao}" rendered="#{clienteController.cliente.tipoPessoa == 0}" /> <p:inputMask mask=" 99.999.999/9999-99" id="cnpj" value="#{clienteController.cliente.identificacao}" rendered="#{clienteController.cliente.tipoPessoa == 1}" /> <p:spacer width="55" height="10" /> <h:commandButton id="verifcarCliente" value="Verificar Cliente" actionListener="#{clienteController.buscaClienteCPFCNPJ()}" > </h:commandButton> </div> </div> </h:form> <h:form class="form-horizontal style-form" id="dadosCliente" rendered="#{clienteController.existeCliente == false}" > <div class="form-group"> <h:outputLabel value="Razão Social" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <h:inputText value="#{clienteController.cliente.nomeFantasia}" class="form-control" /> </div> </div> <div class="form-group"> <h:outputLabel value="Nome" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <h:inputText value="#{clienteController.cliente.nome}" class="form-control" /> </div> </div> <div class="form-group"> <h:outputLabel for="mask" value="Data de Nascimento" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <p:inputMask mask="99/99/9999" id="dataNasc" value="#{clienteController.dataNascimento}" /> </div> </div> <div class="form-group"> <h:outputLabel class="col-sm-2 col-sm-2 control-label" value="Telefone" for="tel" /> <div class="col-sm-10"> <p:inputMask mask="(99)9999-9999" id="tel" value="#{clienteController.cliente.telefone}"/> </div> </div> <div class="form-group"> <h:outputLabel value="E-mail" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <h:inputText id="email" value="#{clienteController.cliente.email}" class="form-control" required="true" pt:placeholder="ex: email#dominio.com" validatorMessage="Endereço de email inválido."> <f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_]#[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" /> </h:inputText> <h:message for="email" /> </div> </div> <div class="form-group"> <h:outputLabel value="Site" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <h:inputText id="site" value="#{clienteController.cliente.site}" class="form-control" validatorMessage="Endereço de site inválido."> <f:validateRegex pattern="[\w\.-]*[a-zA-Z0-9_].[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" /> </h:inputText> <h:message for="site" /> </div> </div> </h:form> <h:form class="form-horizontal style-form" id="novoClienteCEP" rendered="#{clienteController.existeCliente == false}"> <div class="form-group"> <h:outputLabel class="col-sm-2 col-sm-2 control-label" value="CEP" for="cep" /> <div class="col-sm-10"> <h:inputText id="cep" value="#{clienteController.cep}" pt:placeholder="Somente Números" maxlength="8" required="true" validatorMessage="Digite somente os Números"> <f:validateRegex pattern="[0-9]+" /> <f:validateLength minimum="8" maximum="8" /> </h:inputText> <p:spacer width="55" height="10" /> <h:commandButton id="Buscar_Dados" value="Buscar Dados" actionListener="#{clienteController.buscarDadosCEP}" > <f:ajax execute="#form" render="novoClienteCEPDados"/> </h:commandButton> </div> </div> </h:form> <!--inicio autopreenchimento de endereço--> <h:form class="form-horizontal style-form" id="novoClienteCEPDados" rendered="#{clienteController.existeCliente == false}"> <ui:repeat value="#{clienteController.enderecos}" var="dadosEndereco" > <h:column > <div class="form-group"> <h:outputLabel value="Logradouro" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <h:inputText value="#{dadosEndereco.tipoEndereco} #{dadosEndereco.logradouro}" class="form-control" disabled="true" /> </div> </div> <div class="form-group"> <h:outputLabel value="Número" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <h:inputText value="#{clienteController.numero}" class="form-control" disabled="false" pt:placeholder="Somente Números" required="true" validatorMessage="Digite somente os Números"> <f:validateLength minimum="1" /> </h:inputText> </div> </div> <div class="form-group"> <h:outputLabel value="Bairro" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <h:inputText value="#{dadosEndereco.bairro}" class="form-control" disabled="true" /> </div> </div> <div class="form-group"> <h:outputLabel value="Cidade" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <h:inputText value="#{dadosEndereco.cidade}" class="form-control" disabled="true" /> </div> </div> <div class="form-group"> <h:outputLabel value="Estado" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <h:inputText value="#{dadosEndereco.UF}" class="form-control" disabled="true" /> </div> </div> </h:column> </ui:repeat> </h:form> <h:form class="form-horizontal style-form" id="novoClienteSalvar" rendered="#{clienteController.existeCliente == false}"> <!--fim auto preenchimeto endereco--> <h:commandButton id="Salvar" value="Salvar" action="#{clienteController.salvar}" > <f:ajax execute="#all" render="#all"/> </h:commandButton> <p:spacer width="95" height="10" /> <h:commandButton value="Cancelar" type="reset"/> <p:spacer width="25" height="10" /> </h:form> </div> </div> </div> <!-- fim conteudo de novo cliente --> </ui:define> </ui:composition> </h:body> The form dadosCliente and this inputText is null <div class="form-group"> <h:outputLabel value="Número" class="col-sm-2 col-sm-2 control-label" /> <div class="col-sm-10"> <h:inputText value="#{clienteController.numero}" class="form-control" disabled="false" pt:placeholder="Somente Números" required="true" validatorMessage="Digite somente os Números"> <f:validateLength minimum="1" /> </h:inputText> </div> </div> All other forms are correct, if I nest some forms It works, but I read that's not a good thing to do. Anyone??
Spring Tags Form Input
i have some probelm in spring tag form input.. if i use <form:input>..there will be error displayed java.io.IOException: JspException when evaluating the body but if i used html tag, it's can't connect to database. <form:form method="POST" action="/sampling/insert" modelAttribute="sampling"> <div class="form-row control-group row-fluid"> <label class="control-label span3" name="populasi" for="normal-field">Population</label> <div class="controls span9"> <form:input path="populasi" type="text" id="normal-field" class="row-fluid" /> </div> </div> <div class="form-row control-group row-fluid"> <label class="control-label span3" for="normal-field">Error Rate</label> <div class="controls span9"> <form:input path="tKesalahan" name="tKesalahan" type="text" id="normal-field" class="row-fluid" /> </div> </div> <input type="submit" class="btn btn-success" rel="tooltip" data-placement="top" value="Submit" /> </form:form>
Try this: name, type are not valid attributes change the tag attributes: <form:input path="tKesalahan" id="normal-field" cssClass="row-fluid" /> Reference: spring input tag attributes
Pre-populating a Spring MVC form
I am looking for a way to pre-populate a Spring MVC form from values stored in a session-scoped bean. (using this namespace: http://www.springframework.org/tags/form). For example, say I have added a queryInfo object to the uiModel. How do I display the name instance variable from the queryInfo object? <form:input path="queryInfo.name" /> Is this possible? If so how?
In your request mapping, add the bean to the model: model.addAttribute("queryInfo", queryInfo); Then use modelAttribute in the form tag to bind it to the form: <form:form id="some-form" modelAttribute="queryInfo"> ... Now name will display (provided there is a getter in your object appropriately named) when you do this: <form:input path="name" /> Keep in mind form:input is a child tag of form:form. It is not meant to be used on its own.
#skel625's solution for form:input is perfect, but in the case of the form:select, with different option how do I set attributes? because in this way only works for the form:input My form:select is like this: <form:select path="dolorefastidio"> <option value="1"><spring:message code="questionnaire.compile.label.paindiscomfort.one"/></option> <option value="2"><spring:message code="questionnaire.compile.label.paindiscomfort.two"/></option> <option value="3"><spring:message code="questionnaire.compile.label.paindiscomfort.three"/></option> <option value="4"><spring:message code="questionnaire.compile.label.paindiscomfort.four"/></option> <option value="5"><spring:message code="questionnaire.compile.label.paindiscomfort.five"/></option> </form:select>
the solution is put in a value attribute the bean attribute like this Exam Register Form <div class="form-group has-success"> <label for="code" class="col-lg-3 control-label">Exam Code</label> <div class="col-lg-9"> <form:input type="text" class="form-control" path="cod" placeholder="code" value="${editExam.cod}"/> <form:errors path="cod" cssClass="error" /> </div> </div> <div class="form-group has-success"> <label for="name" class="col-lg-3 control-label">Exam Name</label> <div class="col-lg-9"> <form:input type="text" class="form-control" path="name" placeholder="name" value="${editExam.name}"/> <form:errors path="name" cssClass="error" /> </div> </div> <div class="form-group has-success"> <label for="teachNme" class="col-lg-3 control-label">Teacher Name</label> <div class="col-lg-9"> <form:input type="text" class="form-control" path="teachName" placeholder="Teacher Name" value="${exams.teachName}" /> <form:errors path="teachName" cssClass="error" /> </div> </div> <div class="form-group has-success"> <label for="vote" class="col-lg-3 control-label">Final Grade</label> <div class="col-lg-9"> <form:input type="text" class="form-control" path="vote" placeholder="Vote" value="${exams.vote}" /> <form:errors path="vote" cssClass="error" /> </div> </div> <div class="form-group has-success"> <label for="cfu" class="col-lg-3 control-label">Credits (CFU)</label> <div class="col-lg-9"> <form:input type="text" class="form-control" path="cfu" placeholder="Credits" value="${editExam.cfu}" /> <form:errors path="cfu" cssClass="error" /> </div> </div> <input type="submit" value="Save" class="btn btn-primary pull-right"> </fieldset> </form:form>