• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Accessing backing bean.

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I'm a newbie with JSF so please bear with me. I would like to pass a HTTP header value to my backing bean but I'm not sure how to go about doing so. At present, the user's input is passed on to my backing bean in the standard form of

<h:inputText value="#{userBean.userName}" />

However, I would like userName to be assigned the value of a HTTP header, which is in the form of:

String headVal = request.getHeader("shib host");

So basically, I would like headVal to be passed on to my backing bean instead of the user's input. How would I do this? Any help in this matter would be greatly appreciated. Cheers.
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the <f:param /> tag.
 
James Maddison
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Remko,

I tried what you suggested but I'm getting the following error:

javax.faces.FacesException: /login.jsp(49,3) According to TLD or attribute directive in tag file, attribute value does not accept any expressions

What I tried to do is:

<f:param
value="${headerVal}"
id="userBean"
name="userName" />

Am I doing it wrong? Thanks again for your help.
 
Remko Strating
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you use in your backing bean the following method for reading your variable

 
I'm doing laundry! Look how clean this tiny ad is:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic