I have a <p:datatable>
where the user can select the radio button corresponding to a row in order to update that row. As of now, I populate another datatable with the information to edit by having the user click a button that calls a method. However, I would like to have the second datatable populated right when the user clicks the radio button of their desired row.
<h:form id="dataForm">
<p:panel styleClass="center" id="dataPanel">
<!-- This is where the results of the search are displayed. -->
<p:dataTable id="metadataitems" var="result"
value="#{updateMetadataItemsBean.results}" styleClass="center"
resizableColumns="true"
selection="#{updateMetadataItemsBean.selectedMetadataItem}"
rowKey="#{result.rowKey}" rendered="#{updateMetadataItemsBean.show}">
<p:ajax event="rowSelectRadio" listener="#{updateMetadataItemsBean.prepareEdit}" />
<p:column headerText="Select Item to Update" selectionMode="single" update="dataForm"></p:column>
</p:dataTable>
</p:panel>
<p:panel styleClass="centered" id="dataPanel2"
style="font-size:.75em;">
<p:messages id="message2" showDetails="true" />
<p:dataTable value="" var="metadataitemsInput" id="editTable">
<!--This is what I want to update-->
</p:dataTable>
<p:commandButton id="submit" value="Submit"
action="#{updateMetadataItemsBean.edit}"
update="message2, dataForm:dataPanel" />
<p:commandButton id="delete" value="Delete"
action="#{updateMetadataItemsBean.delete}"
update="message2, dataForm:dataPanel" />
</p:panel>
</h:form>
I can't find a way to call my method as soon as the user clicks one of the radio buttons.
This is the method that its supposed to call:
public void prepareEdit(SelectEvent e) {
//set variables that are references by <p:inplace> in datatable
}