• 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

Why can't JSF calls method with parameter?

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have error when trying to execute a simple function. Let's just said I have following method in my backing bean



When I call the method from my JSF, using this code :


It displays following error:

foo must be used with a prefix when a default namespace is not specified


Well, I found a link in google. I suppose this will also happen using non-JSF EL in standard JSP page. The problem is how can I fix this in JSF (or JSP) EL?

Does JSF (or JSP) does not support parameterized method?? Why??
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
doesn't support =(

BUT JBOSS SEAM SUPPORTS! exactly like your code ;D

I think you are using a default JSF Implementation, so, in fact myfaces, RI, Rave, ADF , IceFaces and so on really don't support it

there are two ways to you send parameters to your backing bean

your component



your backing bean



the second way is using a f:param to send a parameter to your backingbean by request. The main difference of the last way is because this second way can pass parameters when you are calling a action method and not only a actionListener method(I MUST CONFIRM, I DON'T REALLY remember if this affirmation is true hahaha, so you can try and tell us if this way works calling an action :P)

your component:


your backing bean:



did you understand how it works?

I hope so

Leo
 
Pamungkas Timotius
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it works..
thanks for your help
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I tried the first option of Leonardo's response (using attributes) and I got a null pointer exception. Is there any reason this should occur?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ian Dunsirn:
Hello,

I tried the first option of Leonardo's response (using attributes) and I got a null pointer exception. Is there any reason this should occur?



Did you just copy and paste, because in his first one there is a spelling error in the get. Should be "attribute" but is showing "attybute" in the post above.

Mark
 
Ian Dunsirn
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No copy and paste at all.
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's dangerous. What if the param value is null? Just cast the value to String.

You may find this article useful too: http://balusc.blogspot.com/2006/06/communication-in-jsf.html
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
f:param works only on h:commandLink and h:outputLink:
<h:commandLink value="Hello" actionListener="#{reservationAction.getParam}">
<f:param name="myParam" value="hello" />
</h:commandLink>

public void getParam( ActionEvent e ) {
String myParam = ""+FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("myParam");
System.out.println(myParam);
}
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Was it really needed to resurrect an old, dead and already answered topic?
 
I AM MIGHTY! Especially when I hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic