• 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

getting the f:param from commandButton

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi every body
I have this tags in my jsp:
<h:commandLink action="#{book.edit}">
<f:param name="title" value="#{param.title}" />
</h:commandLink>

how can I get this param in edit method in class Book?

I try to use request.getParameter("title") and request.getRequestMap().get("title") but they work wrong!please help me!
regards
Arona
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to try using the FacesContext. Look at some of the examples at the following link...they may help you out.

http://www.jsffaq.com/Wiki.jsp?page=HowToAccessOneManagedBeanFromAnotherManagedBean
 
arona kosari
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
I use this code:
ExternalContex contex = FacesContex.getCurrentInstance().getExternalContext();
HttpServletRequest request = (HttpServletRequest)context.getRequest();

and then :
String title = request.getParameter("title");

but title is null.

Maybe I must use another method of getCurrentInstance().
please help me!
 
Josh Juneau
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try to request the parameter map instead of references to the HTTP session. Look at this topic below. It pertains to a commandLink, but it should also work for a commandButton. I hope this solves your issue...good luck!

http://wiki.apache.org/myfaces/ExecutingMethodsFromLinkButtonParameters

code:
FacesContext context = FacesContext.getCurrentInstance();
Map map = context.getExternalContext().getRequestParameterMap();
String localVariable = (String) map.get("your value");
 
arona kosari
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
At first thanks for the useful linkes.
I use the exact code you wrote, but still title is null.

FacesContext context = FacesContext.getCurrentInstance();
Map map = context.getExternalContext().getRequestParameterMap();
String title= (String) map.get("title");

Please help me.
Regards
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
f:param is only handled by h:commandLink. Per the spec, the commandButton doesn't perform any actions with respect to h:param.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just another way of doing this using a4j:
----------xhtml code------------------------
<a4j:form>
<a4j:commandButton action="#{TestPage.testMethod}" value="Submit">
<f:param name="title" value="TestValue" />
</a4j:commandButton>
</a4j:form>

---------backing bean code---------------------
public void testMethod(){
FacesContext context = FacesContext.getCurrentInstance();
Map map = context.getExternalContext().getRequestParameterMap();
String title1= (String) map.get("title");
}

Though its an old post, just adding my comments if it could help someone looking for same stuff.
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arnav Jain,

You saved my day !!!

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic