Bringing dataTable selection data in modalPanel back to parent form
janpk May 14, 2010 6:17 AMHi,
I'm new to richfaces and have been trying to get a simple sample code running involving dataTable and modalPanel. I would have expected to find some examples of a usecase like this, but I just don't seem to be able to construct something that mr Google can use to give me information. I always get a ton of hits on opening a modalPanel showing details from at dataTable.
What I'm trying to achieve is from a page, press a link to popup a modalPanel. In the modalPanel I would like to perform a "search" to display a list of some data in a dataTable. Then I would like to select one of the rows and have data associated with the selected row propagated back into the original page.
I have successfully created an example where I use an input field in the modalPanel and gets the value entered there to be updated in the original page. Now I have expanded on the example and I am able to display the modalPanel, perform search and display the results in a data table. But I'm not able to figure out how to update the original page with values from the selected row. Anybody have any pointer to where I should look to find a solution to this ?
Here's the xhtml I use for this
<h:form> <h:panelGrid id="input"> <h:outputLabel value="Code: " /> <h:inputText value="#{PostalCode.postCode}" /> <a4j:keepAlive beanName="PostalCode" /> <a4j:commandButton id="link2" value="..." oncomplete="#{rich:component('modalPanel')}.show()" reRender="input"> </a4j:commandButton> </h:panelGrid> </h:form> <rich:modalPanel id="modalPanel" width="350" height="500"> <f:facet name="header"> Modal Panel </f:facet> <f:facet name="controls"> <h:graphicImage value="/global/images/close.png" style="cursor:pointer" onclick="#{rich:component('modalPanel')}.hide()" /> </f:facet> <a4j:region id="postFinder" renderRegionOnly="true"> <h:form> <a4j:commandButton styleClass="button" id="postSearch" onclick="this.disabled=true;" oncomplete="this.disabled=false;" action="#{PostalCodeBean.doSearch}" value="Search" reRender="postFinderSearchResults,postSearch" /> <a4j:status> <f:facet name="start"> <h:graphicImage value="/global/images/spinner.gif" /> </f:facet> </a4j:status> </h:form> <rich:dataTable id="postFinderSearchResults" value="#{PostalCodeBean.postalCodes}" var="postalCode" > <h:column> <a4j:commandLink value="#{postalCode.postCode}" reRender="input"> <a4j:actionparam name="paramName" value="#{postalCode.postCode}" assignTo="#{PostalCode.postCode}" /> </a4j:commandLink> </h:column> <h:column> <h:outputText id="postName" value="#{postalCode.postName}" /> </h:column> </rich:dataTable> </a4j:region> </rich:modalPanel>
Regards,
Jan-Petter