> -----Original Message-----
> From: Andy Engle [mailto:[EMAIL PROTECTED]
> Sent: Friday, August 13, 2004 2:00 PM
> To: Struts Users Mailing List
> Subject: RE: Displaying bean values within tiles
> 
> 
> Ok, let me get this straight.  I'll go down the list and you see if I
> have each step correct:
> 
> 1. Put a string in some scope, like the request scope:
> 
> request.setAttribute("thispagetitle", results.getWhatever());
> 
> 
> 2. In my "results" page, I want the title of that page to be the value
> that I sent back as "thispagetitle", so I will do this:
> 
> <tiles:useAttribute id="thispagetitle" name="pagetitle"/>

Ummm.. it's in request scope so <c:out value="${thispagetitle}"/> or <bean:write would 
work better.

> 
> Which will put the value of "thispagetitle" into "pagetitle".

No, <tiles:useAttribute only looks at tiles scope, which is it's own unique scope.

> 
> 
> 3. Then, in my template file, whatever is put into "pagetitle" will be
> displayed:
> 
> <title>Results: <tiles:getAsString name="pagetitle"/></title>
> 
> ...which should display getWhatever() in step #1.
> 
> 
> Is that the way this thing works?


No.  Not if you're puttting the title into request scope.
Put the title in the tiles definition, and it would work that way, just like my 
example.



> 
> Thank you for your help!
> 
> 
> Andy
> 
> 
> 
> 
> 
> 
> 
> --- Jim Barrows <[EMAIL PROTECTED]> wrote:
> 
> > 
> > 
> > > -----Original Message-----
> > > From: Andy Engle [mailto:[EMAIL PROTECTED]
> > > Sent: Friday, August 13, 2004 12:05 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Displaying bean values within tiles
> > > 
> > > 
> > > Hi all,
> > > 
> > > I hate to ask a real, boring, non-OT question on a 
> Friday, but I am
> > > working with a Struts application in which I am using tiles 
> > > to organize
> > > my views.  What I want to be able to do is pass in a bean 
> > > with a String
> > > (or, "string beans" for all you farmer types out there) into my
> > tiles
> > > setup and have that value displayed in my view.
> > > 
> > > I have my tiles definitions in tiles-defs.xml, and of 
> course I have
> > a
> > > file template.jsp which handles my layout.
> > > 
> > > I have horsed around with using the <tiles:useAttribute> tag with
> > the
> > > String value, but I can't seem to get that to work -- for the page
> > I
> > > want to display it on, it either displays the default 
> value for the
> > > page as I have it set in tiles-defs.xml, or it doesn't print
> > anything
> > > at all.  I suppose my question could/should be how and where would
> > I
> > > use this useAttribute tag, as it seems to be the solution to my
> > > problem.
> > 
> > useAttribute:
> >  Declare a Java variable, and an attribute in the specified scope,
> > using tile attribute value.
> > Java variable and attribute will have the name specified by 'id', or
> > the original name if not specified. 
> > 
> > So I believe for tiles def:
> > <definition name="paymentHistory" extends="mainLayout">
> >             <put name="title" value="Payment History"/>
> >             <putList name="centerList">
> >                     <add value="/searchBySsn.jsp"/>
> >                     <add value="/paymenthistory.jsp"/>
> >             </putList>
> > </definition>
> > 
> > In the jsp page:
> > <tiles:useAttribute id="javaVariable" name="title"/>
> > 
> > Will allow
> > 
> > <c:out value="${javaVariable}"/>
> > 
> > And yes, for this example I could have used <tile:getAsString
> > name="title"/>.  :)
> > 
> > Not sure what you mean by pass in a bean to your tiles setup though.
> > 
> > 
> > > 
> > > Thanks for your help, and I look forward to receiving your
> > responses.
> > > 
> > > 
> > > Best Regards,
> > > Andy
> > > 
> > > 
> > >
> > 
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > 
> > > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to