You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ravi_eze <ra...@yahoo.com> on 2008/01/23 05:53:31 UTC

Type converters: convertToString not called

hi,

We have Action class with Employee Object with setters and getters. The
Typeconverter was configured to be called when <EmployeeObject.empId> is
called by the jsp page. We found that convertFromString of type converter is
being called but convertToString is never called. Any idea why this is
happening? The details are as follows:

Type converter:
public class LongConverter extends StrutsTypeConverter {
	public Object convertFromString(Map context, String[] values, Class
toClass) {
         ... ....
	}
	public String convertToString(Map context, Object o) {
        ... ....
	}
}

in actionClass-conversion.properties located along with the class file in
the same package:
employee.empId=com.comp.util.converter.LongConverter

After some debugging we found that we need to add a new file:
Employee-conversion.properties in the same package of Employee class with
entries: 
empId=com.comp.util.converter.LongConverter

and only then the convertToString would be called. I think we should have
only one conversion.prop file instead of 2. Any ideas why this is happening
this way? or am i missing any thing? please help. 

cheers,
ravi
-- 
View this message in context: http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp15034925p15034925.html
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: Type converters: convertToString not called

Posted by ravi_eze <ra...@ivycomptech.com>.
one more thing, then when would this method be called?? sounds like
redundant.



