问题
I have one extended Data Table in payeeSearch.xhtml displayed as -
1) After clicking on show particulars, it should navigate to a different view and display a new table based on the result achieved by one of the column's value of the selected row (In figure, it is IN303285...)
2) I have written code for navigating to the next view as -
<rich:contextMenu attached="false" id="menu" submitMode="ajax">
<rich:menuItem ajaxSingle="true" value="Show Particulars" action="payeeParticulars.xhtml">
<a4j:support event="onclick" actionListener="#{payeeSearchController.showParticulars}"/>
</rich:menuItem>
3) This view (payeeParticulars.xhtml) is displaying another extendedDataTable.
And the showPartulatrs actionlistener is being used to pass the column's value of the selected row to PayeeParticulars.java class, But it is always passing the null value even though I am able to get the value in payeeSearch.java class.
4) I am writing code to display the new extendedDataTable in constructor of the PayeeParticulars.java class
Can anybody tell me where I am going wrong, or how to pass the value of one column of the selected row to another view and display the result accordingly in a new extendedDataTable.
Please help me out....
回答1:
Use rich:menuItem like this....
<rich:menuItem submitMode="ajax" value="Show Particulars" action="#{payeeParticularsController.showParticular}"/>
and then in controller file put
public String showParticular()
{
// operation
return "details";
}
and then in navigation rules set one rule as -
<navigation-rule>
<from-view-id>/payeeSearch.xhtml</from-view-id>
<navigation-case>
<from-outcome>details</from-outcome>
<if>#{payeeParticularsController.selectedFolioNo != null}</if>
<to-view-id>/payeeParticulars.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
It will let you pass the value from one class to another and also new view will not be loaded until the if condition will be satisfied.
来源:https://stackoverflow.com/questions/10492821/jsf-2-0-how-to-pass-a-value-from-one-class-to-another