jsf 2 - How to pass a value on selected row change? -
i have permanent problem, have datatable value="#{mybean.items}" var="itms"
, , want pass selected item bean class.
in columns, use <f:setpropertyactionlistener value="#{itms}" target="#{mybean.selectedrow}" />
pass value, want rows. how that?, , put listener?.
thank much.
what richface version using?
for richfaces 4.3.x, following example might trick:
xhtml:
<rich:extendeddatatable id="mytable" value="#{crudbean.rows}" var="rowitem" rowclasses="odd-row, even-row" selection="#{crudbean.actionform.selection}" rows="#{crudbean.actionform.occurrences}" rowkeyvar="idx" > <a4j:ajax event="selectionchange" listener="#{crudbean.actionform.selectionlistener}" immediate="true" /> <rich:column width="100px" styleclass="#{rowitem.classname}"> ...stuff... </rich:column> <rich:column width="173px" styleclass="#{rowitem.classname}"> ...stuff... </rich:column> </rich:extendeddatatable>
the following code made sure got fired on row selection change:
<a4j:ajax event="selectionchange" listener="#{crudbean.actionform.selectionlistener}" immediate="true" />
the bean:
public void selectionlistener(ajaxbehaviorevent event) { uiextendeddatatable currentdatatable = (uiextendeddatatable) event.getcomponent(); object originalkey = currentdatatable.getrowkey(); // debug log statement log.debug("selectionlistener() - rowkey = {} ", originalkey); // debug log statement if (log.isdebugenabled()) { log.debug("\n selectionlistener() - rowindex = {}", currentdatatable.getrowindex()); } if (currentdatatable.isrowavailable()) { // selectionitems.add(datatable.getrowdata()); idatarow rowvalue = transform((idatagridrow)currentdatatable.getrowdata()); changeactiverow(rowvalue); } }
Comments
Post a Comment