Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Passing object as parameter in JSF using h:commandLink tag

user8769643Oct 18 2009 — edited Oct 20 2009
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 17 2009
Added on Oct 18 2009
12 comments
2,611 views