You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Justin Chin <jc...@nyc.saic.com> on 2006/07/12 05:15:42 UTC

bean access in tile def?

Folks,

 

I have a message in a jsp which require a dynamic attribute that I set
on a bean from an action class.  I want to use that bean within the
tiles definition file.  Is that possible?  So for example, this is what
I would do in my jsp to get the dynamic attribute:

 

 

<%

int requiredNum =
((com.my.bean.TestBean)session.getAttribute("testbean")).getRequiredcoun
t();

%>

 

<bean:message key="my.message" arg0="<%=requiredNum%>"/>

 

 

My tile def looks like this:

 

  <!-- Layout -->

  <definition name="main.layout" path="/pages/layout/layout.jsp">

     <put name="title"        value=" "/>

     <put name="header"       value="/pages/layout/header.jsp"/>

     <put name="body"         value=""/>

     <put name="directions"   value=""/>

     <put name="footer"       value="/pages/layout/footer.jsp" />

  </definition>

 

 

I want to set "directions" dynamically from a bean which I stuff into
the session.  Is that possible, or am I totally off here?

 

Thanks,

Justin


Re: bean access in tile def?

Posted by Antonio Petrelli <br...@tariffenet.it>.
Justin Chin ha scritto:
> Folks,
>
>  
>
> I have a message in a jsp which require a dynamic attribute that I set
> on a bean from an action class.  I want to use that bean within the
> tiles definition file.  Is that possible?

No, it's not possible. Anyway, are you sure that you want to put a bean 
as a definition attribute? What I mean is that probably you only need to 
extend your base definition with specific ones, overriding the 
"directions" attribute. This is the case when you know all of those 
"directions" attributes at "compile" time.
Otherwise, you can do this in a JSP page:

<tiles:insert definition="main.layout">
    <tiles:put name="directions" beanName="myBean" beanScope="session" />
</tiles:insert>

Anyway I think that support for "beanName", "beanScope", etc. attributes 
in Tiles definitions should be provided.

HTH
Ciao
Antonio


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: bean access in tile def?

Posted by Antonio Petrelli <br...@tariffenet.it>.
Dan Langer ha scritto:
> Hopefully I'm wrong (both for your sake and mine), but that's the
> explanation I was given when I asked a similar question.
>   

Just for reference: 
http://www.mail-archive.com/user%40struts.apache.org/msg48310.html


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: bean access in tile def?

Posted by Dan Langer <dl...@targetsite.com>.
Justin,

I've been working on a similar problem, and based on what I've seen
posted here, I don't think it is doable (using definitions).

Technically, it seems that in order for what you'd like to do to work,
the definitions factory would need to be able to see the scope you're
placing that variable in - but since it's just a configuration file (and
hence isn't parsed/has no scope), it can't.

Hopefully I'm wrong (both for your sake and mine), but that's the
explanation I was given when I asked a similar question.

Dan

-----Original Message-----
From: Justin Chin 
Sent: Wednesday, July 12, 2006 4:16 AM
To: user@struts.apache.org
Subject: bean access in tile def?

Folks,

I have a message in a jsp which require a dynamic attribute that I set
on a bean from an action class.  I want to use that bean within the
tiles definition file.  Is that possible?  So for example, this is what
I would do in my jsp to get the dynamic attribute:

[...] 

I want to set "directions" dynamically from a bean which I stuff into
the session.  Is that possible, or am I totally off here?

 

Thanks,

Justin


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: bean access in tile def?

Posted by Dan Langer <dl...@targetsite.com>.
What's always got me about this issue is that the following:

Use and Set Bean in configuration file
It is now possible to use and set beans in the configuration file. Such
bean can then be set as a <put> or <putList> tag value.
This increase and facilitate menu creation.

Is listed as 'news' on Cedric's site
(http://www2.lifl.fr/~dumoulin/tiles/), dated to May 2002. Anyone know
what this is in reference to?

Dan


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org