> -----Original Message-----
> From: Charles McClain [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 10:46 AM
> To: 'Struts Users Mailing List'
> Subject: RE: Re-using JSP pages -- Follow-up
> 
> 
> Chris:
> 
> As I plowed my way through converting my app to Struts, I had 
> to skim a
> lot of the capabilities and make (hopefully, educated) guesses as to
> which ones spend learning time on and subsequently use.
> 
> In my early skimming, I looked at both Struts Tiles and Struts
> Templates, which seemed at first glance to overlap quite a 
> bit.  I chose
> to use Struts Templates, because it looked easier and the example was
> easier to crib from, and figured that after I had mastered everything
> else (Ha!) I could revisit this decision.
> 
> As I started to apply the solution you gave me, I realized 
> that my JSPs
> were becoming way too complicated -- littered with logic:equal tags --
> and that a better way to approach it might be a slightly more 
> elaborate
> template-based solution that constructs the page from more and smaller
> components.  That would give me several benefits:
> 
> -- My mappings could still refer to the same JSP;
> -- The template could assemble the page components based on 
> the value of
> the "dispatch" request parameter, eliminating the need for the JSP to
> know what formBean it had been passed (or rather, it would 
> automatically
> know, because it would be an operation-specific page component);
> -- The main component containing all of the html:text tags 
> for the form
> properties would remain unchanged, since the html:text tag doesn't
> require a "name" attribute.

Another big benefit is that you'll avert (or at least greatly delay)
disaster when you suddenly discover that your JSP pages are too big for the
Java compiler to handle, and you're then forced to split the pages up. In my
experience, this always happens right at the most critical time in your
project, when you have no time to spare for fighting the compiler. ;-)

> 
> So, my follow-up question, if you have time:  Do you know enough about
> Struts Tiles and Struts Templates to recommend one versus the 
> other?  If
> I'm going to put in the time to break these JSPs into smaller 
> components
> and use a Struts facility to assemble them, I'd sure like to know that
> I'm using the "right" Struts facility and not spinning wheels.

I would recommend that you go with Tiles. It's being actively developed and
supported, whereas the original template taglib is more or less just being
kept around for backwards compatibility. (Bugs will still be fixed in it,
though, if any are found.)

One thing to note is that everything that the original template taglib does
can be done in Tiles, using the same tag and attribute names, so switching
over is extremely easy.

--
Martin Cooper


> 
> Don't get me wrong -- your solution to my original problem is very
> useful, and it's nice to know that I have the option to do it that way
> if I choose.
> 
> -----Original Message-----
> From: Bartley, Chris P [PCS] [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, September 20, 2002 1:06 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Re-using JSP pages -- Follow-up
> 
> 
> Hey, great!  Glad it worked.
> 
> I guess i should clarify, however, that what i sent is *a* 
> solution and
> not necessarily the only or best solution. :)
> 
> I haven't made the transition to Struts 1.1 yet, so there may 
> be a more
> elegant way of solving this problem.  Maybe one of the 1.1 gurus can
> chime in here.
> 
> Regarding the choice between a large number of simple JSP vs a small
> number of complex ones, i'd recommend the former.  If you 
> haven't looked
> into Tiles yet to help you manage your presentation, you 
> might give it a
> whirl--very cool stuff.
> 
> chris
> 
> > -----Original Message-----
> > From: Charles McClain [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, September 20, 2002 11:57 AM
> > To: 'Struts Users Mailing List'
> > Subject: RE: Re-using JSP pages -- Follow-up
> > 
> > 
> > Thanks, Chris:
> > 
> > I tested your proposed solution very quickly -- just 
> printing out the 
> > retrieved formName on my JSP -- and it does work.
> > 
> > I'm surprised, though, that it isn't easier than that; it
> > seems that the
> > formName should be available via the bean:struts tag, or 
> some similar
> > tag.
> > 
> > Now I have to integrate the solution into my app.  Like many
> > newcomers,
> > I'm wavering back and forth between having a large number of 
> > very simple
> > JSPs, or a small number of more complex JSPs.  It's nice to 
> know that,
> > using your solution, I at least have the option.
> > 
> > -----Original Message-----
> > From: Bartley, Chris P [PCS] [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, September 20, 2002 12:19 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: Re-using JSP pages -- Follow-up
> > 
> > 
> > Something like this might work:
> > 
> > <bean:define id="actionMappingForThisScreen" 
> > name="org.apache.struts.action.mapping.instance"
> > type="org.apache.struts.action.ActionMapping"/>
> > <bean:define id="formName" name="actionMappingForThisScreen" 
> > property="name" type="java.lang.String" /> <bean:define 
> id="formBean" 
> > name="<%= formName %>" type="org.apache.struts.action.ActionForm"/>
> > 
> > I haven't tested it, but i *think* it'll work since i *think* the 
> > current action mapping is stored in the request under the key 
> > "org.apache.struts.action.mapping.instance".  The above code should 
> > help you get the form bean's name and a reference to the 
> bean itself.
> > 
> > chris
> > 
> > > -----Original Message-----
> > > From: Charles McClain [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, September 20, 2002 11:13 AM
> > > To: Struts User Mailing List
> > > Subject: Re-using JSP pages -- Follow-up
> > > 
> > > 
> > > All:
> > > 
> > > This is a follow-up to my earlier post on the same topic.
> > Although I
> > > received a response, I think it wasn't the response I
> > needed because I
> > 
> > > didn't ask my question correctly.
> > > 
> > > Boiled down -- and ignoring all the background of why I
> > need it, which
> > 
> > > may have confused people -- I want:
> > > 
> > > --  To pass different form-beans to the same JSP;
> > > --  To have the JSP figure out the name of the form-bean it 
> > > received, so it can use that form-bean name in various tags.
> > > 
> > > I'm sure the form-bean name must be easily available to the
> > JSP, but I
> > 
> > > have searched the Struts User Guide and the taglib
> > documentation, and
> > > I can't figure out how .  Can anyone help?
> > > 
> > > Thanks again in advance.  You guys were very responsive
> > before; I just
> > 
> > > needed to phrase my question more simply.
> > > 
> > > Charles McClain
> > > Phone:  603.659.2046
> > > email:    [EMAIL PROTECTED]
> > > 
> > > 
> > > --
> > > To unsubscribe, e-mail:   
> > > <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail: 
> > > <mailto:[EMAIL PROTECTED]>
> > > 
> > 
> > --
> > To unsubscribe, e-mail: 
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: 
> > <mailto:[EMAIL PROTECTED]>
> > 
> > 
> > 
> > --
> > To unsubscribe, e-mail:   
> > <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>



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

Reply via email to