You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by sagarlotiya <sa...@aspl.in> on 2007/10/24 08:07:52 UTC

Invalid field value(due to type coversion) in Struts2

Hi Problem in Struts2.
I have problem when using OGNL to set the Object directly on Model.

For e.g.

<s:select name="courseImplementation.department"
list="listPropertySelectionModel.departmentListOfSchool" listValue="name" />

e.g. Final html which is rendered by struts2
<select name="courseImplementation.department"
id="_courseImplementation_department">
    <option value="Department#3/-970525270"
selected="selected">Dermetology</option>
    <option value="Department#4/-970525207">Orthopedic_dept</option>
    <option value="Department#5/-970525141">Art of Fashion</option>
    <option value="Department#6/-970524313">MBA</option>
</select>  

here i am trying to set the Object of "Department" directly on Model
"CourseImplementation's " setDepartment(Department department) method using
ognl : courseImplementation.department.
My listKey contains the Object of type Department.
When i am trying to save it gives me following error.

Error : Invalid field value for field "courseImplementation.department".

i know that this is error is due to incompatible type.
But what could be the solution?

Any reply is most welcomed.
I have spend a lot of time behined it.
Please reply
Thnak you

-- 
View this message in context: http://www.nabble.com/Invalid-field-value%28due-to-type-coversion%29-in-Struts2-tf4682207.html#a13379578
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Invalid field value(due to type coversion) in Struts2

Posted by Laurie Harper <la...@holoweb.net>.
sagarlotiya wrote:
> Hi Problem in Struts2.
> I have problem when using OGNL to set the Object directly on Model.
> 
> For e.g.
> 
> <s:select name="courseImplementation.department"
> list="listPropertySelectionModel.departmentListOfSchool" listValue="name" />
> 
> e.g. Final html which is rendered by struts2
> <select name="courseImplementation.department"
> id="_courseImplementation_department">
>     <option value="Department#3/-970525270"
> selected="selected">Dermetology</option>
>     <option value="Department#4/-970525207">Orthopedic_dept</option>
>     <option value="Department#5/-970525141">Art of Fashion</option>
>     <option value="Department#6/-970524313">MBA</option>
> </select>  
> 
> here i am trying to set the Object of "Department" directly on Model
> "CourseImplementation's " setDepartment(Department department) method using
> ognl : courseImplementation.department.
> My listKey contains the Object of type Department.
> When i am trying to save it gives me following error.
> 
> Error : Invalid field value for field "courseImplementation.department".
> 
> i know that this is error is due to incompatible type.
> But what could be the solution?

Struts has no way to map a value like 'Department#6/-970524313' to an
instance of some object. You will need to provide your own conversion
handler to do that. See here for more info:

http://struts.apache.org/2.x/docs/type-conversion.html

L.


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


Re: Invalid field value(due to type coversion) in Struts2

Posted by sagarlotiya <sa...@aspl.in>.


Laurie Harper wrote:
> 
> sagarlotiya wrote:
>> Hi Problem in Struts2.
>> I have problem when using OGNL to set the Object directly on Model.
>> 
>> For e.g.
>> 
>> <s:select name="courseImplementation.department"
>> list="listPropertySelectionModel.departmentListOfSchool" listValue="name"
>> />
>> 
>> e.g. Final html which is rendered by struts2
>> <select name="courseImplementation.department"
>> id="_courseImplementation_department">
>>     <option value="Department#3/-970525270"
>> selected="selected">Dermetology</option>
>>     <option value="Department#4/-970525207">Orthopedic_dept</option>
>>     <option value="Department#5/-970525141">Art of Fashion</option>
>>     <option value="Department#6/-970524313">MBA</option>
>> </select>  
>> 
>> here i am trying to set the Object of "Department" directly on Model
>> "CourseImplementation's " setDepartment(Department department) method
>> using
>> ognl : courseImplementation.department.
>> My listKey contains the Object of type Department.
>> When i am trying to save it gives me following error.
>> 
>> Error : Invalid field value for field "courseImplementation.department".
>> 
>> i know that this is error is due to incompatible type.
>> But what could be the solution?
> 
> Struts has no way to map a value like 'Department#6/-970524313' to an 
> instance of some object. You will need to provide your own conversion 
> handler to do that. See here for more info:
> 
> http://struts.apache.org/2.x/docs/type-conversion.html
> 
> L.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

Hi,
First thanks for the reply.
I have tried to used type conversion of struts2 and it works fine but still
one problem occurs.
In type conversion only The method
convertToObject works fine but reverse
convertToString don't work properly.
Means after savings the object when i will come back at that time struts2 to
throws exception due to object type.
It needs it to be string type.
I have tried to convert the Object to String from converToString method but
it didn't call by struts2 converter.
What could be the problem?
-- 
View this message in context: http://www.nabble.com/Invalid-field-value%28due-to-type-coversion%29-in-Struts2-tf4682207.html#a13461453
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Invalid field value(due to type coversion) in Struts2

Posted by Laurie Harper <la...@holoweb.net>.
sagarlotiya wrote:
> Hi Problem in Struts2.
> I have problem when using OGNL to set the Object directly on Model.
> 
> For e.g.
> 
> <s:select name="courseImplementation.department"
> list="listPropertySelectionModel.departmentListOfSchool" listValue="name" />
> 
> e.g. Final html which is rendered by struts2
> <select name="courseImplementation.department"
> id="_courseImplementation_department">
>     <option value="Department#3/-970525270"
> selected="selected">Dermetology</option>
>     <option value="Department#4/-970525207">Orthopedic_dept</option>
>     <option value="Department#5/-970525141">Art of Fashion</option>
>     <option value="Department#6/-970524313">MBA</option>
> </select>  
> 
> here i am trying to set the Object of "Department" directly on Model
> "CourseImplementation's " setDepartment(Department department) method using
> ognl : courseImplementation.department.
> My listKey contains the Object of type Department.
> When i am trying to save it gives me following error.
> 
> Error : Invalid field value for field "courseImplementation.department".
> 
> i know that this is error is due to incompatible type.
> But what could be the solution?

Struts has no way to map a value like 'Department#6/-970524313' to an 
instance of some object. You will need to provide your own conversion 
handler to do that. See here for more info:

http://struts.apache.org/2.x/docs/type-conversion.html

L.


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