You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Peter Alfors <pe...@irista.com> on 2001/01/12 20:06:10 UTC

jsp:useBean runtime ids

Hello all,

    I have a design question.  I want each of my beans to have a static
ID variable that defines an ID for this bean.  The action classes would
then use this id to store the bean in the session/request.  Likewise,
the jsp pages would use this static variable as well to retrieve the
bean from the session/request.  I don't like having the pages and action

classes having to know the key to set/retrieve for the beans.
    The problem that I have is that the <jsp:useBean id""> id field does

not allow a runtime variable.  Having said that... Is there any other
way that I can have my JSP page retrieve a static member variable from a

bean and then use it as the reference to a bean stored within the
session/request????
    I assume that someone has come across this dilema already, and has
hopefully come up with an answer.  (of coarse, I may just be missing
something right under my nose!  :)  ).

Any help would be greatly appreciated,

    Peter Alfors

Re: jsp:useBean runtime ids

Posted by "Michael H. La Budde" <li...@prosoft-inc.com>.
Pete:

I can think of a coupla' ways you might do this.

1) Instead of the jsp:useBean syntax just use a normal Java variable 
declaration inside your jsp page.

2) Write your own taglib component to emulate the jsp:useBean....

HTH,

Mike


At 1/12/2001 01:06 PM, Peter Alfors wrote:
>Hello all,
>
>     I have a design question.  I want each of my beans to have a static
>ID variable that defines an ID for this bean.  The action classes would
>then use this id to store the bean in the session/request.  Likewise,
>the jsp pages would use this static variable as well to retrieve the
>bean from the session/request.  I don't like having the pages and action
>
>classes having to know the key to set/retrieve for the beans.
>     The problem that I have is that the <jsp:useBean id""> id field does
>
>not allow a runtime variable.  Having said that... Is there any other
>way that I can have my JSP page retrieve a static member variable from a
>
>bean and then use it as the reference to a bean stored within the
>session/request????
>     I assume that someone has come across this dilema already, and has
>hopefully come up with an answer.  (of coarse, I may just be missing
>something right under my nose!  :)  ).
>
>Any help would be greatly appreciated,
>
>     Peter Alfors