struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fzli...@omnytex.com
Subject Re: Accessing my form from an included page
Date Wed, 22 Dec 2004 17:58:22 GMT
Yes, if the enjoyment I cause my wo-workers was worth money, I'd be a rich man indeed.  My
wife would have her new car and I'd have my 60-inch plasma TV.  Oh well, back to reality :(

The way I read the original post is that he wanted to have some common code in header.jsp
access the form associated with the main page content.  So...

If you have page1.jsp something like this:

<html><head></head><body>
<%@ include file="/inc/header.jsp" %>
Some content
<%@ include file="/inc/footer.jsp" %>
</body>

What that's going to get you is a servlet named something like page1_servlet.java which includes
the code from header.jsp and footer.jsp, with page1.jsp in the middle.  Nothing you don't
know of course. :)

The problem, as I understood it, is that page1.jsp may be using Page1ActionForm, while page2.jsp
might use Page2ActionForm.  The code in header.jsp however is going to be included in both,
and wants to use the form of the page it's included on, so how does it know which form name
to use, and what scope it's in?  I mean without a bunch of conditional logic of course.

So, if you either (a) always put the form in request and name it something like "form", then
the header.jsp code always knows to get that for any page it's included on, or (b) grab the
ActionMapping and use the information from that, or (c) in page1.jsp, just before the header.jsp
include, you can create a variable formName or something, that essentially hard-codes with
each page the form name (and probably scope) that the header.jsp code can use.

We might be saying the same thing in the end anyway :)

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Wed, December 22, 2004 12:42 pm, Dakota Jack said:
> On Wed, 22 Dec 2004 08:38:39 -0800 (PST), fzlists@omnytex.com
>>
>> (Caveat: I may be wrong about all this :) )
>>
>> Frank W. Zammetti
>> Founder and Chief Software Architect
>> Omnytex Technologies
>> http://www.omnytex.com
> 
> 
> Frank, you are a hoot.  ;-)  You must be great to have as a work partner.
> 
> I think, however, that the page which is identified by the eventual
> servlet is the page which is tied to the form.  Therefore, any
> included aspect of the page can use this information, if consistent.
> Otherwise the included tiles couldn't be dynamic.  I do this with
> forms all the time.  The code in the included file, which might be
> included in various jsp "pages" or servlets or html, depending on your
> perspective, just kicks into whatever the form is with the final
> "page", servlet or html.  If an included page might have this code
> only with certain "final" pages, servlets or html, just make the code
> conditional, e.g. test to see the existence of the form.  There are
> obviously various alternatives you can use on this theme.
> 
> Jack
> 
> ------------------------------
> 
> "You can lead a horse to water but you cannot make it float on its back."
> 
> ~Dakota Jack~
> 
> "You can't wake a person who is pretending to be asleep."
> 
> ~Native Proverb~
> 
> "Each man is good in His sight. It is not necessary for eagles to be
> crows."
> 
> ~Hunkesni (Sitting Bull), Hunkpapa Sioux~
> 
> -----------------------------------------------
> 
> "This message may contain confidential and/or privileged information.
> If you are not the addressee or authorized to receive this for the
> addressee, you must not use, copy, disclose, or take any action based
> on this message or any information herein. If you have received this
> message in error, please advise the sender immediately by reply e-mail
> and delete this message. Thank you for your cooperation."
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


Mime
View raw message