You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pedro Salgado <sa...@04web.com> on 2003/12/16 15:07:12 UTC

Re: Naming conventions for Struts actions, Tiles definitions and JSPs

  First of all the templates go to Templates directory and tile to a Tiles
directory.

  I use two "kinds" of tiles definitions: those that are used to help build
pages, those that are used see pages.

  For the build ones, I use ".definition.def".
  For example, a one form definition would be ".form.def", for a two form
definition would be ".double.form".

  The name of the major Tiles definition is the same as the JSP template.
  The name of Tiles definition properties are the same as the JSP files (for
the initial values).

   <definition
     name=".form.def"
     path="/WEB-INF/classes/pkg/templates/form.jsp"
   >
      <put name="head"       value="/WEB-INF/classes/pkg/tiles/head.jsp"/>
      <put name="header"     value="/WEB-INF/classes/pkg/tiles/header.jsp"/>
      <put name="menu"    value="/WEB-INF/classes/pkg/tiles/menu.jsp"/>
      <put name="errors"     value="/WEB-INF/classes/pkg/tiles/errors.jsp"/>
      <put name="form"       value="/WEB-INF/classes/pkg/tiles/form.jsp"/>
      <put name="footer"     value="/WEB-INF/classes/pkg/tiles/footer.jsp"/>
   </definition>


  For the presentation, I use the name of the extended build definition and
then a name of the page.
  For example, a search form that extends ".form.def" would be
".form.search" which uses a search.jsp file.


   <definition
     name=".form.search"
     extends=".form.def"
   >
      <put name="form" value="/WEB-INF/classes/pkg/tiles/forms/search.jsp"/>
   </definition>

  The first name of the extended Tiles definition is the same as the  major
definition.
  The last name of the extended Tiles definition is the same as the JSP
file.
  The directory where the JSP file is located, is the plural of the major
definition name.
  If the project has a lot of roles I could also use the role to place the
JSP file.

   Admin role
     value="/WEB-INF/classes/pkg/tiles/forms/admin/search.jsp"/>
  User role
     value="/WEB-INF/classes/pkg/tiles/forms/user/search.jsp"/>
  Common to more than one role
     value="/WEB-INF/classes/pkg/tiles/forms/common/search.jsp"/>
  or
     value="/WEB-INF/classes/pkg/tiles/forms/search.jsp"/>



  When the number of properties to be set are more than 1, I use the place
where they will be presented to name the JSP files (t = top, b = bottom, m =
middle, l = left, r = right, c = center...):

  Example:

  - major definition (build)

   <definition
     name=".doubleform.def"
     path="/WEB-INF/classes/pkg/templates/doubleform.jsp"
   >
      <put name="head"       value="/WEB-INF/classes/pkg/tiles/head.jsp"/>
      <put name="menu"    value="/WEB-INF/classes/pkg/tiles/menu.jsp"/>
      <put name="errors"     value="/WEB-INF/classes/pkg/tiles/errors.jsp"/>
      <put name="topForm"
value="/WEB-INF/classes/pkg/tiles/topForm.jsp"/>
      <put name="bottomForm"
value="/WEB-INF/classes/pkg/tiles/bottomForm.jsp"/>
     <put name="footer"     value="/WEB-INF/classes/pkg/tiles/footer.jsp"/>
   </definition>

  - minor definition (see something)

   <definition
     name=".doubleform.something"
     extends=".doubleform.def"
   >
      <put name="topForm"
value="/WEB-INF/classes/pkg/tiles/doubleforms/something_t.jsp"/>
      <put name="bottomForm"
value="/WEB-INF/classes/com/lusovencor/tiles/doubleforms/something_b.jsp"/>
   </definition>

  For the action to tiles name translation:

  Action = /ActionName -> .some-major-definition.actionname
  Example:
          /ViewUser -> .form.viewuser
          /User?operation=view -> .form.user (I only use a dispatch action
when getting an input from 1 form and having more than one action
possibility that ends up on the input form (view user and edit user, for
example))

  Speaking of organizing a large project... how do you represent, in a UML
diagram, Tiles definitions, forms, actions, in a way that you understand the
flow of the application? Do you use the name/colors to differ actions
components from form components? How can you represent a Tiles definition (I
donĀ¹t mean the tiles configuration file)?

Pedro Salgado



On 16/12/2003 13:23, "Philip Mark Donaghy" <go...@yahoo.com> wrote:

> Hello world,
> 
> Naming conventions help organize large projects and
> facilitates the establishment of relationships between
> objects and entities configured in an XML file. My
> current project is using the following convention.
> 
> The forward success path is similar to the action
> path.
> 
> action path="/foo/bar/accesModifierRacine"
> forward path="foo.bar.accesModifierRacine"
> 
> The Tiles definition uses the name
> foo.bar.accesModifierRacine so that when I see the url
> /foo/bar/accesModifierRacine I know which Tiles
> definition to see.
> 
> In addition to that the body of the tiles definition
> is often the same.
> 
> put name="body"
> value="foo/bar/accesModifierRacine.jsp"
> 
> If anyone would like to contribute their naming
> conventions I am sure that the community would
> appreciate it.
> 
> Phil
> 
> =====
> Java Web Application Architect
> mapimage.com - Java and GIS
> struts1.1:tomcat4.1.27:linuxRH8
> 
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing.
> http://photos.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


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