You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Todd Grigsby <st...@tgrigsby.com> on 2003/05/10 09:31:40 UTC

DynaActionForm, JasperException, ServletException, null

In a nutshell, I'm trying to use a DynaActionForm.  I've been over the 
configuration several times and can't see the problem.  When I hit the page, the 
  "header" tile processes ok, but the form in the "body" tile of the page 
returns the following error:

[ServletException in:/Tiles/Edit/MCI.jsp] null'

Note that the single quote at the end is not a typo.

I can put just about anything else in there, but when I attempt to reference 
properties on the DynaActionForm using either bean:write or html:text, I get 
that error.

Any suggestions would be appreciated.  The following are exerpts from my 
configuration.

-------------------------------------------------------
In struts-config.xml:

<form-bean name="dfMCI" type="org.apache.struts.action.DynaActionForm">
   <form-property name="op"        type="java.lang.String" initial=""/>
   <form-property name="dataset"   type="java.lang.String" initial=""/>
   <form-property name="recid"     type="java.lang.String" initial=""/>
   <form-property name="ID"        type="java.lang.String" initial=""/>
   <form-property name="firstname" type="java.lang.String" initial=""/>
   <form-property name="lastname"  type="java.lang.String" initial=""/>
</form-bean>

-------------------------------------------------------
In tiles-defs.xml I have the following:

<definition name=".basicLayout" path="/Tiles/Layouts/BasicLayout.jsp">
   <put name="header"    value="/Tiles/Basic/Header.jsp" />
   <put name="title"     value=""                        />
   <put name="subtitle"  value=""                        />
   <put name="body"      value="/Tiles/Basic/Body.jsp"   />
   <put name="footer"    value="/Tiles/Basic/Footer.jsp" />
</definition>

<definition name="basicDef" extends=".basicLayout">
   <!-- this just implements the basic layout for testing purposes. -->
   <!-- refer to WEB-INF/struts-config.xml for the action Basic.    -->
   <put name="title"     value="Basic Layout Title"      />
   <put name="subtitle"  value="Basic Layout Subtitle"   />
</definition>

<definition name=".editWindowLayout" extends=".basicLayout">
</definition>

<definition name="edtMCIDef" extends=".editWindowLayout">
   <put name="title"     value="MCI"                     />
   <put name="subtitle"  value="Master Client Index"     />
   <put name="body"      value="/Tiles/Edit/MCI.jsp"     />
</definition>

-------------------------------------------------------
The "body" page, in it's entirety:

<%@ page language="java" %><%@ taglib uri="/WEB-INF/struts-html.tld" 
prefix="html" %><%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %><%@ 
taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<p>

<html:form
   action="/EditAction"
   type="org.apache.struts.action.DynaActionForm"
   name="dfMCI">

<html:hidden property="ID" />

<table border="0">
   <tr>
     <td width="70" align="right">Lastname:</td>
     <td width="80%"><html:text property="lastname" maxlength="30" /></td>
     <td width="160">&nbsp;</td>
   </tr>
   <tr>
     <td width="70" align="right">Firstname:</td>
     <td width="80%"><html:text property="firstname" maxlength="30" /></td>
     <td width="160">&nbsp;</td>
   </tr>
   <tr>
     <td />
     <td />
     <td width="160">
       <table width="154" border="0">
         <tr>
           <td width="100%"><html:image src="images/btnSave.jpg" border="0" 
property="org.apache.struts.taglib.html.SUBMIT" />&nbsp;<html:image 
src="images/btnCancel.jpg" border="0" 
property="org.apache.struts.taglib.html.CANCEL" onclick="bCancel=true;" /></td>
         </tr>
       </table>
     </td>
   </tr>
</table>

</html:form>

</p>

---------------------------------------------------------

Thanks in advance,

Todd



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


Re: DynaActionForm example

Posted by Todd Grigsby <st...@tgrigsby.com>.
Brandon,

Thanks so much for responding!  It's a little demoralizing when the bottle cast 
into the ocean is seen later on the beach unopened...

I've already done what you describe as far as configuring the DynaActionForm. 
I've also changed the JSP to print out what Jasper would find the in the request 
context when the page is drawn using the following code:

-----------------------------------------------------
<%@ page language="java" %><%@ taglib uri="/WEB-INF/struts-html.tld" 
prefix="html" %><%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %><%@ 
taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<p>

<html:form
   action="/EditAction"
   type="org.apache.struts.action.DynaActionForm"
   name="dfMCI">
<h3>Request scope attributes</h3>
<table>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.struts.action.DynaActionForm" %>
<%
   Enumeration names = request.getAttributeNames();
   String name = null;
   Object value = null;
   while ( names.hasMoreElements() ) {
     name = (String) names.nextElement();
     value = request.getAttribute( name );
     out.println( "<tr><td>" + name + "</td><td>" );
     if ( value == null )
       out.println( "(null)" );
     else if ( value instanceof String )
       out.println( (String) value );
     else
       out.println( "Class = [" + value.getClass().getName() + "]" );
     out.println( "</td></tr>" );
   }
%>
</table>

<h3>DynaActionForm attributes</h3>
<table>
<%
   DynaActionForm dynaform = (DynaActionForm) request.getAttribute( 
"org.apache.struts.taglib.html.BEAN" );
   Map map = dynaform.getMap();
   Set keyset = map.keySet();
   Iterator keys = keyset.iterator();
   String key = "";
   value = "";
   while ( keys.hasNext() ) {
     key = (String)keys.next();
     value = (String) dynaform.get( key );
     out.println( "<tr><td align=\"left\" valign=\"top\">" + key + "</td><td 
align=\"left\" valign=\"top\">" + value + "</td></tr>" );
   }
%>
</table>

</html:form>
-------------------------------------------------------------

The result showed various attributes described at the request level, but the 
DynaActionForm had *NO* properties defined.  This was strange, to say the least. 
  The form name listed in the JSP code above is defined in struts-config.xml 
with form properties.  What would prevent Jasper for obtaining the correct form 
definition and putting the defined properties in the DynaActionForm?

Thanks in advance,

Todd



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


RE: DynaActionForm example

Posted by Brandon Goodin <ma...@phase.ws>.

Brandon Goodin
Phase Web and Multimedia
PO Box 85
Whitefish MT 59937
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws


-----Original Message-----
From: Todd Grigsby [mailto:strutsuser@tgrigsby.com]
Sent: Saturday, May 10, 2003 4:30 PM
To: Struts Users Mailing List
Subject: Re: DynaActionForm example


To add a little more fuel to the fire, in the action preceding my JSP, I've
tried to prepopulate the form (although I've skipped that recently to try to
figure out what's going on), and in that action I put some code to print out
the
properties in the DynaActionForm prior to forwarding to the JSP that will
use
the DynaActionForm.  That code sees properties in the DynaActionForm's map
that
the JSP doesn't see.  In fact, it would seem that the JSP receives a
DynaActionForm with no properties at all.  The definition, as I mentioned
before, for the form bean is:

<form-bean name="dfMCI" type="org.apache.struts.action.DynaActionForm">
  <form-property name="op"        type="java.lang.String" initial=""/>
  <form-property name="dataset"   type="java.lang.String" initial=""/>
  <form-property name="recid"     type="java.lang.String" initial=""/>
  <form-property name="ID"        type="java.lang.String" initial=""/>
  <form-property name="firstname" type="java.lang.String" initial=""/>
  <form-property name="lastname"  type="java.lang.String" initial=""/>
</form-bean>

And the opening form tag in the JSP is:

<html:form
   action="/EditAction"
   type="org.apache.struts.action.DynaActionForm"
   name="dfMCI">

Any thoughts?

T


---------------------------------------------------------------------
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


Re: DynaActionForm example

Posted by Todd Grigsby <st...@tgrigsby.com>.
Ok, I just got it... hang on and I'll write back in a minute...

T


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


RE: DynaActionForm example

Posted by Brandon Goodin <ma...@phase.ws>.
I was up doing a little work. But, I finished about a half hour ago. I just
wanted to help you out. That's the beauty of a community. I'm glad it all
worked. :-)

Brandon Goodin

-----Original Message-----
From: Todd Grigsby [mailto:strutsuser@tgrigsby.com]
Sent: Sunday, May 11, 2003 12:33 AM
To: Struts Users Mailing List
Subject: Re: DynaActionForm example



Dude, you da man!  Yeah, that brings up a nice tidy little form.  Ok, that's
the
example I needed.  Let me flick at the code I had before and see what the
problem is.  If I had to guess, I'd say it's the spartan <form> tag you use.
In
mine, it's:

<html:form
   action="/testdynaformaction"
   type="org.apache.struts.action.DynaActionForm"
   name="dynaformbean">

Ok, lessee, I'll change it to:

<html:form action="/testdynaformaction">

Reloading....  Oh crap, it worked.  Well ain't that a ....  Now why doesn't
it
just tell you, "Hey, you've redefined the type in the action definition?"  I
just wasted two days on this because I was doing *too much* rather than
doing
too little.  And why does that make *any* difference at all?  Honestly,
that's
thoroughly obfuscated.

Brandon, I don't know why you're up this late on the computer, but you rock.
Thanks mucho!

Todd



---------------------------------------------------------------------
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


Re: DynaActionForm example

Posted by Todd Grigsby <st...@tgrigsby.com>.
Dude, you da man!  Yeah, that brings up a nice tidy little form.  Ok, that's the 
example I needed.  Let me flick at the code I had before and see what the 
problem is.  If I had to guess, I'd say it's the spartan <form> tag you use.  In 
mine, it's:

<html:form
   action="/testdynaformaction"
   type="org.apache.struts.action.DynaActionForm"
   name="dynaformbean">

Ok, lessee, I'll change it to:

<html:form action="/testdynaformaction">

Reloading....  Oh crap, it worked.  Well ain't that a ....  Now why doesn't it 
just tell you, "Hey, you've redefined the type in the action definition?"  I 
just wasted two days on this because I was doing *too much* rather than doing 
too little.  And why does that make *any* difference at all?  Honestly, that's 
thoroughly obfuscated.

Brandon, I don't know why you're up this late on the computer, but you rock. 
Thanks mucho!

Todd



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


Re: DynaActionForm example

Posted by Todd Grigsby <st...@tgrigsby.com>.
Ah, ok.  You caught me just as I was about to start copying jars.  I'll be right 
back...

T


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


RE: DynaActionForm example

Posted by Brandon Goodin <ma...@phase.ws>.
oops. Sorry you can delete that line. It is NOT neccessary.

Brandon Goodin

-----Original Message-----
From: Todd Grigsby [mailto:strutsuser@tgrigsby.com]
Sent: Sunday, May 11, 2003 12:16 AM
To: Struts Users Mailing List
Subject: Re: DynaActionForm example




Ok, first off, I don't have c.tld.  I suspect that I'd have to grab the JSTL
jars off Jakarta first, right?

T


---------------------------------------------------------------------
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


Re: DynaActionForm example

Posted by Todd Grigsby <st...@tgrigsby.com>.

Ok, first off, I don't have c.tld.  I suspect that I'd have to grab the JSTL 
jars off Jakarta first, right?

T


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


RE: DynaActionForm example

Posted by Brandon Goodin <ma...@phase.ws>.
You can just make the jsp page like so...

-- start --
<%@taglib prefix="html" uri="/WEB-INF/struts-html.tld"%>
<html:form action="/testAction">
<html:text property="firstName"/>: First Name<br>
<html:text property="lastName"/>: Last Name<br>
<html:text property="age"/>: Age<br><br>
<html:submit/>
</html:form>
-- stop --

Brandon Goodin 

-----Original Message-----
From: Brandon Goodin [mailto:mail@phase.ws]
Sent: Sunday, May 11, 2003 12:27 AM
To: Struts Users Mailing List
Subject: RE: DynaActionForm example


Don'w worry about jstl. That was a fupa on my part leaving that code in
there.

-----Original Message-----
From: Todd Grigsby [mailto:strutsuser@tgrigsby.com]
Sent: Sunday, May 11, 2003 12:22 AM
To: Struts Users Mailing List
Subject: Re: DynaActionForm example



Ok, to get jumping, how much of the JSTL download should I install at one
shot?
  There are several jars and several TLDs.  Recommendation?  (And I did a
search
and didn't find a c.tld anywhere in my Tomcat/Struts installation.)

T



---------------------------------------------------------------------
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



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


RE: DynaActionForm example

Posted by Brandon Goodin <ma...@phase.ws>.
Don'w worry about jstl. That was a fupa on my part leaving that code in
there.

-----Original Message-----
From: Todd Grigsby [mailto:strutsuser@tgrigsby.com]
Sent: Sunday, May 11, 2003 12:22 AM
To: Struts Users Mailing List
Subject: Re: DynaActionForm example



Ok, to get jumping, how much of the JSTL download should I install at one
shot?
  There are several jars and several TLDs.  Recommendation?  (And I did a
search
and didn't find a c.tld anywhere in my Tomcat/Struts installation.)

T



---------------------------------------------------------------------
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


Re: DynaActionForm example

Posted by Todd Grigsby <st...@tgrigsby.com>.
Ok, to get jumping, how much of the JSTL download should I install at one shot? 
  There are several jars and several TLDs.  Recommendation?  (And I did a search 
and didn't find a c.tld anywhere in my Tomcat/Struts installation.)

T



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


RE: DynaActionForm example

Posted by Brandon Goodin <ma...@phase.ws>.
Sorry to make you jump through any more hoops than you should have too.

I am running:
Tomcat 4.1.18
JDK 1.4.1
Struts 1.1rc1

I set up the following example just now and it worked perfectly. It should
take you about 5 minutes to set up and test. I'll wait up a while to see
your response.

Try it and let me know if it works:

1) Insert this form-bean definition into your struts-config:

-- start --
<form-bean name="testForm"
  type="org.apache.struts.action.DynaActionForm">
  <form-property name="firstName"
    type="java.lang.String"
    initial="Brandon"/>
  <form-property name="lastName"
    type="java.lang.String"
    initial="Goodin"/>
  <form-property name="age"
    type="java.lang.Integer"
    initial="29"/>
</form-bean>
-- stop --


2) Insert this action config into your struts-config:

-- start --
<action path="/testAction"
  type="TestAction"
  name="testForm"
  scope="request"
  validate="false">
  <forward name="auth"
    path="/testjsp.jsp"
    redirect="false"/>
</action>
-- stop --

3) Create this class named TestAction and place it in the root
of your WEB-INF/classes directory:

-- start --
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;

public class TestAction extends Action {

	public ActionForward execute(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception {

		DynaActionForm dynaForm = (DynaActionForm) form;

		System.out.println(dynaForm.get("firstName"));
		System.out.println(dynaForm.get("lastName"));
		System.out.println(dynaForm.get("age"));

		return mapping.findForward("auth");
	}

}
-- stop --

4) create this jsp page name it testjsp.jsp and place it in the root
directory of your webapp:

-- start --
<%@taglib prefix="html" uri="/WEB-INF/struts-html.tld"%>
<%@taglib prefix="c" uri="/WEB-INF/c.tld"%>
<html:form action="/testAction">
<html:text property="firstName"/>: First Name<br>
<html:text property="lastName"/>: Last Name<br>
<html:text property="age"/>: Age<br><br>
<html:submit/>
</html:form>
-- stop --

5) Assuming you are using .do notation go to
http://www.yoursite.com/testAction.do

Brandon Goodin

-----Original Message-----
From: Todd Grigsby [mailto:strutsuser@tgrigsby.com]
Sent: Saturday, May 10, 2003 11:11 PM
To: Struts Users Mailing List
Subject: Re: DynaActionForm example



Here's the form I was testing with.  There is no action preceding this form.
Following that is the struts-config.xml, and following that is the
EditAction I
was testing with.

------------------------------

<%@ page language="java" %><%@ taglib uri="/WEB-INF/struts-html.tld"
prefix="html" %><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"
%><%@
taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<head>
   <link rel="stylesheet" type="text/css" href="ds.css">
</head>
<body bgcolor="#9ECCD7">

<!-- Report errors (this will probably need to be moved at some point -->
<p>
<html:errors />
</p>

<!-- Present the company glyph and the table name -->
<p class="title">
   <span id="upperleftlogo" style="position:absolute; left:10px; top:10px;">
     <img src="images/dsboxlightbluesm.jpg" border="0" width="41"
height="32" />
   </span>
   <span id="upperlefttablename" style="position:absolute; left:55px;
top:20px;">
   </span>
</p>
<p>&nbsp;</p>
<hr /><p>

<html:form
   action="/EditAction"
   type="org.apache.struts.action.DynaActionForm"
   name="dfMCI">

<h3>Request scope attributes</h3>
<table>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.struts.action.DynaActionForm" %>
<%
   Enumeration names = request.getAttributeNames();
   String name = null;
   Object value = null;
   while ( names.hasMoreElements() ) {
     name = (String) names.nextElement();
     value = request.getAttribute( name );
     out.println( "<tr><td>" + name + "</td><td>" );
     if ( value == null )
       out.println( "(null)" );
     else if ( value instanceof String )
       out.println( (String) value );
     else
       out.println( "Class = [" + value.getClass().getName() + "]" );
     out.println( "</td></tr>" );

   }
%>
</table>

<h3>DynaActionForm attributes</h3>
<table>
<%
   DynaActionForm dynaform = (DynaActionForm) request.getAttribute(
"org.apache.struts.taglib.html.BEAN" );
   Map map = dynaform.getMap();
   Set keyset = map.keySet();
   Iterator keys = keyset.iterator();
   String key = "";
   value = "";
   while ( keys.hasNext() ) {
     key = (String)keys.next();
     value = (String) dynaform.get( key );
     out.println( "<tr><td align=\"left\" valign=\"top\">" + key + "</td><td
align=\"left\" valign=\"top\">" + value + "</td></tr>" );
   }
%>
</table>

</html:form>

</p>
<hr />
<table border="0">
   <tr>
     <td width="*">
       <p class="footer">
       &nbsp;
       </p>
     </td>
     <td width="120">
       <p class="footer">
         <h3>test footer</h3>
       </p>
     </td>
   </tr>
</table>

</body>

------------------------------

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
           "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
           "http://localhost/DS/dtd/struts-config_1_1.dtd">

<struts-config>
<!-- ==================================== Data Source Configuration -->
  <data-sources>
    <data-source>
      <set-property
         property="autoCommit"
         value="false"/>
      <set-property
         property="driverClass"
         value="sun.jdbc.odbc.JdbcOdbcDriver"/>
      <set-property
         property="maxCount"
         value="10"/>
      <set-property
         property="minCount"
         value="2"/>
      <set-property
         property="url"
         value="jdbc:odbc:DSSQLServer"/>
    </data-source>
  </data-sources>
<!-- ======================================== Form Bean Definitions -->
  <form-beans>
    <form-bean name="loginForm" type="DS.forms.LoginForm" />
    <form-bean name="dfMCI" type="org.apache.struts.action.DynaActionForm">
      <form-property name="op"        type="java.lang.String" initial=""/>
      <form-property name="dataset"   type="java.lang.String" initial=""/>
      <form-property name="recid"     type="java.lang.String" initial=""/>
      <form-property name="ID"        type="java.lang.String" initial=""/>
      <form-property name="firstname" type="java.lang.String" initial=""/>
      <form-property name="lastname"  type="java.lang.String" initial=""/>
    </form-bean>
  </form-beans>
<!-- ================================= Global Exception Definitions -->
     <global-exceptions>
         <!-- sample exception handler
         <exception
             key="expired.password"
             type="app.ExpiredPasswordException"
             path="/changePassword.jsp"/>
         end sample -->
     </global-exceptions>
<!-- =================================== Global Forward Definitions -->
     <global-forwards>
         <!-- Default forward to "Welcome" action -->
         <!-- Demonstrates using index.jsp to forward -->
         <forward
             name="welcome"
             path="/Welcome.do"/>
     </global-forwards>
<!-- =================================== Action Mapping Definitions -->
     <action-mappings>
       <!-- ************************************************** -->
       <!-- Tiles test -->
       <action path="/Basic"
         type="DS.actions.DSRedirect"
         name="redirect"
         scope="request"
         validate="false">
         <forward name="toPage" path="basicDef" />
       </action>
       <!--
            path      = URL, as in http://localhost/DS/Basic.do
            type      = class that gets called with the request
            forward   = in this case, the Tiles definition that
                        does the actual processing of the
                        request.
            toPage is the only forward supported by DSRedirect,
            and it returns it regardless.
            basicDef can be found in WEB-INF/tiles-defs.xml.
       -->

       <action path="/Grid"
         type="DS.actions.DSRedirect"
         name="redirect"
         scope="request"
         validate="false">
         <forward name="toPage" path="gridDef" />
       </action>
       <!--
            Same as action Basic, but with the following changes:

            path      = URL, as in http://localhost/DS/Grid.do
            forward   = to gridDef

            gridDef can be found in WEB-INF/tiles-defs.xml.
       -->

       <!-- ************************************************** -->

       <!-- This action has no form - takes params from request -->
       <action path="/GridDetails"
         type="DS.actions.GridDetailPullAction">
         <forward name="login"    path="/Login.jsp" />
         <forward name="list"     path="/Tiles/Grid/GridDetailsList.jsp" />
         <forward name="genericfailure"  path="/genericfailure.jsp" />
         <forward name="sqlerror" path="/sqlerror.jsp" />
       </action>

       <action path="/LoginAction"
         type="DS.actions.LoginAction"
         name="loginForm"
         input="/LoginForm.jsp">
         <forward name="success"  path="/MainMenu.jsp" />
         <forward name="failure"  path="/Login.jsp" />
         <forward name="sqlerror" path="/sqlerror.jsp" />
       </action>

       <action path="/MenuAction"
         type="DS.actions.MenuAction">
         <forward name="login"    path="/Login.jsp" />
         <forward name="grid"     path="gridDef" />
         <forward name="genericfailure" path="/genericfailure.jsp" />
         <forward name="sqlerror" path="/sqlerror.jsp" />
       </action>

       <action path="/GridAction"
         type="DS.actions.GridAction"
         name="editForm">
         <forward name="login" path="/Login.jsp" />
         <forward name="genericfailure"  path="/genericfailure.jsp" />
         <forward name="sqlerror"        path="/sqlerror.jsp" />
         <forward name="MCI"             path="edtMCIDef" />
       </action>

       <action path="/EditAction"
         type="DS.actions.EditAction"
         name="dfMCI">
         <forward name="login"           path="/Login.jsp" />
         <forward name="genericfailure"  path="/genericfailure.jsp" />
         <forward name="sqlerror"        path="/sqlerror.jsp" />
         <forward name="grid"            path="gridDef" />
       </action>

     </action-mappings>
<!-- ===================================== Controller Configuration -->
     <controller
        processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<!-- ================================ Message Resources Definitions -->
     <message-resources parameter="DS.ApplicationResources" />
<!-- ======================================= Plug Ins Configuration -->
<!-- ========== Tiles plugin ===================  -->
   <!-- comment following if struts1.0.x -->
   <plug-in className="org.apache.struts.tiles.TilesPlugin" >
     <set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
     <set-property property="definitions-debug" value="2" />
     <set-property property="definitions-parser-details" value="0" />
     <set-property property="definitions-parser-validate" value="true" />
   </plug-in>

   <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
     <set-property
         property="pathnames"
         value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
   </plug-in>
</struts-config>

-----------------------------------------------------

package DS.actions;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class EditAction extends Action {

   public ActionForward execute(
                          ActionMapping mapping,
                          ActionForm form,
                          HttpServletRequest request,
                          HttpServletResponse response )
   throws Exception, IOException, ServletException {

     // gutted for test purposes.  Just forward back to grid
     return ( mapping.findForward( "grid" ) );
   }
}


---------------------------------------------------------------------
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


Re: DynaActionForm example

Posted by Todd Grigsby <st...@tgrigsby.com>.
First off, I want to start by thanking you again for spending time on this.

jdk: 1.4.1
struts: 1.1-rc1
container: tomcat 5, dated 4/23/2003

And if it helps, I've stripped *everything* out to isolate the problem.  This is 
what I have now:

struts-config.xml:
-------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
           "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
           "http://localhost/DS/dtd/struts-config_1_1.dtd">
<struts-config>
<!-- ==================================== Data Source Configuration -->
  <data-sources>
    <data-source>
      <set-property
         property="autoCommit"
         value="false"/>
      <set-property
         property="driverClass"
         value="sun.jdbc.odbc.JdbcOdbcDriver"/>
      <set-property
         property="maxCount"
         value="10"/>
      <set-property
         property="minCount"
         value="2"/>
      <set-property
         property="url"
         value="jdbc:odbc:DSSQLServer"/>
    </data-source>
  </data-sources>

<!-- ======================================== Form Bean Definitions -->
  <form-beans>
   <form-bean name="dynaformbean" type="org.apache.struts.action.DynaActionForm">
     <form-property name="op"        type="java.lang.String" initial="" />
     <form-property name="dataset"   type="java.lang.String" initial="" />
     <form-property name="recid"     type="java.lang.String" initial=""/>
     <form-property name="ID"        type="java.lang.String" initial=""/>
     <form-property name="firstname" type="java.lang.String" initial=""/>
     <form-property name="lastname"  type="java.lang.String" initial=""/>
   </form-bean>
  </form-beans>
<!-- ================================= Global Exception Definitions -->
     <global-exceptions>
         <!-- sample exception handler
         <exception
             key="expired.password"
             type="app.ExpiredPasswordException"
             path="/changePassword.jsp"/>
         end sample -->
     </global-exceptions>
<!-- =================================== Global Forward Definitions -->
     <global-forwards>
         <!-- Default forward to "Welcome" action -->
         <!-- Demonstrates using index.jsp to forward -->
         <forward
             name="welcome"
             path="/Welcome.do"/>
     </global-forwards>
<!-- =================================== Action Mapping Definitions -->
   <action-mappings>
     <action path="/testdynaformaction"
       type="test.actions.testaction"
       name="dynaformbean">
       <forward name="success"         path="/dynatest.jsp" />
       <forward name="genericfailure"  path="/dynatest.jsp" />
     </action>
   </action-mappings>
<!-- ===================================== Controller Configuration -->
   <controller
      processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<!-- ================================ Message Resources Definitions -->
   <message-resources parameter="DS.ApplicationResources" />
<!-- ======================================= Plug Ins Configuration -->
<!-- ========== Tiles plugin ===================  -->
   <plug-in className="org.apache.struts.tiles.TilesPlugin" >
     <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
     <set-property property="definitions-debug" value="2" />
     <set-property property="definitions-parser-details" value="0" />
     <set-property property="definitions-parser-validate" value="true" />
   </plug-in>
   <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
     <set-property
         property="pathnames"
         value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
   </plug-in>
</struts-config>
-----------------------------------------------------------------------


dynatest.jsp:
-----------------------------------------------------------------------
<%@ page language="java" %><%@ taglib uri="/WEB-INF/struts-html.tld" 
prefix="html" %><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %><%@ 
taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<head>
   <link rel="stylesheet" type="text/css" href="ds.css">
</head>
<body bgcolor="#9ECCD7">

<!-- Report errors (this will probably need to be moved at some point -->
<p>
<html:errors />
</p>

<!-- Present the company glyph and the table name -->
<p class="title">
   <span id="upperleftlogo" style="position:absolute; left:10px; top:10px;">
     <img src="images/dsboxlightbluesm.jpg" border="0" width="41" height="32" />
   </span>
   <span id="upperlefttablename" style="position:absolute; left:55px; top:20px;">
   </span>
</p>
<p>&nbsp;</p>
<hr /><p>

<html:form
   action="/testdynaformaction"
   type="org.apache.struts.action.DynaActionForm"
   name="dynaformbean">

<html:text property="ID" />

<h3>Request scope attributes</h3>
<table>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.struts.action.DynaActionForm" %>
<%
   Enumeration names = request.getAttributeNames();
   String name = null;
   Object value = null;
   while ( names.hasMoreElements() ) {
     name = (String) names.nextElement();
     value = request.getAttribute( name );
     out.println( "<tr><td>" + name + "</td><td>" );
     if ( value == null )
       out.println( "(null)" );
     else if ( value instanceof String )
       out.println( (String) value );
     else
       out.println( "Class = [" + value.getClass().getName() + "]" );
     out.println( "</td></tr>" );

   }
%>
</table>

<h3>DynaActionForm attributes</h3>
<table>
<%
   DynaActionForm dynaform = (DynaActionForm) request.getAttribute( 
"org.apache.struts.taglib.html.BEAN" );
   Map map = dynaform.getMap();
   Set keyset = map.keySet();
   Iterator keys = keyset.iterator();
   String key = "";
   value = "";
   while ( keys.hasNext() ) {
     key = (String)keys.next();
     value = (String) dynaform.get( key );
     out.println( "<tr><td align=\"left\" valign=\"top\">" + key + "</td><td 
align=\"left\" valign=\"top\">" + value + "</td></tr>" );
   }
%>
</table>

</html:form>

</p>
<hr />
<table border="0">
   <tr>
     <td width="*">
       <p class="footer">
       &nbsp;
       </p>
     </td>
     <td width="120">
       <p class="footer">
         <h3>test footer</h3>
       </p>
     </td>
   </tr>
</table>

</body>
----------------------------------------------------------------------


And testaction.java:
----------------------------------------------------------------------
package test.actions;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class testaction extends Action {

   public ActionForward execute(
                          ActionMapping mapping,
                          ActionForm form,
                          HttpServletRequest request,
                          HttpServletResponse response )
   throws Exception, IOException, ServletException {

     // gutted for test purposes.  Just forward back to grid
     return ( mapping.findForward( "success" ) );
   }
}
----------------------------------------------------------------------



Hope this helps!

Todd


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


RE: DynaActionForm example

Posted by Brandon Goodin <ma...@phase.ws>.
What is your container, jdk and struts version?

Brandon Goodin

-----Original Message-----
From: Todd Grigsby [mailto:strutsuser@tgrigsby.com]
Sent: Saturday, May 10, 2003 11:11 PM
To: Struts Users Mailing List
Subject: Re: DynaActionForm example



Here's the form I was testing with.  There is no action preceding this form.
Following that is the struts-config.xml, and following that is the
EditAction I
was testing with.

------------------------------

<%@ page language="java" %><%@ taglib uri="/WEB-INF/struts-html.tld"
prefix="html" %><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"
%><%@
taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<head>
   <link rel="stylesheet" type="text/css" href="ds.css">
</head>
<body bgcolor="#9ECCD7">

<!-- Report errors (this will probably need to be moved at some point -->
<p>
<html:errors />
</p>

<!-- Present the company glyph and the table name -->
<p class="title">
   <span id="upperleftlogo" style="position:absolute; left:10px; top:10px;">
     <img src="images/dsboxlightbluesm.jpg" border="0" width="41"
height="32" />
   </span>
   <span id="upperlefttablename" style="position:absolute; left:55px;
top:20px;">
   </span>
</p>
<p>&nbsp;</p>
<hr /><p>

<html:form
   action="/EditAction"
   type="org.apache.struts.action.DynaActionForm"
   name="dfMCI">

<h3>Request scope attributes</h3>
<table>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.struts.action.DynaActionForm" %>
<%
   Enumeration names = request.getAttributeNames();
   String name = null;
   Object value = null;
   while ( names.hasMoreElements() ) {
     name = (String) names.nextElement();
     value = request.getAttribute( name );
     out.println( "<tr><td>" + name + "</td><td>" );
     if ( value == null )
       out.println( "(null)" );
     else if ( value instanceof String )
       out.println( (String) value );
     else
       out.println( "Class = [" + value.getClass().getName() + "]" );
     out.println( "</td></tr>" );

   }
%>
</table>

<h3>DynaActionForm attributes</h3>
<table>
<%
   DynaActionForm dynaform = (DynaActionForm) request.getAttribute(
"org.apache.struts.taglib.html.BEAN" );
   Map map = dynaform.getMap();
   Set keyset = map.keySet();
   Iterator keys = keyset.iterator();
   String key = "";
   value = "";
   while ( keys.hasNext() ) {
     key = (String)keys.next();
     value = (String) dynaform.get( key );
     out.println( "<tr><td align=\"left\" valign=\"top\">" + key + "</td><td
align=\"left\" valign=\"top\">" + value + "</td></tr>" );
   }
%>
</table>

</html:form>

</p>
<hr />
<table border="0">
   <tr>
     <td width="*">
       <p class="footer">
       &nbsp;
       </p>
     </td>
     <td width="120">
       <p class="footer">
         <h3>test footer</h3>
       </p>
     </td>
   </tr>
</table>

</body>

------------------------------

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
           "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
           "http://localhost/DS/dtd/struts-config_1_1.dtd">

<struts-config>
<!-- ==================================== Data Source Configuration -->
  <data-sources>
    <data-source>
      <set-property
         property="autoCommit"
         value="false"/>
      <set-property
         property="driverClass"
         value="sun.jdbc.odbc.JdbcOdbcDriver"/>
      <set-property
         property="maxCount"
         value="10"/>
      <set-property
         property="minCount"
         value="2"/>
      <set-property
         property="url"
         value="jdbc:odbc:DSSQLServer"/>
    </data-source>
  </data-sources>
<!-- ======================================== Form Bean Definitions -->
  <form-beans>
    <form-bean name="loginForm" type="DS.forms.LoginForm" />
    <form-bean name="dfMCI" type="org.apache.struts.action.DynaActionForm">
      <form-property name="op"        type="java.lang.String" initial=""/>
      <form-property name="dataset"   type="java.lang.String" initial=""/>
      <form-property name="recid"     type="java.lang.String" initial=""/>
      <form-property name="ID"        type="java.lang.String" initial=""/>
      <form-property name="firstname" type="java.lang.String" initial=""/>
      <form-property name="lastname"  type="java.lang.String" initial=""/>
    </form-bean>
  </form-beans>
<!-- ================================= Global Exception Definitions -->
     <global-exceptions>
         <!-- sample exception handler
         <exception
             key="expired.password"
             type="app.ExpiredPasswordException"
             path="/changePassword.jsp"/>
         end sample -->
     </global-exceptions>
<!-- =================================== Global Forward Definitions -->
     <global-forwards>
         <!-- Default forward to "Welcome" action -->
         <!-- Demonstrates using index.jsp to forward -->
         <forward
             name="welcome"
             path="/Welcome.do"/>
     </global-forwards>
<!-- =================================== Action Mapping Definitions -->
     <action-mappings>
       <!-- ************************************************** -->
       <!-- Tiles test -->
       <action path="/Basic"
         type="DS.actions.DSRedirect"
         name="redirect"
         scope="request"
         validate="false">
         <forward name="toPage" path="basicDef" />
       </action>
       <!--
            path      = URL, as in http://localhost/DS/Basic.do
            type      = class that gets called with the request
            forward   = in this case, the Tiles definition that
                        does the actual processing of the
                        request.
            toPage is the only forward supported by DSRedirect,
            and it returns it regardless.
            basicDef can be found in WEB-INF/tiles-defs.xml.
       -->

       <action path="/Grid"
         type="DS.actions.DSRedirect"
         name="redirect"
         scope="request"
         validate="false">
         <forward name="toPage" path="gridDef" />
       </action>
       <!--
            Same as action Basic, but with the following changes:

            path      = URL, as in http://localhost/DS/Grid.do
            forward   = to gridDef

            gridDef can be found in WEB-INF/tiles-defs.xml.
       -->

       <!-- ************************************************** -->

       <!-- This action has no form - takes params from request -->
       <action path="/GridDetails"
         type="DS.actions.GridDetailPullAction">
         <forward name="login"    path="/Login.jsp" />
         <forward name="list"     path="/Tiles/Grid/GridDetailsList.jsp" />
         <forward name="genericfailure"  path="/genericfailure.jsp" />
         <forward name="sqlerror" path="/sqlerror.jsp" />
       </action>

       <action path="/LoginAction"
         type="DS.actions.LoginAction"
         name="loginForm"
         input="/LoginForm.jsp">
         <forward name="success"  path="/MainMenu.jsp" />
         <forward name="failure"  path="/Login.jsp" />
         <forward name="sqlerror" path="/sqlerror.jsp" />
       </action>

       <action path="/MenuAction"
         type="DS.actions.MenuAction">
         <forward name="login"    path="/Login.jsp" />
         <forward name="grid"     path="gridDef" />
         <forward name="genericfailure" path="/genericfailure.jsp" />
         <forward name="sqlerror" path="/sqlerror.jsp" />
       </action>

       <action path="/GridAction"
         type="DS.actions.GridAction"
         name="editForm">
         <forward name="login" path="/Login.jsp" />
         <forward name="genericfailure"  path="/genericfailure.jsp" />
         <forward name="sqlerror"        path="/sqlerror.jsp" />
         <forward name="MCI"             path="edtMCIDef" />
       </action>

       <action path="/EditAction"
         type="DS.actions.EditAction"
         name="dfMCI">
         <forward name="login"           path="/Login.jsp" />
         <forward name="genericfailure"  path="/genericfailure.jsp" />
         <forward name="sqlerror"        path="/sqlerror.jsp" />
         <forward name="grid"            path="gridDef" />
       </action>

     </action-mappings>
<!-- ===================================== Controller Configuration -->
     <controller
        processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<!-- ================================ Message Resources Definitions -->
     <message-resources parameter="DS.ApplicationResources" />
<!-- ======================================= Plug Ins Configuration -->
<!-- ========== Tiles plugin ===================  -->
   <!-- comment following if struts1.0.x -->
   <plug-in className="org.apache.struts.tiles.TilesPlugin" >
     <set-property property="definitions-config"
value="/WEB-INF/tiles-defs.xml" />
     <set-property property="definitions-debug" value="2" />
     <set-property property="definitions-parser-details" value="0" />
     <set-property property="definitions-parser-validate" value="true" />
   </plug-in>

   <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
     <set-property
         property="pathnames"
         value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
   </plug-in>
</struts-config>

-----------------------------------------------------

package DS.actions;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class EditAction extends Action {

   public ActionForward execute(
                          ActionMapping mapping,
                          ActionForm form,
                          HttpServletRequest request,
                          HttpServletResponse response )
   throws Exception, IOException, ServletException {

     // gutted for test purposes.  Just forward back to grid
     return ( mapping.findForward( "grid" ) );
   }
}


---------------------------------------------------------------------
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


Re: DynaActionForm example

Posted by Todd Grigsby <st...@tgrigsby.com>.
Here's the form I was testing with.  There is no action preceding this form. 
Following that is the struts-config.xml, and following that is the EditAction I 
was testing with.

------------------------------

<%@ page language="java" %><%@ taglib uri="/WEB-INF/struts-html.tld" 
prefix="html" %><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %><%@ 
taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<head>
   <link rel="stylesheet" type="text/css" href="ds.css">
</head>
<body bgcolor="#9ECCD7">

<!-- Report errors (this will probably need to be moved at some point -->
<p>
<html:errors />
</p>

<!-- Present the company glyph and the table name -->
<p class="title">
   <span id="upperleftlogo" style="position:absolute; left:10px; top:10px;">
     <img src="images/dsboxlightbluesm.jpg" border="0" width="41" height="32" />
   </span>
   <span id="upperlefttablename" style="position:absolute; left:55px; top:20px;">
   </span>
</p>
<p>&nbsp;</p>
<hr /><p>

<html:form
   action="/EditAction"
   type="org.apache.struts.action.DynaActionForm"
   name="dfMCI">

<h3>Request scope attributes</h3>
<table>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.struts.action.DynaActionForm" %>
<%
   Enumeration names = request.getAttributeNames();
   String name = null;
   Object value = null;
   while ( names.hasMoreElements() ) {
     name = (String) names.nextElement();
     value = request.getAttribute( name );
     out.println( "<tr><td>" + name + "</td><td>" );
     if ( value == null )
       out.println( "(null)" );
     else if ( value instanceof String )
       out.println( (String) value );
     else
       out.println( "Class = [" + value.getClass().getName() + "]" );
     out.println( "</td></tr>" );

   }
%>
</table>

<h3>DynaActionForm attributes</h3>
<table>
<%
   DynaActionForm dynaform = (DynaActionForm) request.getAttribute( 
"org.apache.struts.taglib.html.BEAN" );
   Map map = dynaform.getMap();
   Set keyset = map.keySet();
   Iterator keys = keyset.iterator();
   String key = "";
   value = "";
   while ( keys.hasNext() ) {
     key = (String)keys.next();
     value = (String) dynaform.get( key );
     out.println( "<tr><td align=\"left\" valign=\"top\">" + key + "</td><td 
align=\"left\" valign=\"top\">" + value + "</td></tr>" );
   }
%>
</table>

</html:form>

</p>
<hr />
<table border="0">
   <tr>
     <td width="*">
       <p class="footer">
       &nbsp;
       </p>
     </td>
     <td width="120">
       <p class="footer">
         <h3>test footer</h3>
       </p>
     </td>
   </tr>
</table>

</body>

------------------------------

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
           "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
           "http://localhost/DS/dtd/struts-config_1_1.dtd">

<struts-config>
<!-- ==================================== Data Source Configuration -->
  <data-sources>
    <data-source>
      <set-property
         property="autoCommit"
         value="false"/>
      <set-property
         property="driverClass"
         value="sun.jdbc.odbc.JdbcOdbcDriver"/>
      <set-property
         property="maxCount"
         value="10"/>
      <set-property
         property="minCount"
         value="2"/>
      <set-property
         property="url"
         value="jdbc:odbc:DSSQLServer"/>
    </data-source>
  </data-sources>
<!-- ======================================== Form Bean Definitions -->
  <form-beans>
    <form-bean name="loginForm" type="DS.forms.LoginForm" />
    <form-bean name="dfMCI" type="org.apache.struts.action.DynaActionForm">
      <form-property name="op"        type="java.lang.String" initial=""/>
      <form-property name="dataset"   type="java.lang.String" initial=""/>
      <form-property name="recid"     type="java.lang.String" initial=""/>
      <form-property name="ID"        type="java.lang.String" initial=""/>
      <form-property name="firstname" type="java.lang.String" initial=""/>
      <form-property name="lastname"  type="java.lang.String" initial=""/>
    </form-bean>
  </form-beans>
<!-- ================================= Global Exception Definitions -->
     <global-exceptions>
         <!-- sample exception handler
         <exception
             key="expired.password"
             type="app.ExpiredPasswordException"
             path="/changePassword.jsp"/>
         end sample -->
     </global-exceptions>
<!-- =================================== Global Forward Definitions -->
     <global-forwards>
         <!-- Default forward to "Welcome" action -->
         <!-- Demonstrates using index.jsp to forward -->
         <forward
             name="welcome"
             path="/Welcome.do"/>
     </global-forwards>
<!-- =================================== Action Mapping Definitions -->
     <action-mappings>
       <!-- ************************************************** -->
       <!-- Tiles test -->
       <action path="/Basic"
         type="DS.actions.DSRedirect"
         name="redirect"
         scope="request"
         validate="false">
         <forward name="toPage" path="basicDef" />
       </action>
       <!--
            path      = URL, as in http://localhost/DS/Basic.do
            type      = class that gets called with the request
            forward   = in this case, the Tiles definition that
                        does the actual processing of the
                        request.
            toPage is the only forward supported by DSRedirect,
            and it returns it regardless.
            basicDef can be found in WEB-INF/tiles-defs.xml.
       -->

       <action path="/Grid"
         type="DS.actions.DSRedirect"
         name="redirect"
         scope="request"
         validate="false">
         <forward name="toPage" path="gridDef" />
       </action>
       <!--
            Same as action Basic, but with the following changes:

            path      = URL, as in http://localhost/DS/Grid.do
            forward   = to gridDef

            gridDef can be found in WEB-INF/tiles-defs.xml.
       -->

       <!-- ************************************************** -->

       <!-- This action has no form - takes params from request -->
       <action path="/GridDetails"
         type="DS.actions.GridDetailPullAction">
         <forward name="login"    path="/Login.jsp" />
         <forward name="list"     path="/Tiles/Grid/GridDetailsList.jsp" />
         <forward name="genericfailure"  path="/genericfailure.jsp" />
         <forward name="sqlerror" path="/sqlerror.jsp" />
       </action>

       <action path="/LoginAction"
         type="DS.actions.LoginAction"
         name="loginForm"
         input="/LoginForm.jsp">
         <forward name="success"  path="/MainMenu.jsp" />
         <forward name="failure"  path="/Login.jsp" />
         <forward name="sqlerror" path="/sqlerror.jsp" />
       </action>

       <action path="/MenuAction"
         type="DS.actions.MenuAction">
         <forward name="login"    path="/Login.jsp" />
         <forward name="grid"     path="gridDef" />
         <forward name="genericfailure" path="/genericfailure.jsp" />
         <forward name="sqlerror" path="/sqlerror.jsp" />
       </action>

       <action path="/GridAction"
         type="DS.actions.GridAction"
         name="editForm">
         <forward name="login" path="/Login.jsp" />
         <forward name="genericfailure"  path="/genericfailure.jsp" />
         <forward name="sqlerror"        path="/sqlerror.jsp" />
         <forward name="MCI"             path="edtMCIDef" />
       </action>

       <action path="/EditAction"
         type="DS.actions.EditAction"
         name="dfMCI">
         <forward name="login"           path="/Login.jsp" />
         <forward name="genericfailure"  path="/genericfailure.jsp" />
         <forward name="sqlerror"        path="/sqlerror.jsp" />
         <forward name="grid"            path="gridDef" />
       </action>

     </action-mappings>
<!-- ===================================== Controller Configuration -->
     <controller
        processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<!-- ================================ Message Resources Definitions -->
     <message-resources parameter="DS.ApplicationResources" />
<!-- ======================================= Plug Ins Configuration -->
<!-- ========== Tiles plugin ===================  -->
   <!-- comment following if struts1.0.x -->
   <plug-in className="org.apache.struts.tiles.TilesPlugin" >
     <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
     <set-property property="definitions-debug" value="2" />
     <set-property property="definitions-parser-details" value="0" />
     <set-property property="definitions-parser-validate" value="true" />
   </plug-in>

   <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
     <set-property
         property="pathnames"
         value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
   </plug-in>
</struts-config>

-----------------------------------------------------

package DS.actions;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class EditAction extends Action {

   public ActionForward execute(
                          ActionMapping mapping,
                          ActionForm form,
                          HttpServletRequest request,
                          HttpServletResponse response )
   throws Exception, IOException, ServletException {

     // gutted for test purposes.  Just forward back to grid
     return ( mapping.findForward( "grid" ) );
   }
}


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


RE: DynaActionForm example

Posted by Brandon Goodin <ma...@phase.ws>.
Would you mind posting all of the struts-config.xml that uses this form-bean
defintiion (i.e. form-bean, action) or just post the whole struts-config.xml
if it is small enough. Please post the jsp and action code too. This would
help me to see what is going on. Also, post what environment you are using
it in (jdk,struts version, container).

P.S. I am sorry it took so long for me to respond. I just woke up from a
Saturday nap :-D

Brandon Goodin

-----Original Message-----
From: Todd Grigsby [mailto:strutsuser@tgrigsby.com]
Sent: Saturday, May 10, 2003 4:30 PM
To: Struts Users Mailing List
Subject: Re: DynaActionForm example


To add a little more fuel to the fire, in the action preceding my JSP, I've
tried to prepopulate the form (although I've skipped that recently to try to
figure out what's going on), and in that action I put some code to print out
the
properties in the DynaActionForm prior to forwarding to the JSP that will
use
the DynaActionForm.  That code sees properties in the DynaActionForm's map
that
the JSP doesn't see.  In fact, it would seem that the JSP receives a
DynaActionForm with no properties at all.  The definition, as I mentioned
before, for the form bean is:

<form-bean name="dfMCI" type="org.apache.struts.action.DynaActionForm">
  <form-property name="op"        type="java.lang.String" initial=""/>
  <form-property name="dataset"   type="java.lang.String" initial=""/>
  <form-property name="recid"     type="java.lang.String" initial=""/>
  <form-property name="ID"        type="java.lang.String" initial=""/>
  <form-property name="firstname" type="java.lang.String" initial=""/>
  <form-property name="lastname"  type="java.lang.String" initial=""/>
</form-bean>

And the opening form tag in the JSP is:

<html:form
   action="/EditAction"
   type="org.apache.struts.action.DynaActionForm"
   name="dfMCI">

Any thoughts?

T


---------------------------------------------------------------------
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


Re: DynaActionForm example

Posted by Todd Grigsby <st...@tgrigsby.com>.
To add a little more fuel to the fire, in the action preceding my JSP, I've 
tried to prepopulate the form (although I've skipped that recently to try to 
figure out what's going on), and in that action I put some code to print out the 
properties in the DynaActionForm prior to forwarding to the JSP that will use 
the DynaActionForm.  That code sees properties in the DynaActionForm's map that 
the JSP doesn't see.  In fact, it would seem that the JSP receives a 
DynaActionForm with no properties at all.  The definition, as I mentioned 
before, for the form bean is:

<form-bean name="dfMCI" type="org.apache.struts.action.DynaActionForm">
  <form-property name="op"        type="java.lang.String" initial=""/>
  <form-property name="dataset"   type="java.lang.String" initial=""/>
  <form-property name="recid"     type="java.lang.String" initial=""/>
  <form-property name="ID"        type="java.lang.String" initial=""/>
  <form-property name="firstname" type="java.lang.String" initial=""/>
  <form-property name="lastname"  type="java.lang.String" initial=""/>
</form-bean>

And the opening form tag in the JSP is:

<html:form
   action="/EditAction"
   type="org.apache.struts.action.DynaActionForm"
   name="dfMCI">

Any thoughts?

T


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


RE: DynaActionForm example

Posted by Brandon Goodin <ma...@phase.ws>.
What are you trying to do?

Declare a form bean as a DynaActionForm in your struts-config.
<form-bean name="myForm"
type="org.apache.struts.actions.DynaActionForm">
<form-property name="firstName"
type="java.lang.String"/>
<form-property name="lastName"
type="java.lang.String"/>
<form-property name="age"
type="java.lang.Integer"/>
</form-bean>
</form-beans>

Set up an actino to us it.

<action path="/myAction"
type="com.foo.MyAction"
name="myForm"
scope="request"
validate="false">
<forward name="auth"
path="/welcome.jsp"
redirect="false"/>
</action>

Cast the form in the Action to a DynaActionForm

DynaActionForm dynaForm = (DynaActionForm)form;

use the dynaForm.get(String propertyName) and dynaForm.set(String
propertyName) accessor methods to your hearts content.

You html forms should look the same as when using a hard-coded ActionForm.

if you use jstl to display form values then use the ${[dynaActionForm
name].map['[property name]']} to extract the values.

Other than that you should be able to look at the javadocs and figure it
out.
http://jakarta.apache.org/struts/api/org/apache/struts/action/DynaActionForm
.html

This should help too.
http://jakarta.apache.org/struts/userGuide/building_controller.html#dyna_act
ion_form_classes

I'm not sure what your problem was. But, try posting it again.

Brandon Goodin

-----Original Message-----
From: Todd Grigsby [mailto:strutsuser@tgrigsby.com]
Sent: Saturday, May 10, 2003 3:40 PM
To: Struts Users Mailing List
Subject: DynaActionForm example



Does anyone have an example of how a DynaActionForm would be used?  I
submitted
a post about having problems with a DynaActionForm (5/10 12:31am) but no one
has
responded, so if someone could just point me to an example, I'd sure be
happy.

I have three books on Struts, "Struts In Action", "The Struts Framework",
and
"Mastering Jakarta Struts", and NOT ONE OF THEM sufficiently covers
DynaActionForms or gives an example of one in use.  "The Struts Framework"
comes
the closest, but obviously doesn't give a complete enough example for me to
figure out what I'm doing wrong.

Thanks in advance,

Todd


---------------------------------------------------------------------
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


DynaActionForm example

Posted by Todd Grigsby <st...@tgrigsby.com>.
Does anyone have an example of how a DynaActionForm would be used?  I submitted 
a post about having problems with a DynaActionForm (5/10 12:31am) but no one has 
responded, so if someone could just point me to an example, I'd sure be happy.

I have three books on Struts, "Struts In Action", "The Struts Framework", and 
"Mastering Jakarta Struts", and NOT ONE OF THEM sufficiently covers 
DynaActionForms or gives an example of one in use.  "The Struts Framework" comes 
the closest, but obviously doesn't give a complete enough example for me to 
figure out what I'm doing wrong.

Thanks in advance,

Todd


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