You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Josh Holtzman <jh...@americandatacompany.com> on 2004/07/15 18:42:57 UTC

Tiles, Validation and reuse of HTML Form

Hello All,

 

I've tried to search the list archives for previous threads on this topic,
but it appears the search feature is not working.

 

We are building a simple website that offers about a half dozen products for
sale. 

 

We have one dedicated page layout (the product page) that contains a photo
and description of the product.  On this page there is also a list of the
other 5 products.  By clicking on any one of these products, the page is
refreshed, and the new product information appears in the same layout.  Also
on this page is an HTML form that is used to add items to the shopping cart.
>From this form a user can choose any one of the 6 products from a select
menu, type a quantity, and submit the form.. To add items to the shopping
cart.  This form is the same on all the product pages.

 

For the sake of GUI reuse and maintenance, we have implemented the site with
tiles.  For this particular page we have created a base template named
"website.product" containing the header, footer, body layout, and html form
tiles.  For each of the 6 products we have extended this base template, and
added a tile with the product photo, description, and price.

 

In the struts config file we created an Action element for each of the 6
product pages.  For instance:

 

<action

path="/products/lazydazy"

       parameter="website.product.lazydazy"

       scope="request"

       type="org.apache.struts.actions.ForwardAction"

       validate="false">

</action>

 

And

 

<action

path="/products/sallysue"

       parameter="website.product.sallysue"

       scope="request"

       type="org.apache.struts.actions.ForwardAction"

       validate="false">

</action>

 

The following is our dilemma:

 

We are using the same tile containing the html form (which we declared in
the base template) for all these pages.  This doesn't present any problem,
except when validation fails.  When the validation fails, Struts must
determine which page to return and display the error message.  But our
problem is, the Action element requires we specify a single location.

 

<action

path="/addtocart"

      input="website.product.lazydazy"

      name="addToCartForm"

      scope="request"

      type="com.americandatacorp.struts.action.cart.Add"

      validate="true">

      <forward name="Success" path="website.default.cart.success"
redirect="true"/>

</action>

 

But if an item is added to the cart from the "website.product.sallysue"
template, and validation fails, the user is returned to the
"website.product.lazydazy" page with the error displayed.

 

Does anyone have any suggestions, other than having to create a seperate
"addtocart" action for every page?

 

Thank you for your assistance in advance.

 

Josh Holtzman

 

AMERICAN DATA COMPANY

Developing and Supporting your Online Applications

 

jholtzman@americandatacompany.com

Voice: (310) 470-1257

Fax:    (310) 362-8454

 

Sun Microsystems iForce Partner

 


Re: Tiles, Validation and reuse of HTML Form

Posted by Bryan Hunt <ad...@revoltingdigits.com>.
I do it with a seperate action for each use case. I find it tedious but 
have not found a better way.

--b

Josh Holtzman wrote:

>Hello All,
>
> 
>
>I've tried to search the list archives for previous threads on this topic,
>but it appears the search feature is not working.
>
> 
>
>We are building a simple website that offers about a half dozen products for
>sale. 
>
> 
>
>We have one dedicated page layout (the product page) that contains a photo
>and description of the product.  On this page there is also a list of the
>other 5 products.  By clicking on any one of these products, the page is
>refreshed, and the new product information appears in the same layout.  Also
>on this page is an HTML form that is used to add items to the shopping cart.
>>>From this form a user can choose any one of the 6 products from a select
>menu, type a quantity, and submit the form.. To add items to the shopping
>cart.  This form is the same on all the product pages.
>
> 
>
>For the sake of GUI reuse and maintenance, we have implemented the site with
>tiles.  For this particular page we have created a base template named
>"website.product" containing the header, footer, body layout, and html form
>tiles.  For each of the 6 products we have extended this base template, and
>added a tile with the product photo, description, and price.
>
> 
>
>In the struts config file we created an Action element for each of the 6
>product pages.  For instance:
>
> 
>
><action
>
>path="/products/lazydazy"
>
>       parameter="website.product.lazydazy"
>
>       scope="request"
>
>       type="org.apache.struts.actions.ForwardAction"
>
>       validate="false">
>
></action>
>
> 
>
>And
>
> 
>
><action
>
>path="/products/sallysue"
>
>       parameter="website.product.sallysue"
>
>       scope="request"
>
>       type="org.apache.struts.actions.ForwardAction"
>
>       validate="false">
>
></action>
>
> 
>
>The following is our dilemma:
>
> 
>
>We are using the same tile containing the html form (which we declared in
>the base template) for all these pages.  This doesn't present any problem,
>except when validation fails.  When the validation fails, Struts must
>determine which page to return and display the error message.  But our
>problem is, the Action element requires we specify a single location.
>
> 
>
><action
>
>path="/addtocart"
>
>      input="website.product.lazydazy"
>
>      name="addToCartForm"
>
>      scope="request"
>
>      type="com.americandatacorp.struts.action.cart.Add"
>
>      validate="true">
>
>      <forward name="Success" path="website.default.cart.success"
>redirect="true"/>
>
></action>
>
> 
>
>But if an item is added to the cart from the "website.product.sallysue"
>template, and validation fails, the user is returned to the
>"website.product.lazydazy" page with the error displayed.
>
> 
>
>Does anyone have any suggestions, other than having to create a seperate
>"addtocart" action for every page?
>
> 
>
>Thank you for your assistance in advance.
>
> 
>
>Josh Holtzman
>
> 
>
>AMERICAN DATA COMPANY
>
>Developing and Supporting your Online Applications
>
> 
>
>jholtzman@americandatacompany.com
>
>Voice: (310) 470-1257
>
>Fax:    (310) 362-8454
>
> 
>
>Sun Microsystems iForce Partner
>
> 
>
>
>  
>

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