• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pass parameters using insert tag

 
amit sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic