You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Sann, Stephan" <SS...@bhw.de> on 2002/06/13 11:07:24 UTC

A customized Struts

Hello list,

I'm new with Struts and this list so please bear with me.

After I read a lot of tutos, howtos, manuals and mailing-list-posts
I've got two questions left (for now):


1.) How can I add a "static" parameter to an <html:link>-Tag?

I read this stuff about dynamically defined query parameters with
beans and such, but that's not what I want. I just want to ad a
"?customer=FirstCustomer" to my GET-Request

This works fine:
<html:link forward="entry">weiter</html:link> 

This
<html:link forward="entry?customer=FirstCustomer">weiter</html:link>
ends in
"Cannot retrive ActionForward named entry?customer=FirstCustomer"



2.) How can I realize a "customized Forward"?

Assumed there are two customers - "FirstCustomer" and "SecondCustomer".
These cusomers have totaly different JSPs but they share the same
Web-Application.

The directory is
/myWebapp
    /FirstCustomer
        overview.jsp
        *.jsp
    /SecondCustomer
        overview.jsp
        *.jsp
    /WEB-INF

Now in the application I would like to forward the request to the
accordingly "overview.jsp".

My idea is to create a action-mapping like this 

    <!-- entry -->
    <action    path="/entry"
               type="de.bhw.struts.servlet.EntryAction">
      <forward name="success_FirstCustomer"  path="/FirstCustomer/overview.jsp"/>
      <forward name="success_SecondCustomer" path="/SecondCustomer/overview.jsp"/>
    </action>

and then do a

    return(mapping.findForward("success_" + customerGotFromSession));

in the perform()-method of the EntryAction-class.

This should work, but so I have to create a "<forward>" for every
customer (maybe I have more than two).

Isn't there a better way like:

struts-config.xml: <forward   name="success"    path="/overview.jsp"/>

EntryAction:       return(customerGotFromSession + mapping.findForward("success"));

(I know this wouldn't work - I'm not stupid ;-)  - just to show what I mean).



Thanx a lot for your answers!

Best regards
Stephan

--
Stephan Sann
BHW Bausparkasse AG
Anwendungsentwicklung - Abteilung AEW CR -
Lubahnstraße 2, 31789 Hameln

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: A customized Struts

Posted by Joe Germuska <Jo...@Germuska.com>.
At 11:07 AM +0200 2002/06/13, Sann, Stephan wrote:
>Hello list,
>
>I'm new with Struts and this list so please bear with me.
>
>After I read a lot of tutos, howtos, manuals and mailing-list-posts
>I've got two questions left (for now):
>
>
>1.) How can I add a "static" parameter to an <html:link>-Tag?
>
>I read this stuff about dynamically defined query parameters with
>beans and such, but that's not what I want. I just want to ad a
>"?customer=FirstCustomer" to my GET-Request
>
>This works fine:
><html:link forward="entry">weiter</html:link>
>
>This
><html:link forward="entry?customer=FirstCustomer">weiter</html:link>
>ends in
>"Cannot retrive ActionForward named entry?customer=FirstCustomer"

You have to use the same mechanism as with "dynamically defined query 
parameters"  It only requires one <bean:define> tag.

<bean:define id="customerValue" value="FirstCustomer" />
<html:link forward="entry" paramId="customer" 
paramName="customerValue">weiter</html:link>

>2.) How can I realize a "customized Forward"?
>
>Assumed there are two customers - "FirstCustomer" and "SecondCustomer".
>These cusomers have totaly different JSPs but they share the same
>Web-Application.

I may not totally understand your requirements here.  I'd suggest 
that you try to isolate the presentational differences between the 
customers into data rather than requiring multiple JSPs -- for 
example, pull in a customer-specific CSS style sheet, and look up 
images and such based on the customer instead of hard-coding multiple 
JSPs with distinct images.  If you can handle the logic with the same 
action, it's likely that you can externalize the presentation issues.

If you really don't think you can externalize the presentation 
issues, I'd probably opt for installing two distinct instances of the 
web application, one per customer.  That leaves you flexibility for 
more variation between customers if you need it.

Hope this helps,
	Joe

-- 
--
* Joe Germuska    { joe@germuska.com }
"It's pitiful, sometimes, if they've got it bad. Their eyes get 
glazed, they go white, their hands tremble.... As I watch them I 
often feel that a dope peddler is a gentleman compared with the man 
who sells records."
	--Sam Goody, 1956
tune in posse radio: <http://www.live365.com/stations/289268>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>