Okay, I changed it back to settings[0] type syntax (I had tried it before and
it didn't work), so now I have this:

<s:iterator value="%{settings}" status="rowstatus">
                                                        <tr>
                                                                <th>
                                                                        <input 
name="settings[<s:property value="#rowstatus.index"
/>].title" value="<s:property value="title" />" type="hidden" />
                                                                        <label 
for="setting_<s:property value="id" />">
                                                                                
<s:property value="title" />:
                                                                        </label>
                                                                </th>
                                                                <td>            
                                                                        <input 
id="setting_<s:property value="id" />"
name="settings[<s:property value="#rowstatus.index" />].value"
value="<s:property value="value" />" />
                                                                </td>
                                                        </tr>
                                                </s:iterator>

And now I am getting this in the logs (repeated for each attribute id,
title, value):

ERROR com.opensymphony.xwork2.util.InstantiatingNullHandler  - Could not
create and/or set value back on to object
ognl.OgnlException: settings [java.lang.IllegalArgumentException: argument
type mismatch]
ERROR com.opensymphony.xwork2.interceptor.ParametersInterceptor  -
ParametersInterceptor - [setParameters]: Unexpected Exception caught setting
'settings[0].title' on 'class com.rjssoft.webdocs.admin.SettingAction: Error
setting expression 'settings[0].title' with value
'[Ljava.lang.String;@185fe0c'

So again, it's failing trying to set a String[] to a String value on the
Setting object which has all of the getters/setters and are defined to
handle String values.

Any insight? 

Ryan



dusty wrote:
> 
> your syntax for the field name should be 
> ...name = "settings[]"  rather than name = "settings()"
> 
> Also, I think your action expects to build a List of Settings rather than
> Map of settings.  If that is the case then you don't want to use key
> values in settings[ASDF1-123AS-123SA-123] you want to use an index for a
> List, settings[0]...  settings[1]..., etc.  You don't need the Key_xxx in
> -conversion.properties file if your target is a List.
> 
> I am wondering if you want struts to load your Settings models from the db
> based on the ID.  If that was the case then you would need to use an
> entirely different pattern with a custom TypeConverter...
> 
> 
> 
> ryangr wrote:
>> 
>> This is probably going to be a really simple solution, but after
>> searching I still haven't quite found an answer so I appreciate any help
>> with this. I'm using 2.0.14 and trying to do type conversion on a custom
>> collection (called "settings" in this case, it is just an extended
>> ArrayList). I'm getting the following in my logs:
>> 
>> Unexpected Exception caught setting
>> 'settings(D176A8AA-1636-4AFF-9C71-16A21DFCEDA7).id' on 'class
>> com.rjssoft.webdocs.admin.SettingAction: Error setting expression
>> 'settings(D176A8AA-1636-4AFF-9C71-16A21DFCEDA7).id' with value
>> '[Ljava.lang.String;@1f796d0'
>> 
>> Unexpected Exception caught setting
>> 'settings(D176A8AA-1636-4AFF-9C71-16A21DFCEDA7).title' on 'class
>> com.rjssoft.webdocs.admin.SettingAction: Error setting expression
>> 'settings(D176A8AA-1636-4AFF-9C71-16A21DFCEDA7).title' with value
>> '[Ljava.lang.String;@1ce64f6'
>> 
>> Unexpected Exception caught setting
>> 'settings(D176A8AA-1636-4AFF-9C71-16A21DFCEDA7).value' on 'class
>> com.rjssoft.webdocs.admin.SettingAction: Error setting expression
>> 'settings(D176A8AA-1636-4AFF-9C71-16A21DFCEDA7).value' with value
>> '[Ljava.lang.String;@6bba64'
>> 
>> Now, obviously it is trying to set a String[] to a String value and
>> failing; however, according to the "official" doc on type conversion
>> there is no additional processing. The form consists of:
>> 
>> ...
>> <s:iterator value="%{settings}">
>>      <tr>
>>      <th>
>>          <input name="settings(<s:property value="id" />).id"
>> value="<s:property value="id" />" type="hidden" />                           
>>                                 
>>          <input name="settings(<s:property value="id" />).title"
>> value="<s:property value="title" />" type="hidden" />
>>          <label for="setting_<s:property value="id" />">
>>              <s:property value="title" />:
>>          </label>
>>      </th>
>>              <td>            
>>          <input id="setting_<s:property value="id" />"
>> name="settings(<s:property value="id" />).value" value="<s:property
>> value="value" />" />
>>      </td>
>>      </tr>
>> </s:iterator>
>> 
>> The values that come through are:
>> Setting params settings(D176A8AA-1636-4AFF-9C71-16A21DFCEDA7).id => [
>> D176A8AA-1636-4AFF-9C71-16A21DFCEDA7 ]
>> settings(D176A8AA-1636-4AFF-9C71-16A21DFCEDA7).value => [ 192.168.1.1 ]
>> settings(D176A8AA-1636-4AFF-9C71-16A21DFCEDA7).title => [ SMTP Server
>> Address ] 
>> 
>> My SettingAction-conversion.properties has(Setting is just a custom bean
>> object with all id, title, and value along with all getters/setters):
>> KeyProperty_settings=id
>> Element_settings=Setting
>> 
>> I followed the examples so I'm not sure where it is going wrong...any
>> help?
>> 
>> Thanks!
>> Ryan
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Type-conversion-exceptions-tp22497261p22538757.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to