You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike La Budde <mi...@irista.com> on 2000/10/02 20:45:07 UTC

struts-config.xml problem/question (please help!)

I''m in the process of converting from a home-grown Model-2 architecture to 
the struts framework. In my ActionServlet config file I used to just 
specify the name of the PATH and the FORWARD without having to fully 
qualify either relative to the context's root directory.

For example, here's the directory structure (starting at 
../webapps/mycontext/) :

- pages
|
- - - - - - /inventory
|
- - - - - - /orders


And here's a snippet from my new config file:

    <!-- Inventory Actions -->
    <action path="/pages/inventory/InventoryActionSearchPage"
            type="com.xyz.inventory.InventoryActionSearchPage">
        <forward 
name="success"             path="/pages/inventory/inventorySearch.jsp"/>
    </action>

    <action path="/pages/inventory/InventoryActionListPage"
            type="com.xyz.inventory.InventoryActionListPage">
        <forward 
name="success"             path="/pages/inventory/inventoryList.jsp"/>
    </action>

    <action path="InventoryActionViewPage"
            type="com.xyz.inventory.InventoryActionViewPage">
        <forward 
name="success"             path="/pages/inventory/inventoryRow.jsp"/>
    </action>

My question is: Why do I have to specify full path locations to everything? 
How are others doing this? Of course, keeping everything in the context's 
root would eliminate this problem (while creating a new one)....

TIA,

Mike


Re: How come the user's Locale is stored in the Session?

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Mike La Budde wrote:

> I noticed that the ActionServlet stores the user's Locale in the session.
> Presumably then all other code would do a
> session.getAttribute(Action.LOCALE_KEY) rather than a request.getLocale().
> Why is it done this way? (Performance?)
>

The original design intent was to deal with all three of the following
scenarios:

* The user has not (or does not know how to) configure
  their browser to send the right HTTP headers to select
  the locale that the user wants.

* The servlet container makes the wrong assumption about
  which Locale is desired.

* The user wants to be able to switch languages (and therefore
  Locales) in the middle of the application.

The third scenario is the most important of the three.

>
> Getting the Locale out of the request allows us developers to switch our
> language preference on the fly and view the same page in a different
> language. Storing it in the session forces us to log out before we will see
> it in a different language....
>

A patch was recently checked in to set the Locale in the session (based on the
value returned by the servlet container) if it is not there already.  This is
not in the 0.5 milestone release, but will be in 1.0.

If your application wants to support language switching on the fly, all you
have to do is replace the Locale object that is already there in an Action.
This is really simple to do:

    Locale newLocale = ... calculate new Locale value ...
    session.setAttribute(Action.LOCALE_KEY, newLocale);

You don't need to log out -- this will take effect the next time that you
forward to a JSP page that uses the locale-sensitive tags.

>
> Thanks,
>
> Mike

Craig


--
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat



How come the user's Locale is stored in the Session?

Posted by Mike La Budde <mi...@irista.com>.
I noticed that the ActionServlet stores the user's Locale in the session. 
Presumably then all other code would do a 
session.getAttribute(Action.LOCALE_KEY) rather than a request.getLocale(). 
Why is it done this way? (Performance?)

Getting the Locale out of the request allows us developers to switch our 
language preference on the fly and view the same page in a different 
language. Storing it in the session forces us to log out before we will see 
it in a different language....

Thanks,

Mike


Re: HTML editors and custom tags

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Mats Josefsson wrote:

> Robert Leland wrote:
> >
> > What I have in mind is telling the editor that
> > for example <struts:form ..../> is really like HTML <form .../>
> > Is this what XLS or XHTML are ???
>
> I know you can teach Dreamweaver 3 (Ultradev?) to handle your custom
> tag libraries. I have seen it done for other tag libraries. You just
> drag-n-drop your tags from a palette and use a property sheet to fill
> in the parameters.
>
> It would be really cool if someone could make a Dreamweaver extension
> to make it handle struts tags. We have thought of doing it ourselves
> at some point, but right now we don't have the resources. It would be
> a really good "selling point" for struts if we had this support.

People who have the chance to attend ApacheCon Europe are going to get
to
see something pretty interesting in this regard ...

Craig

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat

Re: HTML editors and custom tags

Posted by Mats Josefsson <ma...@rsv.se>.
Robert Leland wrote:
> 
> What I have in mind is telling the editor that
> for example <struts:form ..../> is really like HTML <form .../>
> Is this what XLS or XHTML are ???

I know you can teach Dreamweaver 3 (Ultradev?) to handle your custom
tag libraries. I have seen it done for other tag libraries. You just
drag-n-drop your tags from a palette and use a property sheet to fill
in the parameters. 

It would be really cool if someone could make a Dreamweaver extension
to make it handle struts tags. We have thought of doing it ourselves
at some point, but right now we don't have the resources. It would be
a really good "selling point" for struts if we had this support.

HTML editors and custom tags

Posted by Robert Leland <Ro...@freetocreate.org>.
This isn't exactly a struts specific question so forgive me...

Does anyone know of an html/xml editor that will let me
give it a create a custom definition file of the struts tags
so I can visually edit the struts custom tags.

