Hello,

I am not exactly a guru in Struts, but I have tried to answer the questions.
 Someone please make sure my answers are correct - and correct me if I am
wrong!

Thanks.




>>> struts-config.xml - [Q# 1: what exactly do we need to code in this file]

1) Form bean definitions:

  <!-- ========== Form Bean Definitions ===================================
-->
  <form-beans>

    <!-- Logon form bean -->
    <form-bean      name="logonForm"
                    type="org.xxx.forms.LogonForm"/>

  </form-beans>

2)  Action Mappings:

  <!-- ========== Action Mapping Definitions ==============================
-->
  <action-mappings>

  <!-- Process a user logon -->
    <action    path="/logon"
               type="org.xxx.actions.LogonAction"
               name="logonForm"
              scope="request"
              input="/logon.jsp">
        <forward name="success"         path="/showProfile.do"/>
    </action>

etc etc

3)    <!-- ========== Global Forward Definitions
  <global-forwards>

That's all I have added to my struts-config.xml.




>>> Q# 2: are there any other methods that might be performed in the form
beans

Well, in addition to the methods you talked about, I have a 'reset' method
that resets values of all fields on the form.



>>> Q# 3: what exactly is the ActionErrors object?
It is a collection of 'ActionError' instances.  Typically in the 'validate'
method of the Form, one can check values of the user entered fields and
add 'ActionError' instance if invalid values are found.

For example in LogonForm we may have;

    public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if ((username == null))
            errors.add("username", new ActionError("error.username.required"));

etc etc


>>> Q# 4: I didnt understand what exactly is done by these (Action )classes,
since the example I referred to showed some real complex code.. I got lost
here ..


Typically, the Action class would either directly (or indirectly via a Business
Delegate) call a Session Facade that implements the Use Case.  The Facade
would return a Value Object.  One can validate values in the VO and if invalid
values are found can add ActionError to ActionErrors collection.

For example;

        if (userVO != null && !userVO.getPassword().equals(password)) {
            errors.add(ActionErrors.GLOBAL_ERROR,
                new ActionError("error.password.mismatch"));
        }

OR If no errors are found;

        // Forward control to the specified success URI
        return (mapping.findForward("success"));

(I am sure there are various other ways of doing this, but I have seen/heard
people talk about this architecture.)


>>> Q# 5: would i have to learn the syntax of this library before starting
.. I am not much conversant with custom taglibs in JSP.

My reply would be - yes!  Most definitely you must familiarize yourself
with JSP Taglib.  It shouldn't take you more than a day to learn taglibs.
 The documentation that comes with Weblogic is one way to learn about them.

Struts heavily relies on the Taglibs, so you must know the syntax.



>>> - web.xml [Q# 6: do i have to make any changes in this ?

Yes, you need to make (at the minimum) the following changes;

1)

  <!-- Action Servlet Configuration -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
etc etc

2)

  <!-- Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>


3)

  <!-- Application Tag Library Descriptor -->
  <taglib>
    <taglib-uri>/WEB-INF/app.tld</taglib-uri>
    <taglib-location>/WEB-INF/app.tld</taglib-location>
  </taglib>

& all other taglibs you are using.




>>>** 1 ** what are all the components in the Struts framework (apart from
the ones mentioned above .. anything missing ??)

Basically, you got most of them.  One way to find out is to download the
Struts source code.  That might help. Don't worry about the 'Digester' package,
because it will soon go away from Struts.  It is now part of Jakarta Commons.


>>> ** 2 ** in which of these components do we need to make changes (actual
coding) and how complex is it ?

Typically to implement a Use Case you will need to create a JSP, a Form
class & an Action Class - well as far as the presentation layer and Struts
are concerned.


>>> ** 3 ** apart from the configuration and deploying issues how complex
is Struts ?
I guess, just like any other product, Struts is complex until one figures
out how to use it.  I am learning new tricks in Struts every day.  It's
complex but fun!

HTH!






>-- Original Message --
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>Date: Mon, 29 Apr 2002 12:53:25 -0700 (PDT)
>From: reshma deshpande <[EMAIL PROTECTED]>
>Subject: few questions
>To: [EMAIL PROTECTED]
>
>
>
>Hi All,
>
>Its me again .. remember the "some help... " mail this friday!  I studied
>120 pages of JSP (from Web Development using Java Server Pages, Manning)
>since i had that book (i would finish it soon), and also read a couple
of
>tutorials on Struts. Heres what I understand .. plz correct me if I am
wrong,
>and also plz ans my questions:
>
>Following are the main components that build the Struts framework:
>
>- struts-config.xml : where we specify the action mappings (local or global
>forwards that are defined by the Action class). [Q# 1: what exactly do
we
>need to code in this file]
>
>- ActionForm Beans: these are specific to each form and mainly have getters
>and setters, along with validation methods handled by ActionErrors. [Q#
2:
>are there any other methods that might be performed in the form beans]
[Q#
>3: what exactly is the ActionErrors object?]
>
>- ApplicationResources.properties file: defined in the web.xml file, and
>is used for displaying error messages etc..
>
>- Action classes: the main method here is the perform( ). [Q# 4: I didnt
>understand what exactly is done by these classes, since the example I referred
>to showed some real complex code.. I got lost here ..]
>
>- JSP pages: these would have code using the Struts tag library to access
>html elements such as forms etc [Q# 5: would i have to learn the syntax
of
>this library before starting .. I am not much conversant with custom taglibs
>in JSP]
>
>- Action Servlet: the main controller servlet
>
>- web.xml [Q# 6: do i have to make any changes in this ?]
>
>As you might have noticed .. I kind of have the gist of these pieces, but
>cant put them up together.... to summarize all my Questions, I would put
>it this way..
>
>** 1 ** what are all the components in the Struts framework (apart from
the
>ones mentioned above .. anything missing ??)
>
>** 2 ** in which of these components do we need to make changes (actual
coding)
>and how complex is it ? I mean, if you are separating out Java content
from
>the presentation layer, and restricting it to EJBs and stuff, how much
of
>actual Java code would be written in a Struts application (especially in
>the Action classes)
>
>** 3 ** apart from the configuration and deploying issues how complex is
>Struts ?
>
>Could anybody plz ans my questions .. especially Q# 2 and Q# 4.
>
>Thankyou for your time .. and plz note that I am very new to the Struts
environment
>.. I mite (rather must) have asked all silly questions .. :-)
>
>~ Reshma
>
>
>
>
>
>
>
>---------------------------------
>Do You Yahoo!?
>Yahoo! Tax Center - online filing with TurboTax

Ajay Chitre

Diligent Team, Inc.
(Where Diligent People Work as a Team)

http://www.DiligentTeam.com


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to