aspose 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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pass parameters using insert tag