What I have in mind is telling the editor that
for example <struts:form ..../> is really like HTML <form .../>
Is this what XLS or XHTML are ???

Thank in advance for any pointers !!!

Rob




Re: struts-config.xml problem/question (please help!)

Posted by Mike La Budde <mi...@irista.com>.
Craig:

Thanks for your response. Sorry I wasn't clear in my original message. The 
context is called "mycontext" and the pages subdirectory contains several 
subdirectories (inventory, orders, etc.). Further, in my action mapping 
config file the third example was missing the "/pages/inventory/" prior to 
"InventoryActionViewPage".

So, am I going to have to specify full context-relative paths for all 
action paths as well as forward paths? How will this affect links specified 
within pages (be they to an Action or to a straight html page)? Obviously, 
from the discussion you & Colin had yesterday (geez, I can't take one day 
off without missing something!) this also will have a large impact on 
security constraints.

Thanks in advance for your insight,

Mike

PS: I'm sure that I used to have relative paths working just fine - I'll 
have to review the code prior to implementing struts.


At 10/03/2000 03:32 PM -0700, Craig R. McClanahan wrote:
>Mike La Budde wrote:
>
> > I''m in the process of converting from a home-grown Model-2 architecture to
> > the struts framework. In my ActionServlet config file I used to just
> > specify the name of the PATH and the FORWARD without having to fully
> > qualify either relative to the context's root directory.
> >
> > For example, here's the directory structure (starting at
> > ../webapps/mycontext/) :
> >
> > - pages
> > |
> > - - - - - - /inventory
> > |
> > - - - - - - /orders
> >
> > And here's a snippet from my new config file:
> >
> >     <!-- Inventory Actions -->
> >     <action path="/pages/inventory/InventoryActionSearchPage"
> >             type="com.xyz.inventory.InventoryActionSearchPage">
> >         <forward
> > name="success"             path="/pages/inventory/inventorySearch.jsp"/>
> >     </action>
> >
> >     <action path="/pages/inventory/InventoryActionListPage"
> >             type="com.xyz.inventory.InventoryActionListPage">
> >         <forward
> > name="success"             path="/pages/inventory/inventoryList.jsp"/>
> >     </action>
> >
> >     <action path="InventoryActionViewPage"
> >             type="com.xyz.inventory.InventoryActionViewPage">
> >         <forward
> > name="success"             path="/pages/inventory/inventoryRow.jsp"/>
> >     </action>
> >
> > My question is: Why do I have to specify full path locations to everything?
> > How are others doing this? Of course, keeping everything in the context's
> > root would eliminate this problem (while creating a new one)....
> >
>
>If "/pages" is the context path for your web application, you do *not*
>want to
>include it in the paths inside action.xml.  The paths here are all
>context-relative (in other words, they conform to the same requirements
>as the
>argument to ServletContext.getRequestDispatcher()).
>
>So, for example, the last example in your new file should read:
>
>     <action path="InventoryActionViewPage"
>       type="com.xyz.inventory.InventoryActionViewPage">
>         <forward name="success" path="/inventory/inventoryRow.jsp"/>
>     </action>
>
> >
> > TIA,
> >
> > Mike
>
>Craig
>
>====================
>See you at ApacheCon Europe <http://www.apachecon.com>!
>Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
>Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
>                                     Applications to Tomcat


Re: struts-config.xml problem/question (please help!)

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Mike La Budde wrote:

> I''m in the process of converting from a home-grown Model-2 architecture to
> the struts framework. In my ActionServlet config file I used to just
> specify the name of the PATH and the FORWARD without having to fully
> qualify either relative to the context's root directory.
>
> For example, here's the directory structure (starting at
> ../webapps/mycontext/) :
>
> - pages
> |
> - - - - - - /inventory
> |
> - - - - - - /orders
>
> And here's a snippet from my new config file:
>
>     <!-- Inventory Actions -->
>     <action path="/pages/inventory/InventoryActionSearchPage"
>             type="com.xyz.inventory.InventoryActionSearchPage">
>         <forward
> name="success"             path="/pages/inventory/inventorySearch.jsp"/>
>     </action>
>
>     <action path="/pages/inventory/InventoryActionListPage"
>             type="com.xyz.inventory.InventoryActionListPage">
>         <forward
> name="success"             path="/pages/inventory/inventoryList.jsp"/>
>     </action>
>
>     <action path="InventoryActionViewPage"
>             type="com.xyz.inventory.InventoryActionViewPage">
>         <forward
> name="success"             path="/pages/inventory/inventoryRow.jsp"/>
>     </action>
>
> My question is: Why do I have to specify full path locations to everything?
> How are others doing this? Of course, keeping everything in the context's
> root would eliminate this problem (while creating a new one)....
>

If "/pages" is the context path for your web application, you do *not*
want to
include it in the paths inside action.xml.  The paths here are all
context-relative (in other words, they conform to the same requirements
as the
argument to ServletContext.getRequestDispatcher()).

So, for example, the last example in your new file should read:

    <action path="InventoryActionViewPage"
      type="com.xyz.inventory.InventoryActionViewPage">
        <forward name="success" path="/inventory/inventoryRow.jsp"/>
    </action>

>
> TIA,
>
> Mike

Craig

====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat