| Author |
Updating a form in primefaces when a selection is made in the datatable
|
Derrick Albers
Greenhorn
Joined: Nov 01, 2010
Posts: 20
|
|
I have a prime panel to display employee information and a datatable next to it, the datatable is getting populated and I am tyring to update the panel with that employee information when a row is selected. I am using dataTable and onRowSelect is getting the information that I want from the Backing bean but I can never get the inputtext fields to populate???
This is the page:
And this is my backing bean:
|
 |
Brendan Healey
Ranch Hand
Joined: May 12, 2009
Posts: 218
|
|
About 10 times a week I see someone on here or somewhere else who have multiple forms on a single
page and every time they're in trouble.
Use one form with prependId="false" and everything will start to become a lot simpler. Read up about
naming containers also.
Brendan.
|
 |
David Norris
Greenhorn
Joined: May 04, 2009
Posts: 3
|
|
Right and never mind separating concerns like putting parameters and returned data in separate forms.
While we're at it lets get rid of templates too. Just put everything in one page.
Why should primeFaces force me to stuff everything into one form? If it would not break this feature then maybe you wouldn't see this 10 times a week. It's not our fault PF breaks it.
Other frameworks work perfectly with multiple forms.
|
 |
Brendan Healey
Ranch Hand
Joined: May 12, 2009
Posts: 218
|
|
Hi David, my response was probably a little unhelpful, although I was genuinely trying to assist. I
stand by my original comment in that the use of multiple forms, whilst permissible (when not nested)
tends to cause more problems than it solves. I think it unlikely that PrimeFaces is causing the
problems you're experiencing, although there are some idiosynchracies related to referring to
component ids from within a p:datatable (i.e. you have to use form:compid when you otherwise
wouldn't need to). If you are still experiencing problems perhaps we could try and narrow down the
problem with a minimalist code structure?
Regards,
Brendan.
|
 |
sardar waqas ahmed
Greenhorn
Joined: Oct 19, 2011
Posts: 16
|
|
please tell me i have two form and cant update the command button whic is disable in form 2.i try alot but cant find a solution my code is below.
<h:form id="FamilyInfo">
<h:panelGrid columns="6" cellpadding="7" cellspacing="2"
id="grid3" columnClasses="a,b,c,d"
rowClasses="plainRow,shadedRow">
<h utputLabel value="Marital Status : " class="field-title" />
<p:selectOneMenu required="true" id="maritalstatus"
value="#{personalInfoBean.maritialStatusPerson}">
<f:selectItem itemLabel="Select Maritial Status"></f:selectItem>
<f:selectItem itemLabel="Single" itemValue="Single" />
<f:selectItem itemLabel="Married" itemValue="Married" />
<f:selectItem itemLabel="Widower" itemValue="Widower" />
<f:selectItem itemLabel="Divorce" itemValue="Divorce" />
<p:ajax event="blur" update="msg36" />
<p:ajax event="change" update="childaddbtn"
listener="#{personalInfoBean.handleStatusChange}" />
</p:selectOneMenu>
<p:message for="maritalstatus" id="msg36" display="icon" />
<h utputLabel value=" " class="field-title" />
<h utputLabel value=" " class="field-title" />
<h utputLabel value=" " class="field-title" />
<h utputLabel value="Name next of Kin : " class="field-title" />
<p:inputText
value="#{personalInfoBean.hrNextOfKin.nameNextOfKin}"
required="true" id="nok">
<p:ajax event="blur" update="msg37" />
<f:validateLength minimum="3" maximum="15"></f:validateLength>
</p:inputText>
<p:message for="nok" id="msg37" display="icon" />
<h:commandButton value="Save" action="#personalInfoBean.saveHrNOK}" class="defaultButton" />
</h:form>
<h:form id="nokChildForm">
<p:dialog header="Children" widgetVar="dlgchild" id="childDlg">
<h:panelGrid columns="3" cellpadding="5">
<h utputLabel value="Name : " />
<p:inputText value="#{personalInfoBean.nokChild.childrenName}"
required="true" id="chlname">
<p:ajax event="blur" update="msgchld" />
<f:validateLength minimum="3" maximum="25"></f:validateLength>
</p:inputText>
<p:message for="chlname" id="msgchld" display="icon" />
<h utputLabel value="Gender :" />
<p:selectOneMenu id="chldgender" required="true"
value="#{personalInfoBean.nokChild.childrenGender}">
<f:selectItem itemLabel="Select Gender" itemValue="" />
<f:selectItem itemLabel="Male" itemValue="Male" />
<f:selectItem itemLabel="Female" itemValue="Female" />
<p:ajax event="blur" update="msgchldGnd" />
</p:selectOneMenu>
<p:message for="chldgender" id="msgchldGnd" display="icon" />
<h utputLabel value="Age :" />
<p:inputText value="#{personalInfoBean.nokChild.childrenAge}"
required="true" id="chldage">
<p:ajax event="blur" update="msgchldage" />
<f:validateLength minimum="1" maximum="3"></f:validateLength>
</p:inputText>
<p:message for="chldage" id="msgchldage" display="icon" />
<f:facet name="footer">
<p:commandButton value="Save" update="nokChildList"
oncomplete="handleAddChildrenRequest(xhr, status, args)"
actionListener="#{personalInfoBean.setNOKChild}" />
</f:facet>
</h:panelGrid>
<div style="padding-left: 950px; padding-top: 28px">
<p:commandButton disabled="#{personalInfoBean.addButtonChildren}" value="Add Children" id="childaddbtn" onclick="dlgchild.show()"/></div>
<h:commandButton value="Save" action="#{personalInfoBean.saveHrNOK}" class="defaultButton" />
</h:form>
when i change dropdown of from one the button on second form should be enabled by default that button is disabled how i do it.this button is not getting enabled when i change the dropdown
<p:commandButton disabled="#{personalInfoBean.addButtonChildren}" value="Add Children" id="childaddbtn" onclick="dlgchild.show()"/>
|
 |
 |
|
|
subject: Updating a form in primefaces when a selection is made in the datatable
|
|
|