Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sending parameters from JSF to JSF  RSS feed

 
Rohit Kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have 2 JSF screens . first.jsf and second.jsf.
In first.jsf , I have 2 different links , one is �save� and other is �copy� .On clicking either of the link it goes to same second.jsf
In second.jsf , I have 3 command buttons.
1. Save 2. Copy 3.Cancel
When the user clicks save on first.jsf , it goes to second.jsf and displays only 2 command buttons (save,cancel)
When user clicks copy on first.jsf, it goes to second.jsf and displays only 2 command buttons (copy,cancel)
Below is the code I am doing. Command link for �save� on first.jsf
<h:commandLink immediate ="true" action = "#{controller.control}" >
<f:param name="cipIdValue" value="#{cipDetailed.cipId}" />
<f:param name ="save" value = "save" />
<hutputText styleClass="user" valueue="#{cipDetailed.comments}"/>
</h:commandLink>
Command link for �copy� on first.jsf
<h:commandLink immediate ="true" action = "#{controller.control}" >
<f:param name="cipIdValue" value="#{cipDetailed.cipId}" />
<f:param name ="copy" value = "copy" />
<hutputText styleClass="user" value="#{cipDetailed.cipId}"/>
</h:commandLink>

In the faces-config file, I have added save and copy as managed-property
<managed-bean>
<managed-bean-name>capitalImproveProj</managed-bean-name>
<managed-bean-class>gov.gdot.ooit.asm.dto.CapitalImproveProj</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>save</property-name>
<value>#{param.save}</value>
</managed-property>
<managed-property>
<property-name>copy</property-name>
<value>#{param.copy}</value>
</managed-property>
</managed-bean>
In the capitalImproveProj.java (dto) I have getter/setters for save and copy.

How can I get the parameter value to second.jsf like (save/copy ) and show the respective buttons like (save/cancel) and (copy/cancel)
Do please suggest me, any snippet of code is helpful

Thanks
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would use a parameter within your backingbean from which you can decide if a certain button will be rendered in second.jsf.

Because this bean handles screen logic I will separate that from your business logic.

If the users presses on save then you will set your form as a saveform. You can then set your buttons on rendered if the form is a saveform

If the users presses on copy then you will set your second form as a copyform. You can then set your buttons on rendered if the form is a copyform

You can one int parameter for that because you form could either be a saveform or a copyform and not both.
 
Rohit Kumar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Remko,

Thanks for the reply..any snippet of code according to my code is a lot helpful.

Could you please provide me that..
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!