RE: Map Backed Form/Tiles
Nope! Im sorry to say. I only wish it were so. The page comes up and initializes correctly with the value that ${element.value} evaluates to. So _ I think it might be in some way environmental, so I will double and triple check the common-* jars for size and dates. Thanks for all of your help! -Original Message- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Friday, September 19, 2003 4:20 PM To: Struts Users Mailing List Subject: Re: Map Backed Form/Tiles Ray Madigan wrote: > I have narrowed the problem down to: > >value='${element.value}'/> > > being in a tile. If the tag is in the main body of the JSP > everything works as it should. > > - Guess I better look harder at the tiles I use. > > Thanks Looking at this I haven't used the value='' attribute before. The Struts taglib API says ' Value to which this field should be initialized. [Use the corresponding bean property value] [RT Expr]' This sounds like it will try to access the method in the form bean to find the initial value. If your ${element.value} evaluates to "abc" then it will try to do a Form.getAbc() for the initial value. I don't think that is what you want. I think you should be using this: and in the action that you call to get to this JSP page, you should be putting in the initial values. -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Map Backed Form/Tiles
Ray Madigan wrote: I have narrowed the problem down to: being in a tile. If the tag is in the main body of the JSP everything works as it should. - Guess I better look harder at the tiles I use. Thanks Looking at this I haven't used the value='' attribute before. The Struts taglib API says ' Value to which this field should be initialized. [Use the corresponding bean property value] [RT Expr]' This sounds like it will try to access the method in the form bean to find the initial value. If your ${element.value} evaluates to "abc" then it will try to do a Form.getAbc() for the initial value. I don't think that is what you want. I think you should be using this: and in the action that you call to get to this JSP page, you should be putting in the initial values. -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Map Backed Form/Tiles
I have narrowed the problem down to: being in a tile. If the tag is in the main body of the JSP everything works as it should. - Guess I better look harder at the tiles I use. Thanks -Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of Navneet Karnani Sent: Thursday, September 18, 2003 10:34 PM To: [EMAIL PROTECTED] Subject: Re: Map Backed Form I suggest that you look at the code once more. There is a possibility that the error is not due to the problem that you see but something else. And i'm nearly sure that the problem is not as complex as it seems. If you want, I can look at the sources and test a fix at my side. Let me know. - Navneet Karnani Umber Business Solutions Pvt. Ltd. Ray Madigan said the following on 19/09/2003 3:15 AM: > I tried this - same result? h > > -Original Message- > From: Jason Lea [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 18, 2003 2:18 PM > To: Struts Users Mailing List > Subject: Re: Map Backed Form > > > I read this somewhere (perhaps Struts in Action) and I use map-backed > properties... the methods should have String keys, but Object values eg > > public Object getElementMap ( String key ) { > public void setElementMap ( String key, Object value ) > > > Ray Madigan wrote: > > >>I am having some difficulty with my Map Backed Form implementation. >> >>I have in my Form: >> >>private Properties elementMap = null; >> >>public String getElementMap ( String key ) { >>return ( String ) elementMap.getProperty ( key ); >>} >> >>public void setElementMap ( String key, String value ) { >>elementMap.put ( key, value ); >>} >> >>public void reset ( ActionMapping mapping, HttpServletRequest request ) { >>... >>elementMap = new Properties ( ); >>} >> >>I have in my JSP: >> >>>value='${element.value}'/> >> >>If I enumerate the request parameters in the reset method of the form >>the paramaters and values look like: >> >>name->elementMap(PerPage) >>value->4 >> >>I get the exception >>java.lang.IllegalAccessError: try to access class >>org.apache.commons.beanutils.MappedPropertyDescriptor$1 from class >>org.apache.commons.beanutils.MappedPropertyDescriptor >> >>>From past experience I get this exception when struts is looking for a >>setter >>in my form and can't find it. I think that struts is looking for a method >>'setElementMap(perPage)' and has not figured out it is a mapped property >>for some reason. And I can't write a method with name. >> >>Any help would be appreciated. >> >>Thanks >> >> >>- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > > -- > Jason Lea > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Map Backed Form
I suggest that you look at the code once more. There is a possibility that the error is not due to the problem that you see but something else. And i'm nearly sure that the problem is not as complex as it seems. If you want, I can look at the sources and test a fix at my side. Let me know. - Navneet Karnani Umber Business Solutions Pvt. Ltd. Ray Madigan said the following on 19/09/2003 3:15 AM: I tried this - same result? h -Original Message- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Thursday, September 18, 2003 2:18 PM To: Struts Users Mailing List Subject: Re: Map Backed Form I read this somewhere (perhaps Struts in Action) and I use map-backed properties... the methods should have String keys, but Object values eg public Object getElementMap ( String key ) { public void setElementMap ( String key, Object value ) Ray Madigan wrote: I am having some difficulty with my Map Backed Form implementation. I have in my Form: private Properties elementMap = null; public String getElementMap ( String key ) { return ( String ) elementMap.getProperty ( key ); } public void setElementMap ( String key, String value ) { elementMap.put ( key, value ); } public void reset ( ActionMapping mapping, HttpServletRequest request ) { ... elementMap = new Properties ( ); } I have in my JSP: If I enumerate the request parameters in the reset method of the form the paramaters and values look like: name->elementMap(PerPage) value->4 I get the exception java.lang.IllegalAccessError: try to access class org.apache.commons.beanutils.MappedPropertyDescriptor$1 from class org.apache.commons.beanutils.MappedPropertyDescriptor From past experience I get this exception when struts is looking for a setter in my form and can't find it. I think that struts is looking for a method 'setElementMap(perPage)' and has not figured out it is a mapped property for some reason. And I can't write a method with name. Any help would be appreciated. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Map Backed Form
You don't have any other setElementMap() methods in there do you? eg public void setElementMap(String key, Object value) public void setElementMap(String key, String value) There should only be 1. Ray Madigan wrote: Jason - thanks for your help. I do appreciate it. This code worked in 1.1 beta and I haven't had a chance to look at it since then. I have found that the exception I am getting is caused by Struts via BeanUtils attempting to access a setter on a bean when the setter method doesn't exist. I added to the line: private Properties elementMap = new Properties(); I rechecked the name of the methods and the name in the jsp. I remember once I had a space between the ( and the parameter and the parser couldn't find the parameter. This page lives in a set of pages that all use the same formBean it is the only page that uses the map. Also the html text control code lives in a tile. The tile declares itself a form and uses the correct form. I'll have to dig in the source I guess. -Original Message- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Thursday, September 18, 2003 3:29 PM To: Struts Users Mailing List Subject: Re: Map Backed Form Perhaps you need to step through the struts-config to make sure you are referencing the correct form bean. Do you access the .jsp page directly or go through an action first? I would also look at your initialisation of the elementMap. Perhaps you should be using private Properties elementMap = new Properties(); and in your reset method: elementMap.clear() to make sure it is initialised at first use. If you accessed the .jsp directly I don't think the reset method is called, but the bean is created. Ray Madigan wrote: I tried this - same result? h -Original Message- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Thursday, September 18, 2003 2:18 PM To: Struts Users Mailing List Subject: Re: Map Backed Form I read this somewhere (perhaps Struts in Action) and I use map-backed properties... the methods should have String keys, but Object values eg public Object getElementMap ( String key ) { public void setElementMap ( String key, Object value ) Ray Madigan wrote: I am having some difficulty with my Map Backed Form implementation. I have in my Form: private Properties elementMap = null; public String getElementMap ( String key ) { return ( String ) elementMap.getProperty ( key ); } public void setElementMap ( String key, String value ) { elementMap.put ( key, value ); } public void reset ( ActionMapping mapping, HttpServletRequest request ) { ... elementMap = new Properties ( ); } I have in my JSP: If I enumerate the request parameters in the reset method of the form the paramaters and values look like: name->elementMap(PerPage) value->4 I get the exception java.lang.IllegalAccessError: try to access class org.apache.commons.beanutils.MappedPropertyDescriptor$1 from class org.apache.commons.beanutils.MappedPropertyDescriptor From past experience I get this exception when struts is looking for a setter in my form and can't find it. I think that struts is looking for a method 'setElementMap(perPage)' and has not figured out it is a mapped property for some reason. And I can't write a method with name. Any help would be appreciated. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Map Backed Form
Jason - thanks for your help. I do appreciate it. This code worked in 1.1 beta and I haven't had a chance to look at it since then. I have found that the exception I am getting is caused by Struts via BeanUtils attempting to access a setter on a bean when the setter method doesn't exist. I added to the line: private Properties elementMap = new Properties(); I rechecked the name of the methods and the name in the jsp. I remember once I had a space between the ( and the parameter and the parser couldn't find the parameter. This page lives in a set of pages that all use the same formBean it is the only page that uses the map. Also the html text control code lives in a tile. The tile declares itself a form and uses the correct form. I'll have to dig in the source I guess. -Original Message- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Thursday, September 18, 2003 3:29 PM To: Struts Users Mailing List Subject: Re: Map Backed Form Perhaps you need to step through the struts-config to make sure you are referencing the correct form bean. Do you access the .jsp page directly or go through an action first? I would also look at your initialisation of the elementMap. Perhaps you should be using private Properties elementMap = new Properties(); and in your reset method: elementMap.clear() to make sure it is initialised at first use. If you accessed the .jsp directly I don't think the reset method is called, but the bean is created. Ray Madigan wrote: > I tried this - same result? h > > -Original Message- > From: Jason Lea [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 18, 2003 2:18 PM > To: Struts Users Mailing List > Subject: Re: Map Backed Form > > > I read this somewhere (perhaps Struts in Action) and I use map-backed > properties... the methods should have String keys, but Object values eg > > public Object getElementMap ( String key ) { > public void setElementMap ( String key, Object value ) > > > Ray Madigan wrote: > > >>I am having some difficulty with my Map Backed Form implementation. >> >>I have in my Form: >> >>private Properties elementMap = null; >> >>public String getElementMap ( String key ) { >>return ( String ) elementMap.getProperty ( key ); >>} >> >>public void setElementMap ( String key, String value ) { >>elementMap.put ( key, value ); >>} >> >>public void reset ( ActionMapping mapping, HttpServletRequest request ) { >>... >>elementMap = new Properties ( ); >>} >> >>I have in my JSP: >> >>>value='${element.value}'/> >> >>If I enumerate the request parameters in the reset method of the form >>the paramaters and values look like: >> >>name->elementMap(PerPage) >>value->4 >> >>I get the exception >>java.lang.IllegalAccessError: try to access class >>org.apache.commons.beanutils.MappedPropertyDescriptor$1 from class >>org.apache.commons.beanutils.MappedPropertyDescriptor >> >>>From past experience I get this exception when struts is looking for a >>setter >>in my form and can't find it. I think that struts is looking for a method >>'setElementMap(perPage)' and has not figured out it is a mapped property >>for some reason. And I can't write a method with name. >> >>Any help would be appreciated. >> >>Thanks >> >> >>- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > > -- > Jason Lea > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Map Backed Form
Perhaps you need to step through the struts-config to make sure you are referencing the correct form bean. Do you access the .jsp page directly or go through an action first? I would also look at your initialisation of the elementMap. Perhaps you should be using private Properties elementMap = new Properties(); and in your reset method: elementMap.clear() to make sure it is initialised at first use. If you accessed the .jsp directly I don't think the reset method is called, but the bean is created. Ray Madigan wrote: I tried this - same result? h -Original Message- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Thursday, September 18, 2003 2:18 PM To: Struts Users Mailing List Subject: Re: Map Backed Form I read this somewhere (perhaps Struts in Action) and I use map-backed properties... the methods should have String keys, but Object values eg public Object getElementMap ( String key ) { public void setElementMap ( String key, Object value ) Ray Madigan wrote: I am having some difficulty with my Map Backed Form implementation. I have in my Form: private Properties elementMap = null; public String getElementMap ( String key ) { return ( String ) elementMap.getProperty ( key ); } public void setElementMap ( String key, String value ) { elementMap.put ( key, value ); } public void reset ( ActionMapping mapping, HttpServletRequest request ) { ... elementMap = new Properties ( ); } I have in my JSP: If I enumerate the request parameters in the reset method of the form the paramaters and values look like: name->elementMap(PerPage) value->4 I get the exception java.lang.IllegalAccessError: try to access class org.apache.commons.beanutils.MappedPropertyDescriptor$1 from class org.apache.commons.beanutils.MappedPropertyDescriptor From past experience I get this exception when struts is looking for a setter in my form and can't find it. I think that struts is looking for a method 'setElementMap(perPage)' and has not figured out it is a mapped property for some reason. And I can't write a method with name. Any help would be appreciated. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Map Backed Form
I tried this - same result? h -Original Message- From: Jason Lea [mailto:[EMAIL PROTECTED] Sent: Thursday, September 18, 2003 2:18 PM To: Struts Users Mailing List Subject: Re: Map Backed Form I read this somewhere (perhaps Struts in Action) and I use map-backed properties... the methods should have String keys, but Object values eg public Object getElementMap ( String key ) { public void setElementMap ( String key, Object value ) Ray Madigan wrote: > I am having some difficulty with my Map Backed Form implementation. > > I have in my Form: > > private Properties elementMap = null; > > public String getElementMap ( String key ) { > return ( String ) elementMap.getProperty ( key ); > } > > public void setElementMap ( String key, String value ) { > elementMap.put ( key, value ); > } > > public void reset ( ActionMapping mapping, HttpServletRequest request ) { > ... > elementMap = new Properties ( ); > } > > I have in my JSP: > > value='${element.value}'/> > > If I enumerate the request parameters in the reset method of the form > the paramaters and values look like: > > name->elementMap(PerPage) > value->4 > > I get the exception > java.lang.IllegalAccessError: try to access class > org.apache.commons.beanutils.MappedPropertyDescriptor$1 from class > org.apache.commons.beanutils.MappedPropertyDescriptor > >>From past experience I get this exception when struts is looking for a > setter > in my form and can't find it. I think that struts is looking for a method > 'setElementMap(perPage)' and has not figured out it is a mapped property > for some reason. And I can't write a method with name. > > Any help would be appreciated. > > Thanks > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Map Backed Form
I read this somewhere (perhaps Struts in Action) and I use map-backed properties... the methods should have String keys, but Object values eg public Object getElementMap ( String key ) { public void setElementMap ( String key, Object value ) Ray Madigan wrote: I am having some difficulty with my Map Backed Form implementation. I have in my Form: private Properties elementMap = null; public String getElementMap ( String key ) { return ( String ) elementMap.getProperty ( key ); } public void setElementMap ( String key, String value ) { elementMap.put ( key, value ); } public void reset ( ActionMapping mapping, HttpServletRequest request ) { ... elementMap = new Properties ( ); } I have in my JSP: If I enumerate the request parameters in the reset method of the form the paramaters and values look like: name->elementMap(PerPage) value->4 I get the exception java.lang.IllegalAccessError: try to access class org.apache.commons.beanutils.MappedPropertyDescriptor$1 from class org.apache.commons.beanutils.MappedPropertyDescriptor From past experience I get this exception when struts is looking for a setter in my form and can't find it. I think that struts is looking for a method 'setElementMap(perPage)' and has not figured out it is a mapped property for some reason. And I can't write a method with name. Any help would be appreciated. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jason Lea - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]