This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Access backing bean variables from JSP directly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Access backing bean variables from JSP directly" Watch "Access backing bean variables from JSP directly" New topic
Author

Access backing bean variables from JSP directly

raju svgk
Greenhorn

Joined: Sep 25, 2002
Posts: 14
Hi, I need to access backing bean variables directly from the JSP. Not able to figure out how to do it. I created a Hashtable (details) and String[] (header) variables in the backing bean and initialized both in the corresponding backing bean constructor. Now I want to access those two variables from the JSP and apply some logic to format them properly. How can I do it?

Backing bean code

package com.itools.vs.view.backing.General;


find.jsp JSP code:

faces-config.xml
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

Backing beans are not some sort of magical creation that only JSF understands. Backing beans are ordinary Javabeans that have been wired into the JSF application. JSF can construct them and connect them together, but unlike Struts formbeans and action beans, they don't have any special properties or attributes of their own.

So if you want to get at a session backing bean, use the same technique you'd use to get at any other J2EE session bean.


Customer surveys are for companies who didn't pay proper attention to begin with.
raju svgk
Greenhorn

Joined: Sep 25, 2002
Posts: 14
In the given example find.jsp is JSF only. I am treating JSF means backing bean with an associated JSP. In my JSF I can access the backing bean attribuites trough <hutputtext ..../> etc., Now I want to access those backing bean attributes between

<%

%>

How can I achieve this?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15952
    
  19

Probably the easiest way would be via JSTL. Use a useBean to define the backing bean to the JSP and a cut to print the property value.
Cyrille Pontvieux
Greenhorn

Joined: Sep 25, 2009
Posts: 1


You defined "backing_General_top" but you used "backing_General_find", here is the error.
 
Consider Paul's rocket mass heater.
 
subject: Access backing bean variables from JSP directly
 
Similar Threads
Unable to call Action Methof
initial page event
passing parameter from non JSF URL to JSF backing bean
Setting ID attribute in backing bean
Struts: No getter method for property name problem