You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ZYD <el...@hotmail.com> on 2003/11/06 02:52:12 UTC

multibox - Null attribute name ServletException

I tried to use multibox. I copied the code snippet from Struts in Action, but I got:
[ServletException in:/WEB-INF/jsp/form/multiboxTest.jsp] Null attribute name' 
---------------------------------------------------
This is my multiboxTest.jsp:

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<html:form action="/Multibox">

<table border="0" width="100%">

<logic:iterate id="item" property="items">
 <html:multibox property="selectedItems">
  <bean:write name="item"/>
 </html:multibox>
 <bean:write name="item"/>
</logic:iterate>

<!-- Buttons -->
<tr>
 <td>
     <html:submit property="ok" onclick="bCancel=false;">
   <bean:message key="button.ok"/>
  </html:submit> 
  &nbsp;
  <html:submit property="cancel" onclick="bCancel=true;">
   <bean:message key="button.cancel"/>
  </html:submit>
 </td>
</tr>
</table>
</html:form>
---------------------------------------------------
This is my ActionForm: MultiboxForm .java

public class MultiboxForm extends ActionForm
{
     private String[] selectedItems = {};
     private String[] items = { "UPS", "FedEx", "Airborne" };
     public String[] getSelectedItems()
     {
          return this.selectedItems;
     }
     public void setSelectedItems(String[] selectedItems)
     {
          this.selectedItems = selectedItems;
     }

     public ActionErrors validate(
          ActionMapping mapping,
          HttpServletRequest request)
         {
              ActionErrors errors = new ActionErrors();    
              return errors;
         }
}

Re: multibox - Null attribute name ServletException - SOLVED

Posted by ZYD <el...@hotmail.com>.
I change html:iterate tag to:

<logic:iterate id="item" name="multiboxTest" property="items">

the ="multiboxTest"  is the ActionForm bean's name in struts-config.xml.

and add getter/setter for items, now it works.

Thanks.

bruce


----- Original Message ----- 
From: "ZYD" <el...@hotmail.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, November 06, 2003 10:23 AM
Subject: Re: multibox - Null attribute name ServletException


> Thanks for your response.
> Could you give me some hint? I'm a struts newbie.
> 
> Thanks a lot.
> 
> ----- Original Message ----- 
> From: "Firat TIRYAKI" <fi...@pleksus.com.tr>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Thursday, November 06, 2003 11:04 PM
> Subject: Re: multibox - Null attribute name ServletException
> 
> 
> > store the properties in a bean and recall them in your action.
> > 
> > F.
> > 
> > 
> > ----- Original Message ----- 
> > From: "ZYD" <el...@hotmail.com>
> > To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> > Sent: Thursday, November 06, 2003 3:52 AM
> > Subject: multibox - Null attribute name ServletException
> > 
> > 
> > >
> > > I tried to use multibox. I copied the code snippet from Struts in Action,
> > but I got:
> > > [ServletException in:/WEB-INF/jsp/form/multiboxTest.jsp] Null attribute
> > name'
> > > ---------------------------------------------------
> > > This is my multiboxTest.jsp:
> > >
> > > <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> > > <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> > > <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
> > >
> > > <html:form action="/Multibox">
> > >
> > > <table border="0" width="100%">
> > >
> > > <logic:iterate id="item" property="items">
> > >  <html:multibox property="selectedItems">
> > >   <bean:write name="item"/>
> > >  </html:multibox>
> > >  <bean:write name="item"/>
> > > </logic:iterate>
> > >
> > > <!-- Buttons -->
> > > <tr>
> > >  <td>
> > >      <html:submit property="ok" onclick="bCancel=false;">
> > >    <bean:message key="button.ok"/>
> > >   </html:submit>
> > >   &nbsp;
> > >   <html:submit property="cancel" onclick="bCancel=true;">
> > >    <bean:message key="button.cancel"/>
> > >   </html:submit>
> > >  </td>
> > > </tr>
> > > </table>
> > > </html:form>
> > > ---------------------------------------------------
> > > This is my ActionForm: MultiboxForm .java
> > >
> > > public class MultiboxForm extends ActionForm
> > > {
> > >      private String[] selectedItems = {};
> > >      private String[] items = { "UPS", "FedEx", "Airborne" };
> > >      public String[] getSelectedItems()
> > >      {
> > >           return this.selectedItems;
> > >      }
> > >      public void setSelectedItems(String[] selectedItems)
> > >      {
> > >           this.selectedItems = selectedItems;
> > >      }
> > >
> > >      public ActionErrors validate(
> > >           ActionMapping mapping,
> > >           HttpServletRequest request)
> > >          {
> > >               ActionErrors errors = new ActionErrors();
> > >               return errors;
> > >          }
> > > }
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> > 
> >

