You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mu Mike <mi...@hotmail.com> on 2004/03/11 02:30:38 UTC

help me with using bean

I have files like the below,I m  trying to submit a bean object to my 
action class, yet when I pressed the "submit" on the jsp file,it threw an 
exception:java.lang.IllegalArgumentException: No bean specified

what is the correct way?
Thanks&Regards


myjsp.jsp
========
html:form action="/selectFont.do" >
    <tr>
    <td>
      <html:text property="bean.size" value="10"/>
    </td>
    <td>
      <html:text property="bean.fontName" value="aria"/>
    </td>
    </tr>
    <input type="submit"/>
</html:form>

=========
part of struts-config.xml

        <form-beans>
        <form-bean name="SelectFontForm"
            type="com.viador.rv.form.SelectFontForm">
            <form-property name="bean"
                           type="com.viador.rv.bean.FontBean"/>
        </form-bean>
         </form-beans>

        <action-mappings>
        <action path="/selectFont"
            type="com.viador.rv.action.ApplyFormatAction"
            name="SelectFontForm"
            scope="session">
        </action>
       </action-mappings>

===========
SelectFontForm.java

import org.apache.struts.action.ActionForm;
import com.viador.rv.bean.FontBean;

public class SelectFontForm extends ActionForm{
    public FontBean getBean() {
        return bean;
    }

    public void setBean(FontBean bean) {
        this.bean = bean;
    }

    private FontBean bean;
}

==========
FontBean.java

public class FontBean  {
    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public String getFontName() {
        return fontName;
    }

    public void setFontName(String fontName) {
        this.fontName = fontName;
    }

    private int size;
    private String fontName;

}

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com  


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


Re: help me with using bean

Posted by stu <sw...@ucs.co.za>.
On Thu, 11 Mar 2004 01:30:38 +0000
"Mu Mike" <mi...@hotmail.com> wrote:

> I have files like the below,I m  trying to submit a bean object to my 
> action class, yet when I pressed the "submit" on the jsp file,it threw
> an exception:java.lang.IllegalArgumentException: No bean specified
> 
> what is the correct way?
> Thanks&Regards
> 
> 
> myjsp.jsp
> ========
> html:form action="/selectFont.do" >
>     <tr>
>     <td>
>       <html:text property="bean.size" value="10"/>
>     </td>
>     <td>
>       <html:text property="bean.fontName" value="aria"/>
>     </td>
>     </tr>
>     <input type="submit"/>
> </html:form>
> 

Don't you need the 'name' attribute in your html:text tags ie

<html:text name="SelectFontForm" property="bean.size" value="10"/>
           ^^^^^^^^^^^^^^^^^^^^^

-- 
Stuart Logie
Programmer

UNIVERSAL COMPUTER SERVICES (PTY) LTD
A member of South Africa's largest retail software vendor, the UCS Group

Tel : (011) 712 1371   Cell : 082 902 5632
Fax : (011) 339 3421
Internet : http://ucs.co.za

"I am the Unconquerable Spirit."
               -- Poet Unknown
   
Powered by Debian GNU/Linux - testing/unstable

RE: help me with using bean

Posted by David Friedman <hu...@ix.netcom.com>.
Mike,

When you use form-property with a form-bean, don't you need to make the main
Bean a DynaActionForm or a class you extended from DynaActionForm?  Where do
you initialize the form-property "bean".  For DynaActionForms, they
initialize to null, per "If you do not supply an initial attribute, numbers
will be initialized to 0 and objects to null" from the document:
http://jakarta.apache.org/struts/userGuide/building_controller.html#dyna_act
ion_form_classes

Regards,
David

-----Original Message-----
From: Mu Mike [mailto:mikemu_58@hotmail.com]
Sent: Wednesday, March 10, 2004 8:31 PM
To: struts-user@jakarta.apache.org
Subject: help me with using bean


I have files like the below,I m  trying to submit a bean object to my
action class, yet when I pressed the "submit" on the jsp file,it threw an
exception:java.lang.IllegalArgumentException: No bean specified

what is the correct way?
Thanks&Regards


myjsp.jsp
========
html:form action="/selectFont.do" >
    <tr>
    <td>
      <html:text property="bean.size" value="10"/>
    </td>
    <td>
      <html:text property="bean.fontName" value="aria"/>
    </td>
    </tr>
    <input type="submit"/>
</html:form>

=========
part of struts-config.xml

        <form-beans>
        <form-bean name="SelectFontForm"
            type="com.viador.rv.form.SelectFontForm">
            <form-property name="bean"
                           type="com.viador.rv.bean.FontBean"/>
        </form-bean>
         </form-beans>

        <action-mappings>
        <action path="/selectFont"
            type="com.viador.rv.action.ApplyFormatAction"
            name="SelectFontForm"
            scope="session">
        </action>
       </action-mappings>

===========
SelectFontForm.java

import org.apache.struts.action.ActionForm;
import com.viador.rv.bean.FontBean;

public class SelectFontForm extends ActionForm{
    public FontBean getBean() {
        return bean;
    }

    public void setBean(FontBean bean) {
        this.bean = bean;
    }

    private FontBean bean;
}

==========
FontBean.java

public class FontBean  {
    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public String getFontName() {
        return fontName;
    }

    public void setFontName(String fontName) {
        this.fontName = fontName;
    }

    private int size;
    private String fontName;

}

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com


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


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