How to define an Integer bean in Struts 1.x

Posted by ian_scho_es on Stack Overflow See other posts from Stack Overflow or by ian_scho_es
Published on 2010-05-26T09:02:02Z Indexed on 2010/05/26 14:01 UTC
Read the original article Hit count: 456

Filed under:
|
|

Hi. How do you instantiate an Integer bean, assigning a value, in the Struts 1.x framework?

<bean:define id="index" type="java.lang.Integer" value="0"/>

or

<bean:define id="index" type="java.lang.Integer" value="${0}"/>

Results in a: java.lang.ClassCastException: java.lang.String

<bean:define id="index" type="java.lang.Integer" value="<%=0%>"/>

Results in: The method setValue(String) in the type DefineTag is not applicable for the arguments (int)

<% java.lang.Integer index = new java.lang.Integer(0); %>

Works, but makes my eyes bleed.

Note that I had to refactor iterating over a list but am now applying a filter within the iteration. This was the cleanest solution of all!

<logic:equal name="aplicacion" property="generico" value="false" indexId="index">

Maybe I need to go about this completely differently. Many thanks.

© Stack Overflow or respective owner

Related posts about struts

Related posts about define