Re: multibox - Null attribute name ServletException

Posted by ZYD <el...@hotmail.com>.
Thanks for your response.
Could you give me some hint? I'm a struts newbie.

Thanks a lot.

----- Original Message ----- 
From: "Firat TIRYAKI" <fi...@pleksus.com.tr>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, November 06, 2003 11:04 PM
Subject: Re: multibox - Null attribute name ServletException


> store the properties in a bean and recall them in your action.
> 
> F.
> 
> 
> ----- Original Message ----- 
> From: "ZYD" <el...@hotmail.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Thursday, November 06, 2003 3:52 AM
> Subject: multibox - Null attribute name ServletException
> 
> 
> >
> > I tried to use multibox. I copied the code snippet from Struts in Action,
> but I got:
> > [ServletException in:/WEB-INF/jsp/form/multiboxTest.jsp] Null attribute
> name'
> > ---------------------------------------------------
> > This is my multiboxTest.jsp:
> >
> > <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> > <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> > <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
> >
> > <html:form action="/Multibox">
> >
> > <table border="0" width="100%">
> >
> > <logic:iterate id="item" property="items">
> >  <html:multibox property="selectedItems">
> >   <bean:write name="item"/>
> >  </html:multibox>
> >  <bean:write name="item"/>
> > </logic:iterate>
> >
> > <!-- Buttons -->
> > <tr>
> >  <td>
> >      <html:submit property="ok" onclick="bCancel=false;">
> >    <bean:message key="button.ok"/>
> >   </html:submit>
> >   &nbsp;
> >   <html:submit property="cancel" onclick="bCancel=true;">
> >    <bean:message key="button.cancel"/>
> >   </html:submit>
> >  </td>
> > </tr>
> > </table>
> > </html:form>
> > ---------------------------------------------------
> > This is my ActionForm: MultiboxForm .java
> >
> > public class MultiboxForm extends ActionForm
> > {
> >      private String[] selectedItems = {};
> >      private String[] items = { "UPS", "FedEx", "Airborne" };
> >      public String[] getSelectedItems()
> >      {
> >           return this.selectedItems;
> >      }
> >      public void setSelectedItems(String[] selectedItems)
> >      {
> >           this.selectedItems = selectedItems;
> >      }
> >
> >      public ActionErrors validate(
> >           ActionMapping mapping,
> >           HttpServletRequest request)
> >          {
> >               ActionErrors errors = new ActionErrors();
> >               return errors;
> >          }
> > }
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 

Re: multibox - Null attribute name ServletException

Posted by Firat TIRYAKI <fi...@pleksus.com.tr>.
store the properties in a bean and recall them in your action.

F.


----- Original Message ----- 
From: "ZYD" <el...@hotmail.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Thursday, November 06, 2003 3:52 AM
Subject: multibox - Null attribute name ServletException


>
> I tried to use multibox. I copied the code snippet from Struts in Action,
but I got:
> [ServletException in:/WEB-INF/jsp/form/multiboxTest.jsp] Null attribute
name'
> ---------------------------------------------------
> This is my multiboxTest.jsp:
>
> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
>
> <html:form action="/Multibox">
>
> <table border="0" width="100%">
>
> <logic:iterate id="item" property="items">
>  <html:multibox property="selectedItems">
>   <bean:write name="item"/>
>  </html:multibox>
>  <bean:write name="item"/>
> </logic:iterate>
>
> <!-- Buttons -->
> <tr>
>  <td>
>      <html:submit property="ok" onclick="bCancel=false;">
>    <bean:message key="button.ok"/>
>   </html:submit>
>   &nbsp;
>   <html:submit property="cancel" onclick="bCancel=true;">
>    <bean:message key="button.cancel"/>
>   </html:submit>
>  </td>
> </tr>
> </table>
> </html:form>
> ---------------------------------------------------
> This is my ActionForm: MultiboxForm .java
>
> public class MultiboxForm extends ActionForm
> {
>      private String[] selectedItems = {};
>      private String[] items = { "UPS", "FedEx", "Airborne" };
>      public String[] getSelectedItems()
>      {
>           return this.selectedItems;
>      }
>      public void setSelectedItems(String[] selectedItems)
>      {
>           this.selectedItems = selectedItems;
>      }
>
>      public ActionErrors validate(
>           ActionMapping mapping,
>           HttpServletRequest request)
>          {
>               ActionErrors errors = new ActionErrors();
>               return errors;
>          }
> }


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