Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Access backing bean variables from JSP directly

 
raju svgk
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18218
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
raju svgk
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18218
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You defined "backing_General_top" but you used "backing_General_find", here is the error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic