yes, it was a typo for which I paid bigtime. Also, after correcting my jsp to use name="SetupForm" for all the textboxes and checkboxes in JSP.

Everything worked just like that.

Thanks you all for helping me working with dynaactionforms.


Thanks again.


From: Laurie Harper <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: user@struts.apache.org
Subject: Re: No getter method servlet Exception. using DynaActionForm
Date: Thu, 17 Nov 2005 14:44:07 -0500

fea jabi wrote:
By changing the form property boolean - Boolean
<form-property name="confirm" type="java.lang.boolean" initial="true"/>

to
<form-property name="confirm" type="java.lang.Boolean" initial="true"/>

I am able to get the instance of the dynaactionform.

is it necessary to use Boolean itself?

Yep, as Dave points out, there's no such type as java.lang.boolean. It should be either just 'boolean' or 'java.lang.Boolean'.

none of my form properties are initialized. all strings are "" and Boolean are <NULL> by default from what I see thru System.out.println of form in my action.

Since they are as above I am getting the "no getter method for property exception I think". Am I right?

What exactly is the exception and where do you get it?

What should be happening is, when you hit your setup action, Struts should create a new form bean with its properties initialized as you specified in struts-config.xml. Then, when you submit the form to one of your other actions, the form properties will be updated based on the request parameters.

If you're seeing a 'no getter method' excetption, you're probably trying to access a property in your JSP that you didn't declare in your form bean config.

Do all the Dynaform properties have to be initialized always?

No. As noted, they should be defaulted for you the first time the form is created. Note, however, that if you store the form in session scope, its properties are *not* reset to their initial values by DynaActionForm's reset() method, so the properties will retain the values they had the last time the form was used.

Perhaps this is your problem? Struts creates and init's the form, you use it in some way that results in all the properties being cleared, then you use it in a context you're expecting it to be fresh and it's still empty.

Try setting your 'scope' to 'request' on each of your action mappings in struts-config and see if that changes the behaviour (after fixing whatever is causing your 'no getter' problems, of course).

L.

thanks.

Thank you all for helping me using the dynaactionform.


From: Laurie Harper <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: user@struts.apache.org
Subject: Re: No getter method servlet Exception. using DynaActionForm
Date: Wed, 16 Nov 2005 22:49:52 -0500

What you have below looks right to me; the action mapping has 'name' set to your action form, so you should be getting an instance of it in the action. Double check you haven't gotten your config out of sync along the way.

L.

fea jabi wrote:

thanks for your response. Understood better now.

I am not sure why but the setupForm is null in the Action when debugged thru the code.

DynaActionForm setupForm = (DynaActionForm) form;

System.out.println("In PrepareSetupAction : setupform is : " + setupForm);


Any idea of why it's so? Is there anything else I have to do?

Thanks.


From: Laurie Harper <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: user@struts.apache.org
Subject: Re: No getter method servlet Exception. using DynaActionForm
Date: Wed, 16 Nov 2005 15:48:33 -0500

At least part of your problem is the way you're trying to setup the action form. Struts will create an instance of the form bean for you, which is what is passed into execute() via the 'form' parameter. You're referencing that in the first line of your execute() method.

However, you then go on to build your own form bean instance, and replace the one Struts put in the request with the one you've built. You don't need to do this; just use the bean Struts supplies in the 'form' parameter.

You mentioned that someone has suggested you needed to do this to get initial values populated; that's not the case. The first time Struts builds an instance of DynaActionForm, it will populate properties for which you've supplied an initial value. What it won't do is reset properties to their initial values when the reset() method is called on the form, which you might care about if you have the form stored in session scope. You can worry about that later though.

So, essentially, your execute() method can be simplified to just this:

>    public ActionForward execute(ActionMapping mapping,
>                               ActionForm form,
>                               HttpServletRequest request,
>                               HttpServletResponse response)
>                       throws ServletException, IOException{
>        DynaActionForm setupForm = (DynaActionForm) form;
>        //getSetupInfo(setupForm);
>        return mapping.findForward("success");
>    }

L.

fea jabi wrote:

Thanks for hepling me. here is the code

<form-bean
       name="SetupForm"
       type="org.apache.struts.action.DynaActionForm" dynamic="true">
       <form-property name="custName" type="java.lang.String"/>
       <form-property name="typeName" type="java.lang.String"/>
       <form-property name="typeNameDesc" type="java.lang.String"/>
