Problem with rendered inputs and form validation

UI Components for JSF
Post Reply
warley noleto
Posts: 2
Joined: 29 Sep 2011, 06:00

29 Sep 2011, 06:48

Hi everyone, I am facing a problem using form validation and the rendered property in my application. I dont know what i am doing wrong so I need help.

The problem is, i have a form where some inputs should not be rendered when including a new record. this inputs will be rendered only for updating a record. To achive this feature I used the rendered property (something like rendered="#{mBean.entity.id != null}". It works fine unless I have a validation fail in the form. when I select a record for updating the form is ok but if press the Save button with some incorrect input it shows the validation message but hide all the "rendered=#{mBean.entity.id != null}" inputs even the id still null. How can I fix this?

I am working with primefaces 2.2.1 in tomcat7.

my xhtml code

Code: Select all

<f:metadata>
	<f:viewParam name="id" value="#{myMBean.selected.id}" />
</f:metadata>
<h:form id="formu" >
	<p:focus />
	<h:inputHidden id="hdnId"  value="#{myMBean.selected.id}"/>
	<h:panelGrid columns="2" columnClasses="column" cellpadding="5">
		<h:outputLabel value="#{msgs.lbl_codigo}:" 
			rendered="#{myMBean.selected.id != null}" />
		<h:outputLabel id="lblId" value="#{myMBean.selected.id}"
			rendered="#{myMBean.selected.id != null}" />

		<h:outputLabel value="#{msgs.lbl_nome}:" />
		<p:inputText id="txtUsuario" value="#{myMBean.selected.name}"
			label="#{msgs.lbl_nome}" maxlength="200" required="true" size="100" />

		<h:outputLabel value="#{msgs.lbl_login }:" />
		<p:inputText  id="txtLogin" value="#{myMBean.selected.login}"
			label="#{msgs.lbl_login}" maxlength="30" required="true" size="30" />
	</h:panelGrid>
....

<p:commandButton value="#{msgs.btn_gravar}"
	action="#{CadUsuarioBean.actionGravar}"
	image="ui-icon ui-icon-disk" process="@this formu" ajax="false" />
and here is my ManagedBean action

Code: Select all

public String actionGravar() {
	nUser.save(this.selected);
	this.setSelected(null);
	info("Record saved."); //Faces message
	return "user-list";
}
I can fix the problem if replace ajax="false" with update="growl" but i would like to navigate to another page when successfull.

tks.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests