File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Pass parameters using insert tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Pass parameters using insert tag " Watch "Pass parameters using insert tag " New topic
Author

Pass parameters using insert tag

amit sharma
Ranch Hand

Joined: Jul 19, 2006
Posts: 129
my code is

I want to pass parameters to DropDown.xhtml .But not everyone will pass parameters to tag .If someone not pass the tag then it should use some default value.
Thanks
Anil kumar
Greenhorn

Joined: Dec 05, 2008
Posts: 3
you can pass parameters like this

on page1.xhtml

<ui:include src="page2.xhtml">
<ui:param name="param1" value="one"/>
<ui:param name="param2" value="two"/>
</ui:include>

page2.xhtml

<h:commandLink action="${bean.prevPage}">
<f:param name="prev" value="#{param1}" />

</h:commandLink>

<h:commandLink action="#{bean.nextPage}">
<f:param name="next" value="#{param2}" />

</h:commandLink>

on the backing bean you can access params ..

public String nextPage() {
String nextPage = (String)
FacesContext.getCurrentInstance(). getExternalContext()
.getRequestParameterMap().get("next");
return nextPage;
}
public String prevPage() {
String prevPage = (String)
FacesContext.getCurrentInstance(). getExternalContext()
.getRequestParameterMap().get("prev");
return prevPage;
}
amit sharma
Ranch Hand

Joined: Jul 19, 2006
Posts: 129
Originally posted by Anil11:
you can pass parameters like this

on page1.xhtml

<ui:include src="page2.xhtml">
<ui:param name="param1" value="one"/>
<ui:param name="param2" value="two"/>
</ui:include>

page2.xhtml

<h:commandLink action="${bean.prevPage}">
<f:param name="prev" value="#{param1}" />

</h:commandLink>

<h:commandLink action="#{bean.nextPage}">
<f:param name="next" value="#{param2}" />

</h:commandLink>

on the backing bean you can access params ..

public String nextPage() {
String nextPage = (String)
FacesContext.getCurrentInstance(). getExternalContext()
.getRequestParameterMap().get("next");
return nextPage;
}
public String prevPage() {
String prevPage = (String)
FacesContext.getCurrentInstance(). getExternalContext()
.getRequestParameterMap().get("prev");
return prevPage;
}

Thanks for your reply .
But if some users don't want any parameters i want to use some default value for that parameter.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Pass parameters using insert tag
 
Similar Threads
Facelets + CSS problem; CSS is not applied after first request
Facelets template/composition without name atribute
Facelets custom component does not insert ui:repeat or c:forEach
internationlization in facelet seems not working well
In wich tag should I call a javaScript function?