<form-property name="confirm" type="java.lang.boolean" initial="true"/>
   </form-bean>

<action
       path="/PrepareSetupAction"
       type="com.actions.PrepareSetupAction"
       name="SetupForm"
       scope="session"
       validate="false"
       input="/pages/Setup.jsp">
<forward name="success" path="/pages/Setup.jsp" redirect="false"/>
    </action>



public class PrepareSetupAction extends Action {

   /** Creates a new instance of PrepareSetupAction */
   public PrepareSetupAction() {
   }

   public ActionForward execute(ActionMapping mapping,
                              ActionForm form,
                              HttpServletRequest request,
                              HttpServletResponse response)
                      throws ServletException, IOException{
       DynaActionForm setupForm = (DynaActionForm) form;

System.out.println("In PrepareSetupAction : setupform is : " + setupForm);

       //getSetupInfo(setupForm);

ModuleConfig moduleConfig = RequestUtils.getModuleConfig(request, getServlet().getServletContext()); FormBeanConfig formConfig = moduleConfig.findFormBeanConfig("SetupForm"); DynaActionFormClass dynaClass = DynaActionFormClass.createDynaActionFormClass(formConfig);

       try {
           setupForm = (DynaActionForm)dynaClass.newInstance();
System.out.println("In PrepareSetupAction in try : setupform is : " + setupForm);
       }
       catch (Exception e) {
           //logger.error(e);
       }

       //request.setAttribute("SetupForm", setupForm);
       return mapping.findForward("success");
   }

}


       <html:form action="PrepareScreen1Action.do" method="post">
           <table >
............................
......................................
<!-- 1. Customer Name-->
               <tr>
                   <td>
<bean:message key="lbl.customername"/> <bean:message key="colon"/>
                   </td>
                   <td>
<html:text property="custName" size="40" styleClass="invisibleInput" readonly="true" tabindex="-1"/>
                   </td>
                   <td></td>
               </tr>
               <tr></tr><tr></tr><tr></tr>
               <tr>
                   <td>
<bean:message key="lbl.typename"/> <bean:message key="colon"/>
                   </td>
                   <td>
                       <html:text property="typeName" size="40" />
                   </td>
                   <td></td>
               </tr>
               <tr></tr><tr></tr><tr></tr>
               <!-- 3. Type Name Description -->
               <tr>
                   <td>
<bean:message key="lbl.typenamedescption"/> <bean:message key="colon"/>
                   </td>
                   <td>
                       <html:textarea property="typeNameDesc" />
                   </td>
                   <td></td>
               </tr>
               <tr></tr><tr></tr><tr></tr>
               <!-- 4. confirm -->
               <tr>
                   <td>
<bean:message key="lbl.confirm"/> <bean:message key="colon"/>
                   </td>
                   <td>
                       <html:checkbox property="confirm" />
                   </td>
                   <td></td>
               </tr>
......................
....................
</table>
</html-form>


thanks.



From: Dave Newton <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: Struts Users Mailing List <user@struts.apache.org>
Subject: Re: No getter method servlet Exception. using DynaActionForm
Date: Wed, 16 Nov 2005 11:06:56 -0500

fea jabi wrote:

When I debug after
DynaActionForm setupForm = (DynaActionForm) form;

my setupForm is null




Is your struts config as you posted earlier? i.e., the "name" attribute refers to a Dyna form that doesn't exist in the "form-beans" section? That won't work.

ModuleConfig moduleConfig =

RequestUtils.getModuleConfig(request,
getServlet().getServletContext());
        FormBeanConfig formConfig =
moduleConfig.findFormBeanConfig("CustForm");
        DynaActionFormClass dynaClass =
DynaActionFormClass.createDynaActionFormClass(formConfig);

        try {
            setupForm = (DynaActionForm)dynaClass.newInstance();





one of the user suggested that when I initialize a form-property in struts-config using initial="true"
I have to use the above to prepopulate the form.

is this right?? Am I using at the right place.




If Struts is configured the form will have already been created on entry to the Action.

I think you need to back up a step and check your configuration. If you post the relevent sections again as they exist now we might be able to help you better.

Right now things are wrong, and I find it highly unlikely you would _ever_ need or want to instantiate a form inside an Action.

Dave



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


_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/





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


_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




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


_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



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


_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


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

Reply via email to