ravi_eze wrote:
> 
> hi,
> 
> thanks for the reply. If the design had this behavior intended then
> probably we cannot do any thing.... but in that case i would not agree
> with the design. I read the post linked below and also the bug... but
> still unable to understand the reason behind for such a design. 
> 
> i think i will now have to redesign my application.
> 
> thanks for all your help
> 
> regards,
> ravi 
> 
> 
> jimski wrote:
>> 
>> Hi Ravi-
>> 
>> I think the problem here is how the struts2 tags were implemented.  As
>> far as I can see from the code base the type converter definition you're
>> referring to is used by the XWork API and not OGNL.  The XWork api is
>> used by the Struts Tags which have the option to call the converter or
>> not.  In the case of rendering content, the option chosen by the
>> designers is not to call the converter and call toString() instead. 
>> Check out this bug report https://issues.apache.org/struts/browse/WW-2047
>> for more details.
>> 
>> I asked a question about this:
>> (http://www.nabble.com/Struts-framework-design-question%3A-Type-Converters-and-Tags-to15019888.html) 
>> 
>> ...and it seems like a community generated patch is probably the only way
>> forward at this point.  I started looking into it, but my day job has
>> been way too busy to give me any time to actually code a patch.  There's
>> also a question on my part as to whether or not the patch would even be
>> accepted given that 2.0.6 supported type conversion at render time and
>> the core struts2 dev team has explicitly chosen to remove this feature
>> (as mentioned by Don Brown in the referenced bug report).  
>> 
>> 
>> ravi_eze wrote:
>>> 
>>> hi,
>>> 
>>> We have Action class with Employee Object with setters and getters. The
>>> Typeconverter was configured to be called when <EmployeeObject.empId> is
>>> called by the jsp page. We found that convertFromString of type
>>> converter is being called but convertToString is never called. Any idea
>>> why this is happening? The details are as follows:
>>> 
>>> Type converter:
>>> public class LongConverter extends StrutsTypeConverter {
>>> 	public Object convertFromString(Map context, String[] values, Class
>>> toClass) {
>>>          ... ....
>>> 	}
>>> 	public String convertToString(Map context, Object o) {
>>>         ... ....
>>> 	}
>>> }
>>> 
>>> in actionClass-conversion.properties located along with the class file
>>> in the same package:
>>> employee.empId=com.comp.util.converter.LongConverter
>>> 
>>> After some debugging we found that we need to add a new file:
>>> Employee-conversion.properties in the same package of Employee class
>>> with entries: 
>>> empId=com.comp.util.converter.LongConverter
>>> 
>>> and only then the convertToString would be called. I think we should
>>> have only one conversion.prop file instead of 2. Any ideas why this is
>>> happening this way? or am i missing any thing? please help. 
>>> 
>>> cheers,
>>> ravi
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp15034925p15203570.html
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: Type converters: convertToString not called

Posted by ravi_eze <ra...@ivycomptech.com>.
hi,

thanks for the reply. If the design had this behavior intended then probably
we cannot do any thing.... but in that case i would not agree with the
design. I read the post linked below and also the bug... but still unable to
understand the reason behind for such a design. 

i think i will now have to redesign my application.

thanks for all your help

regards,
ravi 


jimski wrote:
> 
> Hi Ravi-
> 
> I think the problem here is how the struts2 tags were implemented.  As far
> as I can see from the code base the type converter definition you're
> referring to is used by the XWork API and not OGNL.  The XWork api is used
> by the Struts Tags which have the option to call the converter or not.  In
> the case of rendering content, the option chosen by the designers is not
> to call the converter and call toString() instead.  Check out this bug
> report https://issues.apache.org/struts/browse/WW-2047 for more details.
> 
> I asked a question about this:
> (http://www.nabble.com/Struts-framework-design-question%3A-Type-Converters-and-Tags-to15019888.html) 
> 
> ...and it seems like a community generated patch is probably the only way
> forward at this point.  I started looking into it, but my day job has been
> way too busy to give me any time to actually code a patch.  There's also a
> question on my part as to whether or not the patch would even be accepted
> given that 2.0.6 supported type conversion at render time and the core
> struts2 dev team has explicitly chosen to remove this feature (as
> mentioned by Don Brown in the referenced bug report).  
> 
> 
> ravi_eze wrote:
>> 
>> hi,
>> 
>> We have Action class with Employee Object with setters and getters. The
>> Typeconverter was configured to be called when <EmployeeObject.empId> is
>> called by the jsp page. We found that convertFromString of type converter
>> is being called but convertToString is never called. Any idea why this is
>> happening? The details are as follows:
>> 
>> Type converter:
>> public class LongConverter extends StrutsTypeConverter {
>> 	public Object convertFromString(Map context, String[] values, Class
>> toClass) {
>>          ... ....
>> 	}
>> 	public String convertToString(Map context, Object o) {
>>         ... ....
>> 	}
>> }
>> 
>> in actionClass-conversion.properties located along with the class file in
>> the same package:
>> employee.empId=com.comp.util.converter.LongConverter
>> 
>> After some debugging we found that we need to add a new file:
>> Employee-conversion.properties in the same package of Employee class with
>> entries: 
>> empId=com.comp.util.converter.LongConverter
>> 
>> and only then the convertToString would be called. I think we should have
>> only one conversion.prop file instead of 2. Any ideas why this is
>> happening this way? or am i missing any thing? please help. 
>> 
>> cheers,
>> ravi
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp15034925p15203566.html
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: Type converters: convertToString not called

Posted by ravi_eze <ra...@ivycomptech.com>.
hi,

thanks for the reply. If the design had this behavior intended then probably
we cannot do any thing.... but in that case i would not agree with the
design. I read the post linked below and also the bug... but still unable to
understand the reason behind for such a design. 

i think i will now have to redesign my application.

thanks for all your help

regards,
ravi 


jimski wrote:
> 
> Hi Ravi-
> 
> I think the problem here is how the struts2 tags were implemented.  As far
> as I can see from the code base the type converter definition you're
> referring to is used by the XWork API and not OGNL.  The XWork api is used
> by the Struts Tags which have the option to call the converter or not.  In
> the case of rendering content, the option chosen by the designers is not
> to call the converter and call toString() instead.  Check out this bug
> report https://issues.apache.org/struts/browse/WW-2047 for more details.
> 
> I asked a question about this:
> (http://www.nabble.com/Struts-framework-design-question%3A-Type-Converters-and-Tags-to15019888.html) 
> 
> ...and it seems like a community generated patch is probably the only way
> forward at this point.  I started looking into it, but my day job has been
> way too busy to give me any time to actually code a patch.  There's also a
> question on my part as to whether or not the patch would even be accepted
> given that 2.0.6 supported type conversion at render time and the core
> struts2 dev team has explicitly chosen to remove this feature (as
> mentioned by Don Brown in the referenced bug report).  
> 
> 
> ravi_eze wrote:
>> 
>> hi,
>> 
>> We have Action class with Employee Object with setters and getters. The
>> Typeconverter was configured to be called when <EmployeeObject.empId> is
>> called by the jsp page. We found that convertFromString of type converter
>> is being called but convertToString is never called. Any idea why this is
>> happening? The details are as follows:
>> 
>> Type converter:
>> public class LongConverter extends StrutsTypeConverter {
>> 	public Object convertFromString(Map context, String[] values, Class
>> toClass) {
>>          ... ....
>> 	}
>> 	public String convertToString(Map context, Object o) {
>>         ... ....
>> 	}
>> }
>> 
>> in actionClass-conversion.properties located along with the class file in
>> the same package:
>> employee.empId=com.comp.util.converter.LongConverter
>> 
>> After some debugging we found that we need to add a new file:
>> Employee-conversion.properties in the same package of Employee class with
>> entries: 
>> empId=com.comp.util.converter.LongConverter
>> 
>> and only then the convertToString would be called. I think we should have
>> only one conversion.prop file instead of 2. Any ideas why this is
>> happening this way? or am i missing any thing? please help. 
>> 
>> cheers,
>> ravi
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp15034925p15203568.html
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: Type converters: convertToString not called

Posted by jimski <ji...@gmail.com>.
Hi Ravi-

I think the problem here is how the struts2 tags were implemented.  As far
as I can see from the code base the type converter definition you're
referring to is used by the XWork API and not OGNL.  The XWork api is used
by the Struts Tags which have the option to call the converter or not.  In
the case of rendering content, the option chosen by the designers is not to
call the converter and call toString() instead.  Check out this bug report
https://issues.apache.org/struts/browse/WW-2047 for more details.

I asked a question about this:
(http://www.nabble.com/Struts-framework-design-question%3A-Type-Converters-and-Tags-to15019888.html) 

...and it seems like a community generated patch is probably the only way
forward at this point.  I started looking into it, but my day job has been
way too busy to give me any time to actually code a patch.  There's also a
question on my part as to whether or not the patch would even be accepted
given that 2.0.6 supported type conversion at render time and the core
struts2 dev team has explicitly chosen to remove this feature (as mentioned
by Don Brown in the referenced bug report).  


ravi_eze wrote:
> 
> hi,
> 
> We have Action class with Employee Object with setters and getters. The
> Typeconverter was configured to be called when <EmployeeObject.empId> is
> called by the jsp page. We found that convertFromString of type converter
> is being called but convertToString is never called. Any idea why this is
> happening? The details are as follows:
> 
> Type converter:
> public class LongConverter extends StrutsTypeConverter {
> 	public Object convertFromString(Map context, String[] values, Class
> toClass) {
>          ... ....
> 	}
> 	public String convertToString(Map context, Object o) {
>         ... ....
> 	}
> }
> 
> in actionClass-conversion.properties located along with the class file in
> the same package:
> employee.empId=com.comp.util.converter.LongConverter
> 
> After some debugging we found that we need to add a new file:
> Employee-conversion.properties in the same package of Employee class with
> entries: 
> empId=com.comp.util.converter.LongConverter
> 
> and only then the convertToString would be called. I think we should have
> only one conversion.prop file instead of 2. Any ideas why this is
> happening this way? or am i missing any thing? please help. 
> 
> cheers,
> ravi
> 

-- 
View this message in context: http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp15034925p15140174.html
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: Type converters: please help!!! :(

Posted by ravi_eze <ra...@ivycomptech.com>.
team any help??? 

:(


ravi_eze wrote:
> 
> hi,
> The code is as follows. Do not get terrified by the length of the post. I
> tried formatting the post for better readability. Hope this helps you...
> to help me ;)
> 
> @new.xml, this is included in struts.xml
> <struts>
> 	<package name="newsCreation" namespace="/new"
> 		extends="struts-default">
> 
> 		<action name="configurenew"
> 			class="com.comp.admin.news.newConfigurationAction"
> 			method="viewnew">
> 			<interceptor-ref name="scope">
> 				< param name="session">
> 					newData,disableFields
> 				< /param>
> 			</interceptor-ref>
> 			<interceptor-ref name="conversionError" />
> 			<interceptor-ref name="params" />
> 			<result>/new/layout/newConfiguration_layout.jsp</result>
> 			<result name="input">
> 				/new/layout/new_layout.jsp
> 			</result>
> 		</action>
> 
> @com\comp\admin\news\newConfigurationAction-conversion.properties
> newData.maxLimit=com.comp.util.converter.newLongConverter
> ...
> 
> @com.comp.util.converter.newLongConverter
> public class newLongConverter extends StrutsTypeConverter {
> 
> 	public Object convertFromString(Map context, String[] values, Class
> toClass) {
> 		if (null == values || values.length == 0 || values[0]==null ||
> values[0].trim().length()==0 )
> 			return 0;
> 		try {
> 			int i = Integer.parseInt(values[0]);
> 			return i;
> 		} catch (Exception ex) {}
> 		return 0; 
> 	}
> 	public String convertToString(Map context, Object obj) {
> 		if (null == obj)
> 			return "0";
> 		if(obj instanceof Long)
> 			return ((Long)obj).longValue()+""; 
> 		return "";
> 	}
> }
> 
> 
> 
> 
> mgainty wrote:
>> 
>> Hi Ravi-
>> 
>> Could you display your code for your StrutsTypeConverter class please
>> 
>> M-
>> ----- Original Message -----
>> From: "ravi_eze" <ra...@ivycomptech.com>
>> To: <us...@struts.apache.org>
>> Sent: Friday, January 25, 2008 12:58 AM
>> Subject: RE: Type converters: please help!!! :(
>> 
>> 
>>>
>>> Thank you Jeff for the reply.
>>>
>>> did u mean the *converter* attribute of the action tag that we give in
>>> struts.xml? I didnt give any such attribute in it. I added
>>> ActionClass-conversion.properties: in which i mentioned the attribute to
>>> pickup a class which implements convertFromString and viceversa
>>> functions.
>>>
>>> My action tag in the xml are as follows:
>>>
>>> <struts>
>>> <package name="eventsCreation" namespace="/event"
>>> extends="struts-default">
>>>
>>> <interceptors>
>>> <interceptor name="..." class="..." />
>>> <interceptor name="..." class="..." />
>>> </interceptors>
>>>
>>> <action name="oneAct" class="oneClass">
>>> <interceptor-ref name="...">
>>> ...
>>> </interceptor-ref>
>>> <result>one.jsp</result>
>>> </action>
>>> ...
>>>
>>> let me know if you are looking for anything else.
>>>
>>> cheers,
>>> ravi
>>>
>>>
>>> Jeff Hill (RR) wrote:
>>> >
>>> > Ravi,
>>> > From my understanding of OGNL, it *should* use the model object's
>>> > conversion
>>> > descriptor. It's probably more surprising that it called
>> convertFromString
>>> > without it. Are you using defaultStack?
>>> >
>>> > I believe providing the model object's descriptor is the correct
>> approach,
>>> > and you indicate that it's working. So why the long face? ;-)
>>> >
>>> > -----Original Message-----
>>> > From: ravi_eze [mailto:ravichandrac@ivycomptech.com]
>>> > Sent: Thursday, January 24, 2008 11:45 PM
>>> > To: user@struts.apache.org
>>> > Subject: Type converters: please help!!! :(
>>> >
>>> >
>>> > hi,
>>> >
>>> > i badly need the solution to this problem. i had posted this issue on
>>> > xwork
>>> > forums, struts fourms previously also, but hardluck: no reply :(
>>> >
>>> > i am reposting the same again... atleast let me know if this idea
>>> itself
>>> > is
>>> > wrong!!! or any better approach/ is there?
>>> >
>>> >
>>> > ravi_eze wrote:
>>> >>
>>> >> hi,
>>> >>
>>> >> We have Action class with Employee Object with setters and getters.
>>> The
>>> >> Typeconverter was configured to be called when <EmployeeObject.empId>
>> is
>>> >> called by the jsp page. We found that convertFromString of type
>> converter
>>> >> is being called but convertToString is never called. Any idea why
>>> this
>> is
>>> >> happening? The details are as follows:
>>> >>
>>> >> Type converter:
>>> >> public class LongConverter extends StrutsTypeConverter {
>>> >> public Object convertFromString(Map context, String[] values, Class
>>> >> toClass) {
>>> >>          ... ....
>>> >> }
>>> >> public String convertToString(Map context, Object o) {
>>> >>         ... ....
>>> >> }
>>> >> }
>>> >>
>>> >> in actionClass-conversion.properties located along with the class
>>> file
>> in
>>> >> the same package:
>>> >> employee.empId=com.comp.util.converter.LongConverter
>>> >>
>>> >> After some debugging we found that we need to add a new file:
>>> >> Employee-conversion.properties in the same package of Employee class
>> with
>>> >> entries:
>>> >> empId=com.comp.util.converter.LongConverter
>>> >>
>>> >> and only then the convertToString would be called. I think we should
>> have
>>> >> only one conversion.prop file instead of 2. Any ideas why this is
>>> >> happening this way? or am i missing any thing? please help.
>>> >>
>>> >> cheers,
>>> >> ravi
>>> >>
>>> >
>>> > --
>>> > View this message in context:
>>> >
>> http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp150349
>>> > 25p15080943.html
>>> > 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
>>> >
>>> >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> > For additional commands, e-mail: user-help@struts.apache.org
>>> >
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>> http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp150349
>> 25p15081469.html
>>> 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
>>>
>>>
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp15034925p15152856.html
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: Type converters: please help!!! :(

Posted by ravi_eze <ra...@ivycomptech.com>.
any help?

had any one encountered a similar situation.

i am pasting thelink straight to the problem so that u need not navigate
throught the discussion threads to locate it.

http://www.nabble.com/Type-converters%3A-convertToString-not-called-to15034925.html

any help would be great. 

regards,
ravi 

ravi_eze wrote:
> 
> hi,
> The code is as follows. Do not get terrified by the length of the post. I
> tried formatting the post for better readability. Hope this helps you...
> to help me ;)
> 
> @new.xml, this is included in struts.xml
> <struts>
> 	<package name="newsCreation" namespace="/new"
> 		extends="struts-default">
> 
> 		<action name="configurenew"
> 			class="com.comp.admin.news.newConfigurationAction"
> 			method="viewnew">
> 			<interceptor-ref name="scope">
> 				< param name="session">
> 					newData,disableFields
> 				< /param>
> 			</interceptor-ref>
> 			<interceptor-ref name="conversionError" />
> 			<interceptor-ref name="params" />
> 			<result>/new/layout/newConfiguration_layout.jsp</result>
> 			<result name="input">
> 				/new/layout/new_layout.jsp
> 			</result>
> 		</action>
> 
> @com\comp\admin\news\newConfigurationAction-conversion.properties
> newData.maxLimit=com.comp.util.converter.newLongConverter
> ...
> 
> @com.comp.util.converter.newLongConverter
> public class newLongConverter extends StrutsTypeConverter {
> 
> 	public Object convertFromString(Map context, String[] values, Class
> toClass) {
> 		if (null == values || values.length == 0 || values[0]==null ||
> values[0].trim().length()==0 )
> 			return 0;
> 		try {
> 			int i = Integer.parseInt(values[0]);
> 			return i;
> 		} catch (Exception ex) {}
> 		return 0; 
> 	}
> 	public String convertToString(Map context, Object obj) {
> 		if (null == obj)
> 			return "0";
> 		if(obj instanceof Long)
> 			return ((Long)obj).longValue()+""; 
> 		return "";
> 	}
> }
> 
> 
> 
> 
> mgainty wrote:
>> 
>> Hi Ravi-
>> 
>> Could you display your code for your StrutsTypeConverter class please
>> 
>> M-
>> ----- Original Message -----
>> From: "ravi_eze" <ra...@ivycomptech.com>
>> To: <us...@struts.apache.org>
>> Sent: Friday, January 25, 2008 12:58 AM
>> Subject: RE: Type converters: please help!!! :(
>> 
>> 
>>>
>>> Thank you Jeff for the reply.
>>>
>>> did u mean the *converter* attribute of the action tag that we give in
>>> struts.xml? I didnt give any such attribute in it. I added
>>> ActionClass-conversion.properties: in which i mentioned the attribute to
>>> pickup a class which implements convertFromString and viceversa
>>> functions.
>>>
>>> My action tag in the xml are as follows:
>>>
>>> <struts>
>>> <package name="eventsCreation" namespace="/event"
>>> extends="struts-default">
>>>
>>> <interceptors>
>>> <interceptor name="..." class="..." />
>>> <interceptor name="..." class="..." />
>>> </interceptors>
>>>
>>> <action name="oneAct" class="oneClass">
>>> <interceptor-ref name="...">
>>> ...
>>> </interceptor-ref>
>>> <result>one.jsp</result>
>>> </action>
>>> ...
>>>
>>> let me know if you are looking for anything else.
>>>
>>> cheers,
>>> ravi
>>>
>>>
>>> Jeff Hill (RR) wrote:
>>> >
>>> > Ravi,
>>> > From my understanding of OGNL, it *should* use the model object's
>>> > conversion
>>> > descriptor. It's probably more surprising that it called
>> convertFromString
>>> > without it. Are you using defaultStack?
>>> >
>>> > I believe providing the model object's descriptor is the correct
>> approach,
>>> > and you indicate that it's working. So why the long face? ;-)
>>> >
>>> > -----Original Message-----
>>> > From: ravi_eze [mailto:ravichandrac@ivycomptech.com]
>>> > Sent: Thursday, January 24, 2008 11:45 PM
>>> > To: user@struts.apache.org
>>> > Subject: Type converters: please help!!! :(
>>> >
>>> >
>>> > hi,
>>> >
>>> > i badly need the solution to this problem. i had posted this issue on
>>> > xwork
>>> > forums, struts fourms previously also, but hardluck: no reply :(
>>> >
>>> > i am reposting the same again... atleast let me know if this idea
>>> itself
>>> > is
>>> > wrong!!! or any better approach/ is there?
>>> >
>>> >
>>> > ravi_eze wrote:
>>> >>
>>> >> hi,
>>> >>
>>> >> We have Action class with Employee Object with setters and getters.
>>> The
>>> >> Typeconverter was configured to be called when <EmployeeObject.empId>
>> is
>>> >> called by the jsp page. We found that convertFromString of type
>> converter
>>> >> is being called but convertToString is never called. Any idea why
>>> this
>> is
>>> >> happening? The details are as follows:
>>> >>
>>> >> Type converter:
>>> >> public class LongConverter extends StrutsTypeConverter {
>>> >> public Object convertFromString(Map context, String[] values, Class
>>> >> toClass) {
>>> >>          ... ....
>>> >> }
>>> >> public String convertToString(Map context, Object o) {
>>> >>         ... ....
>>> >> }
>>> >> }
>>> >>
>>> >> in actionClass-conversion.properties located along with the class
>>> file
>> in
>>> >> the same package:
>>> >> employee.empId=com.comp.util.converter.LongConverter
>>> >>
>>> >> After some debugging we found that we need to add a new file:
>>> >> Employee-conversion.properties in the same package of Employee class
>> with
>>> >> entries:
>>> >> empId=com.comp.util.converter.LongConverter
>>> >>
>>> >> and only then the convertToString would be called. I think we should
>> have
>>> >> only one conversion.prop file instead of 2. Any ideas why this is
>>> >> happening this way? or am i missing any thing? please help.
>>> >>
>>> >> cheers,
>>> >> ravi
>>> >>
>>> >
>>> > --
>>> > View this message in context:
>>> >
>> http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp150349
>>> > 25p15080943.html
>>> > 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
>>> >
>>> >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> > For additional commands, e-mail: user-help@struts.apache.org
>>> >
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>> http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp150349
>> 25p15081469.html
>>> 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
>>>
>>>
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp15034925p15203559.html
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: Type converters: please help!!! :(

Posted by Dave Newton <ne...@yahoo.com>.
--- ravi_eze <ra...@ivycomptech.com> wrote:
> public class newLongConverter extends StrutsTypeConverter {
> 	public Object convertFromString(Map context, String[] values, Class
> toClass) {
> 		if (null == values || values.length == 0 || values[0]==null ||
> values[0].trim().length()==0 )
> 			return 0;
> 		try {
> 			int i = Integer.parseInt(values[0]);

If it's a Long converter you might want to consider parsing a Long, not an
int.

That doesn't answer your question, but it still might be a good idea.

d.


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


Re: Type converters: please help!!! :(

Posted by ravi_eze <ra...@ivycomptech.com>.
hi,
The code is as follows. Do not get terrified by the length of the post. I
tried formatting the post for better readability. Hope this helps you... to
help me ;)

@new.xml, this is included in struts.xml
<struts>
	<package name="newsCreation" namespace="/new"
		extends="struts-default">

		<action name="configurenew"
			class="com.comp.admin.news.newConfigurationAction"
			method="viewnew">
			<interceptor-ref name="scope">
				< param name="session">
					newData,disableFields
				< /param>
			</interceptor-ref>
			<interceptor-ref name="conversionError" />
			<interceptor-ref name="params" />
			<result>/new/layout/newConfiguration_layout.jsp</result>
			<result name="input">
				/new/layout/new_layout.jsp
			</result>
		</action>

@com\comp\admin\news\newConfigurationAction-conversion.properties
newData.maxLimit=com.comp.util.converter.newLongConverter
...

@com.comp.util.converter.newLongConverter
public class newLongConverter extends StrutsTypeConverter {

	public Object convertFromString(Map context, String[] values, Class
toClass) {
		if (null == values || values.length == 0 || values[0]==null ||
values[0].trim().length()==0 )
			return 0;
		try {
			int i = Integer.parseInt(values[0]);
			return i;
		} catch (Exception ex) {}
		return 0; 
	}
	public String convertToString(Map context, Object obj) {
		if (null == obj)
			return "0";
		if(obj instanceof Long)
			return ((Long)obj).longValue()+""; 
		return "";
	}
}




mgainty wrote:
> 
> Hi Ravi-
> 
> Could you display your code for your StrutsTypeConverter class please
> 
> M-
> ----- Original Message -----
> From: "ravi_eze" <ra...@ivycomptech.com>
> To: <us...@struts.apache.org>
> Sent: Friday, January 25, 2008 12:58 AM
> Subject: RE: Type converters: please help!!! :(
> 
> 
>>
>> Thank you Jeff for the reply.
>>
>> did u mean the *converter* attribute of the action tag that we give in
>> struts.xml? I didnt give any such attribute in it. I added
>> ActionClass-conversion.properties: in which i mentioned the attribute to
>> pickup a class which implements convertFromString and viceversa
>> functions.
>>
>> My action tag in the xml are as follows:
>>
>> <struts>
>> <package name="eventsCreation" namespace="/event"
>> extends="struts-default">
>>
>> <interceptors>
>> <interceptor name="..." class="..." />
>> <interceptor name="..." class="..." />
>> </interceptors>
>>
>> <action name="oneAct" class="oneClass">
>> <interceptor-ref name="...">
>> ...
>> </interceptor-ref>
>> <result>one.jsp</result>
>> </action>
>> ...
>>
>> let me know if you are looking for anything else.
>>
>> cheers,
>> ravi
>>
>>
>> Jeff Hill (RR) wrote:
>> >
>> > Ravi,
>> > From my understanding of OGNL, it *should* use the model object's
>> > conversion
>> > descriptor. It's probably more surprising that it called
> convertFromString
>> > without it. Are you using defaultStack?
>> >
>> > I believe providing the model object's descriptor is the correct
> approach,
>> > and you indicate that it's working. So why the long face? ;-)
>> >
>> > -----Original Message-----
>> > From: ravi_eze [mailto:ravichandrac@ivycomptech.com]
>> > Sent: Thursday, January 24, 2008 11:45 PM
>> > To: user@struts.apache.org
>> > Subject: Type converters: please help!!! :(
>> >
>> >
>> > hi,
>> >
>> > i badly need the solution to this problem. i had posted this issue on
>> > xwork
>> > forums, struts fourms previously also, but hardluck: no reply :(
>> >
>> > i am reposting the same again... atleast let me know if this idea
>> itself
>> > is
>> > wrong!!! or any better approach/ is there?
>> >
>> >
>> > ravi_eze wrote:
>> >>
>> >> hi,
>> >>
>> >> We have Action class with Employee Object with setters and getters.
>> The
>> >> Typeconverter was configured to be called when <EmployeeObject.empId>
> is
>> >> called by the jsp page. We found that convertFromString of type
> converter
>> >> is being called but convertToString is never called. Any idea why this
> is
>> >> happening? The details are as follows:
>> >>
>> >> Type converter:
>> >> public class LongConverter extends StrutsTypeConverter {
>> >> public Object convertFromString(Map context, String[] values, Class
>> >> toClass) {
>> >>          ... ....
>> >> }
>> >> public String convertToString(Map context, Object o) {
>> >>         ... ....
>> >> }
>> >> }
>> >>
>> >> in actionClass-conversion.properties located along with the class file
> in
>> >> the same package:
>> >> employee.empId=com.comp.util.converter.LongConverter
>> >>
>> >> After some debugging we found that we need to add a new file:
>> >> Employee-conversion.properties in the same package of Employee class
> with
>> >> entries:
>> >> empId=com.comp.util.converter.LongConverter
>> >>
>> >> and only then the convertToString would be called. I think we should
> have
>> >> only one conversion.prop file instead of 2. Any ideas why this is
>> >> happening this way? or am i missing any thing? please help.
>> >>
>> >> cheers,
>> >> ravi
>> >>
>> >
>> > --
>> > View this message in context:
>> >
> http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp150349
>> > 25p15080943.html
>> > 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
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > For additional commands, e-mail: user-help@struts.apache.org
>> >
>> >
>> >
>>
>> --
>> View this message in context:
> http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp150349
> 25p15081469.html
>> 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
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp15034925p15128562.html
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: Type converters: please help!!! :(

Posted by Martin Gainty <mg...@hotmail.com>.
Hi Ravi-

Could you display your code for your StrutsTypeConverter class please

M-
----- Original Message -----
From: "ravi_eze" <ra...@ivycomptech.com>
To: <us...@struts.apache.org>
Sent: Friday, January 25, 2008 12:58 AM
Subject: RE: Type converters: please help!!! :(


>
> Thank you Jeff for the reply.
>
> did u mean the *converter* attribute of the action tag that we give in
> struts.xml? I didnt give any such attribute in it. I added
> ActionClass-conversion.properties: in which i mentioned the attribute to
> pickup a class which implements convertFromString and viceversa functions.
>
> My action tag in the xml are as follows:
>
> <struts>
> <package name="eventsCreation" namespace="/event"
> extends="struts-default">
>
> <interceptors>
> <interceptor name="..." class="..." />
> <interceptor name="..." class="..." />
> </interceptors>
>
> <action name="oneAct" class="oneClass">
> <interceptor-ref name="...">
> ...
> </interceptor-ref>
> <result>one.jsp</result>
> </action>
> ...
>
> let me know if you are looking for anything else.
>
> cheers,
> ravi
>
>
> Jeff Hill (RR) wrote:
> >
> > Ravi,
> > From my understanding of OGNL, it *should* use the model object's
> > conversion
> > descriptor. It's probably more surprising that it called
convertFromString
> > without it. Are you using defaultStack?
> >
> > I believe providing the model object's descriptor is the correct
approach,
> > and you indicate that it's working. So why the long face? ;-)
> >
> > -----Original Message-----
> > From: ravi_eze [mailto:ravichandrac@ivycomptech.com]
> > Sent: Thursday, January 24, 2008 11:45 PM
> > To: user@struts.apache.org
> > Subject: Type converters: please help!!! :(
> >
> >
> > hi,
> >
> > i badly need the solution to this problem. i had posted this issue on
> > xwork
> > forums, struts fourms previously also, but hardluck: no reply :(
> >
> > i am reposting the same again... atleast let me know if this idea itself
> > is
> > wrong!!! or any better approach/ is there?
> >
> >
> > ravi_eze wrote:
> >>
> >> hi,
> >>
> >> We have Action class with Employee Object with setters and getters. The
> >> Typeconverter was configured to be called when <EmployeeObject.empId>
is
> >> called by the jsp page. We found that convertFromString of type
converter
> >> is being called but convertToString is never called. Any idea why this
is
> >> happening? The details are as follows:
> >>
> >> Type converter:
> >> public class LongConverter extends StrutsTypeConverter {
> >> public Object convertFromString(Map context, String[] values, Class
> >> toClass) {
> >>          ... ....
> >> }
> >> public String convertToString(Map context, Object o) {
> >>         ... ....
> >> }
> >> }
> >>
> >> in actionClass-conversion.properties located along with the class file
in
> >> the same package:
> >> employee.empId=com.comp.util.converter.LongConverter
> >>
> >> After some debugging we found that we need to add a new file:
> >> Employee-conversion.properties in the same package of Employee class
with
> >> entries:
> >> empId=com.comp.util.converter.LongConverter
> >>
> >> and only then the convertToString would be called. I think we should
have
> >> only one conversion.prop file instead of 2. Any ideas why this is
> >> happening this way? or am i missing any thing? please help.
> >>
> >> cheers,
> >> ravi
> >>
> >
> > --
> > View this message in context:
> >
http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp150349
> > 25p15080943.html
> > 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
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
>
> --
> View this message in context:
http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp150349
25p15081469.html
> 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
>
>


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


RE: Type converters: please help!!! :(

Posted by ravi_eze <ra...@ivycomptech.com>.
Thank you Jeff for the reply.

did u mean the *converter* attribute of the action tag that we give in
struts.xml? I didnt give any such attribute in it. I added
ActionClass-conversion.properties: in which i mentioned the attribute to
pickup a class which implements convertFromString and viceversa functions.

My action tag in the xml are as follows:

<struts>
	<package name="eventsCreation" namespace="/event"
		extends="struts-default">

		<interceptors>
			<interceptor name="..."	class="..." />
			<interceptor name="..."	class="..." />
		</interceptors>

		<action name="oneAct"	class="oneClass">
			<interceptor-ref name="...">
				...
			</interceptor-ref>
			<result>one.jsp</result>
		</action>
...

let me know if you are looking for anything else.

cheers,
ravi 


Jeff Hill (RR) wrote:
> 
> Ravi,
> From my understanding of OGNL, it *should* use the model object's
> conversion
> descriptor. It's probably more surprising that it called convertFromString
> without it. Are you using defaultStack?
> 
> I believe providing the model object's descriptor is the correct approach,
> and you indicate that it's working. So why the long face? ;-)
> 
> -----Original Message-----
> From: ravi_eze [mailto:ravichandrac@ivycomptech.com] 
> Sent: Thursday, January 24, 2008 11:45 PM
> To: user@struts.apache.org
> Subject: Type converters: please help!!! :(
> 
> 
> hi,
> 
> i badly need the solution to this problem. i had posted this issue on
> xwork
> forums, struts fourms previously also, but hardluck: no reply :(
> 
> i am reposting the same again... atleast let me know if this idea itself
> is
> wrong!!! or any better approach/ is there?  
> 
> 
> ravi_eze wrote:
>> 
>> hi,
>> 
>> We have Action class with Employee Object with setters and getters. The
>> Typeconverter was configured to be called when <EmployeeObject.empId> is
>> called by the jsp page. We found that convertFromString of type converter
>> is being called but convertToString is never called. Any idea why this is
>> happening? The details are as follows:
>> 
>> Type converter:
>> public class LongConverter extends StrutsTypeConverter {
>> 	public Object convertFromString(Map context, String[] values, Class
>> toClass) {
>>          ... ....
>> 	}
>> 	public String convertToString(Map context, Object o) {
>>         ... ....
>> 	}
>> }
>> 
>> in actionClass-conversion.properties located along with the class file in
>> the same package:
>> employee.empId=com.comp.util.converter.LongConverter
>> 
>> After some debugging we found that we need to add a new file:
>> Employee-conversion.properties in the same package of Employee class with
>> entries: 
>> empId=com.comp.util.converter.LongConverter
>> 
>> and only then the convertToString would be called. I think we should have
>> only one conversion.prop file instead of 2. Any ideas why this is
>> happening this way? or am i missing any thing? please help. 
>> 
>> cheers,
>> ravi
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp150349
> 25p15080943.html
> 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
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp15034925p15081469.html
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: Type converters: please help!!! :(

Posted by "Jeff Hill (RR)" <dj...@tampabay.rr.com>.
Ravi,
>From my understanding of OGNL, it *should* use the model object's conversion
descriptor. It's probably more surprising that it called convertFromString
without it. Are you using defaultStack?

I believe providing the model object's descriptor is the correct approach,
and you indicate that it's working. So why the long face? ;-)

-----Original Message-----
From: ravi_eze [mailto:ravichandrac@ivycomptech.com] 
Sent: Thursday, January 24, 2008 11:45 PM
To: user@struts.apache.org
Subject: Type converters: please help!!! :(


hi,

i badly need the solution to this problem. i had posted this issue on xwork
forums, struts fourms previously also, but hardluck: no reply :(

i am reposting the same again... atleast let me know if this idea itself is
wrong!!! or any better approach/ is there?  


ravi_eze wrote:
> 
> hi,
> 
> We have Action class with Employee Object with setters and getters. The
> Typeconverter was configured to be called when <EmployeeObject.empId> is
> called by the jsp page. We found that convertFromString of type converter
> is being called but convertToString is never called. Any idea why this is
> happening? The details are as follows:
> 
> Type converter:
> public class LongConverter extends StrutsTypeConverter {
> 	public Object convertFromString(Map context, String[] values, Class
> toClass) {
>          ... ....
> 	}
> 	public String convertToString(Map context, Object o) {
>         ... ....
> 	}
> }
> 
> in actionClass-conversion.properties located along with the class file in
> the same package:
> employee.empId=com.comp.util.converter.LongConverter
> 
> After some debugging we found that we need to add a new file:
> Employee-conversion.properties in the same package of Employee class with
> entries: 
> empId=com.comp.util.converter.LongConverter
> 
> and only then the convertToString would be called. I think we should have
> only one conversion.prop file instead of 2. Any ideas why this is
> happening this way? or am i missing any thing? please help. 
> 
> cheers,
> ravi
> 

-- 
View this message in context:
http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp150349
25p15080943.html
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



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


Type converters: please help!!! :(

Posted by ravi_eze <ra...@ivycomptech.com>.
hi,

i badly need the solution to this problem. i had posted this issue on xwork
forums, struts fourms previously also, but hardluck: no reply :(

i am reposting the same again... atleast let me know if this idea itself is
wrong!!! or any better approach/ is there?  


ravi_eze wrote:
> 
> hi,
> 
> We have Action class with Employee Object with setters and getters. The
> Typeconverter was configured to be called when <EmployeeObject.empId> is
> called by the jsp page. We found that convertFromString of type converter
> is being called but convertToString is never called. Any idea why this is
> happening? The details are as follows:
> 
> Type converter:
> public class LongConverter extends StrutsTypeConverter {
> 	public Object convertFromString(Map context, String[] values, Class
> toClass) {
>          ... ....
> 	}
> 	public String convertToString(Map context, Object o) {
>         ... ....
> 	}
> }
> 
> in actionClass-conversion.properties located along with the class file in
> the same package:
> employee.empId=com.comp.util.converter.LongConverter
> 
> After some debugging we found that we need to add a new file:
> Employee-conversion.properties in the same package of Employee class with
> entries: 
> empId=com.comp.util.converter.LongConverter
> 
> and only then the convertToString would be called. I think we should have
> only one conversion.prop file instead of 2. Any ideas why this is
> happening this way? or am i missing any thing? please help. 
> 
> cheers,
> ravi
> 

-- 
View this message in context: http://www.nabble.com/Type-converters%3A-convertToString-not-called-tp15034925p15080943.html
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