• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Pass parameters using insert tag

 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
There is no "i" in denial. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic