You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Steven Leija <St...@valtech.com> on 2001/04/06 00:33:53 UTC

Gathering Bean Information?

Hey All,

I have a quick question.  I'm trying to use a struts bean in a page to
simple display a vector with the following tag, but having problems.  The
name path to my bean is com.struts.UsersBean and in my struts-config.xml, I
have usersBean as the name value.  What value do I use to have it use the
usersBean instance?  Currently I have this code:

<table width="200" height="100" align="center">
  <logic:iterate id="element" property="users" name="com.struts.UsersBean"
scope="request"> 
	  <tr> <bean:write name="element"/> </tr>
  </logic:iterate> 
</table>

I thought that Struts automatically instantiated my bean if there wasn't an
instance already existing.  When my page is hit, how would I grab the bean
from my session or request if I haven't put it into my session/request?  Is
there a way to do this through my ActionForm class?

Thanks!

Steven

Re: Gathering Bean Information?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 5 Apr 2001, Steven Leija wrote:

> Hey All,
> 
> I have a quick question.  I'm trying to use a struts bean in a page to
> simple display a vector with the following tag, but having problems.  The
> name path to my bean is com.struts.UsersBean and in my struts-config.xml, I
> have usersBean as the name value.  What value do I use to have it use the
> usersBean instance?  Currently I have this code:
> 
> <table width="200" height="100" align="center">
>   <logic:iterate id="element" property="users" name="com.struts.UsersBean"
> scope="request"> 
> 	  <tr> <bean:write name="element"/> </tr>
>   </logic:iterate> 
> </table>
> 
> I thought that Struts automatically instantiated my bean if there wasn't an
> instance already existing.  When my page is hit, how would I grab the bean
> from my session or request if I haven't put it into my session/request?  Is
> there a way to do this through my ActionForm class?
> 

The only case where Struts automatically instantiates a bean is for form
beans.  In a JSP page, that only happens in the <html:form> tag.  If you
want to refer to a bean outside the form tag, you will need to make sure
it is instantiated already.

One thing to note -- "com.struts.UserBean" sounds like the class name of
your bean, rather than the attribute name under which you would store
it.  The class name would be specified (for example) in the
"type" attribute of <jsp:useBean>.

> Thanks!
> 
> Steven
> 

Craig McClanahan