Hi ,
I have a scenario in which i need to pass objects from one jsp to another using h:commandLink. i read balusC article "Communication in JSF" and found a basic idea of achieving it. Thanks to BalusC for the wonderful article. But i am not fully clear on the concepts and the code is giving some error. The code i have is
My JSP:
This commandlink is inside a <h:column> tag of <h:dataTable>
<h:commandLink id="ol3"action="ManageAccount" actionListener="#{admincontroller.action}" >
<f:param id="ag" name="account" value="#{admincontroller.account}" />
<h:outputText id="ot3" value="Manage Account" rendered="#{adminbean.productList!=null}" />
</h:commandLink>
Also a binding in h:dataTable tag with the binding="#{admincontroller.dataTable}"
My Backing Bean:
public class CompanyAdminController {
private HtmlDataTable dataTable;
private Account account=new Account();
public HtmlDataTable getDataTable() {
return dataTable;
}
public Account getAccount() {
return this.account;
}
public void setAccount(Account account) {
this.account = account;
}
public void action(){
account= (Account)this.getDataTable().getRowData();
}
faces-config.xml
<navigation-rule>
<from-view-id>/compadmin.jsp</from-view-id>
<navigation-case>
<from-outcome>ManageAccount</from-outcome>
<to-view-id>/manageAccount.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>admincontroller</managed-bean-name>
<managed-bean-class>com.forrester.AdminController</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>account</property-name>
<property-class>com.model.Account</property-class>
<value>#{param.account}</value>
</managed-property>
</managed-bean>
My account object:
public class Account {
string name;
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name=name;
}
I need to display #{admincontroller.account.name} in my forwarded jsp. But I am not sure whether the code i wrote in commandlink is correct. I get an error if i use <f:setActionListener> . No tag "setPropertyActionListener" defined in tag library imported with prefix "f"
Please advise.
Edited by: twisai on Oct 18, 2009 11:46 AM
Edited by: twisai on Oct 18, 2009 11:47 AM
Edited by: twisai on Oct 18, 2009 11:48 AM