You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Uwe <st...@ebers.de> on 2009/04/17 11:03:45 UTC

Convert a substring to integer

Hello Community,

I'm quite new to Struts2 (or even Struts anyhow) and I'm struggling with 
a Problem .

My multiline Form send's via  the validation the fieldError data as 
shown below to my jsp. Because I do have a multiline form my return of 
the Object key is something like:
myrecords[3].myfieldName. This information is not the best for my Users 
so I want to break it up in something like : At row 4 (because it starts 
counting 0) in Column MyFieldName is Error blablabla... Therefor I need 
to extract the index and the Fieldname. Well the problem is the index. 
As you can see in my example below I have extracted the index (in my 
example 3 ) from the Object key. And that works pretty fine. But, and 
now comes my Problem, it's still a String and I can't add the int 1 to 
it. I have tried several things in different combinations but nothing 
worked out.

<s:iterator value="fieldErrors" >
	<s:set name="r2" value="%{key.substring(key.indexOf('[')+1,key.indexOf(']'))}"/>
	<s:set name="r3" value="%{#r2.trim()}"/>  //howto convert r3 to a integer?
	<s:property value="r3"/><br>
</s:iterator>

Thanks for any help

Uwe






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


Re: Convert a substring to integer

Posted by Stefano Tranquillini <st...@gmail.com>.
I'm not sure that is a good solution but u can try to use simply jsp code
and bean:define

e.g (i don't know the right name of the struts tag)

<bean:define name="myvar>
<%=all the operation%>
</bean:define>

<s:set name="r2" value="${myvar}"/>

i don't really know it's works, but it'll be, i'm not so sure.

otherwise:
u want to display the error in the right place?
why u don't use a different error name for each fields?

(i don't remember well how to do this, but i guess that is possible, i'd
done in past).

bye

On Fri, Apr 17, 2009 at 11:03, Uwe <st...@ebers.de> wrote:

> Hello Community,
>
> I'm quite new to Struts2 (or even Struts anyhow) and I'm struggling with a
> Problem .
>
> My multiline Form send's via  the validation the fieldError data as shown
> below to my jsp. Because I do have a multiline form my return of the Object
> key is something like:
> myrecords[3].myfieldName. This information is not the best for my Users so
> I want to break it up in something like : At row 4 (because it starts
> counting 0) in Column MyFieldName is Error blablabla... Therefor I need to
> extract the index and the Fieldname. Well the problem is the index. As you
> can see in my example below I have extracted the index (in my example 3 )
> from the Object key. And that works pretty fine. But, and now comes my
> Problem, it's still a String and I can't add the int 1 to it. I have tried
> several things in different combinations but nothing worked out.
>
> <s:iterator value="fieldErrors" >
>        <s:set name="r2"
> value="%{key.substring(key.indexOf('[')+1,key.indexOf(']'))}"/>
>        <s:set name="r3" value="%{#r2.trim()}"/>  //howto convert r3 to a
> integer?
>        <s:property value="r3"/><br>
> </s:iterator>
>
> Thanks for any help
>
> Uwe
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Stefano