• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I bind this bean property?  RSS feed

 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In page1.jsp I need to have <hutputText value="handler.messageForKey" />

And page1.jsp is loaded via a javascript. So before page1 is loaded handler.key needs to be set so that the correct message is returned above. In the javascript I have access to key value, but I dont know where or how to bind it to handler.key, the key value is just a text in the html.

One way I was thinking was to pass the value as a request parameter to page1.jsp, but I still dont know how to use this to bind it to handler.key before the getMessageForKey is called.


Any ideas?
[ August 26, 2005: Message edited by: seb petterson ]
 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need more code example and detail. I don't really know what you mean by "loaded via a javascript".

I think this might work (or something close to it)...



However, I defer to the experts on this list.
 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Man. Always a greenhorn. Never a ranch hand. Anway...

I think my explanation was a little light. This...



would go inside your faces config for handler bean. However, my example was off. Let me try again...

URL: /page1.jsp?messageKey=ozzy



Make sure the scope stays as request. If its session or above, it'll only set the key the first time.

Again, comments from the experts?
 
Kevin Galligan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh yeah, if you want the bean to be in session scope, you could write the 'getKey' function to do the following...

return ((ServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("messageKey);
 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, cant quite get it to work though.

I think the code sample you gave of the managed-property element should be #{facesContext.externalContext.requestMap... but then what? Ive tried["messageKey"], and .messageKey, but it doesnt work. The value of the managedBean property is just set to null.

Help?
 
seb petterson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok got it. In order to pick up the value from request parameter, the managed property declaration should be #{param.key} in the value element.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!