You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Brown, Melonie S. - Contractor" <Me...@forscom.army.mil> on 2003/07/02 18:00:11 UTC

Html-El Form and Indexed Tags Problem

I have a form with a list that is made up of UserMenuItem objects.  I want
to allow the user to set various properties of the individual UserMenuItem
objects.  The action the form is submitted to would take the list with the
user's input and process it.

To accomplish this, I'm trying to do something similar to the struts-el
example at http://jakarta.apache.org/struts/faqs/indexedprops.html, but I
keep getting a "[ServletException in:/pages/admin/user/adduserperms.jsp] No
getter method for property permsMenuItem.permission[0] of bean userPerms'"  

I know the data is there, because if I do the non-indexed version of the
page (code at end of post), I can see each item in the list. But when I try
to process the form in the submitted-to action, the form is null (hence the
attempt at indexed).

Following are snippets of the relative code.  I would greatly appreciate any
assistance in figuring out what I'm doing wrong.

Struts-config:
<form-bean name="UserPermissions" type="foo.UserPermissions"> </form-bean>

Form fields:
private List userPerms; [made up of UserMenuItem objects]
[getter / setter]


public UserMenuItem getPermsMenuItem(int index) [to get the indexed property
item]
{ return (UserMenuItem) userPerms.get(index); }

UserMenuItem:
private String description;
private String permission;
[more fields / getters and setters]


JSP Indexed Page:
-------------------
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/display.tld" prefix="display" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-logic-el.tld" prefix="logic-el" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<html-el:form action="/setUserPerms.do">  
   <logic-el:iterate name="UserPermissions" indexId="ctr"
property="userPerms" id="userPerms">  
     <div class="formrow">   
        <div class="label">
             <label><c:out value="${userPerms.description}"/></label>
         </div>
         <div class="widget">
              <html-el:text name="userPerms"
property="permsMenuItem[${ctr}].permission" />  (also tried adding
indexed="true" - didn't work)
         </div>
     </div>
   </logic-el:iterate> 
   
   <div class="formrow">
       <div class="label">
          &nbsp;
       </div>
       <div class="widget">
          <html:submit property="submit" />
       </div>
   </div>
</html-el:form>


Jsp NonIndexed Page:
----------------------
<html-el:form action="/setUserPerms.do">  
   <logic-el:iterate name="UserPermissions" property="userPerms" id="perms">

            <div class="formrow">                 
                 <div class="label">
                     <label><c:out value="${perms.description}"/></label>
                 </div>
                 <div class="widget">
                    <html-el:text name="perms" property="permission" />
                 </div>
             </div>
   </logic-el:iterate> 
   
   <div class="formrow">
       <div class="label">
          &nbsp;
       </div>
       <div class="widget">
          <html:submit property="submit" />
       </div>
   </div>
</html-el:form>

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


Re: Html-El Form and Indexed Tags Problem

Posted by Sandeep Takhar <sa...@yahoo.com>.
I don't think you want the [ctr] and keep
indexed="true"

The thing you are iterating on is already doing the
[ctr] for you.

sandeep
--- "Brown, Melonie S. - Contractor"
<Me...@forscom.army.mil> wrote:
> I have a form with a list that is made up of
> UserMenuItem objects.  I want
> to allow the user to set various properties of the
> individual UserMenuItem
> objects.  The action the form is submitted to would
> take the list with the
> user's input and process it.
> 
> To accomplish this, I'm trying to do something
> similar to the struts-el
> example at
>
http://jakarta.apache.org/struts/faqs/indexedprops.html,
> but I
> keep getting a "[ServletException
> in:/pages/admin/user/adduserperms.jsp] No
> getter method for property
> permsMenuItem.permission[0] of bean userPerms'"  
> 
> I know the data is there, because if I do the
> non-indexed version of the
> page (code at end of post), I can see each item in
> the list. But when I try
> to process the form in the submitted-to action, the
> form is null (hence the
> attempt at indexed).
> 
> Following are snippets of the relative code.  I
> would greatly appreciate any
> assistance in figuring out what I'm doing wrong.
> 
> Struts-config:
> <form-bean name="UserPermissions"
> type="foo.UserPermissions"> </form-bean>
> 
> Form fields:
> private List userPerms; [made up of UserMenuItem
> objects]
> [getter / setter]
> 
> 
> public UserMenuItem getPermsMenuItem(int index) [to
> get the indexed property
> item]
> { return (UserMenuItem) userPerms.get(index); }
> 
> UserMenuItem:
> private String description;
> private String permission;
> [more fields / getters and setters]
> 
> 
> JSP Indexed Page:
> -------------------
> <%@ taglib uri="/WEB-INF/struts-tiles.tld"
> prefix="tiles" %>
> <%@ taglib uri="/WEB-INF/display.tld"
> prefix="display" %>
> <%@ taglib uri="/WEB-INF/struts-bean-el.tld"
> prefix="bean-el" %>
> <%@ taglib uri="/WEB-INF/struts-html-el.tld"
> prefix="html-el" %>
> <%@ taglib uri="/WEB-INF/struts-logic-el.tld"
> prefix="logic-el" %>
> <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
> <html-el:form action="/setUserPerms.do">  
>    <logic-el:iterate name="UserPermissions"
> indexId="ctr"
> property="userPerms" id="userPerms">  
>      <div class="formrow">   
>         <div class="label">
>              <label><c:out
> value="${userPerms.description}"/></label>
>          </div>
>          <div class="widget">
>               <html-el:text name="userPerms"
> property="permsMenuItem[${ctr}].permission" /> 
> (also tried adding
> indexed="true" - didn't work)
>          </div>
>      </div>
>    </logic-el:iterate> 
>    
>    <div class="formrow">
>        <div class="label">
>           &nbsp;
>        </div>
>        <div class="widget">
>           <html:submit property="submit" />
>        </div>
>    </div>
> </html-el:form>
> 
> 
> Jsp NonIndexed Page:
> ----------------------
> <html-el:form action="/setUserPerms.do">  
>    <logic-el:iterate name="UserPermissions"
> property="userPerms" id="perms">
> 
>             <div class="formrow">                 
>                  <div class="label">
>                      <label><c:out
> value="${perms.description}"/></label>
>                  </div>
>                  <div class="widget">
>                     <html-el:text name="perms"
> property="permission" />
>                  </div>
>              </div>
>    </logic-el:iterate> 
>    
>    <div class="formrow">
>        <div class="label">
>           &nbsp;
>        </div>
>        <div class="widget">
>           <html:submit property="submit" />
>        </div>
>    </div>
> </html-el:form>
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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