my jsp is : <logic:iterate id="xxx" name="abc" > <bean:write name="xxx" property="logname"/> <bean:write name="xxx" property="password"/> <bean:write name="xxx" property="phone"/> <bean:write name="xxx" property=""id/> </logic:iterate> how can i put the value of <bean:write name="xxx" property=""id/> to a variable! i try in this way : <% int t= <bean:write name="xxx" property=""id/>; %> but it is wrong! how can i do?
Not 100% certain, but I believe you can use the <bean:define> for that.
Then you can access the values as a page variable using, for example <%=idValue%> in your code, like in a request string: yourAction.do?id=<%=idValue%> or something along those lines. HTH, E [ October 15, 2003: Message edited by: Eric Fletcher ]
My theory of evolution is that Darwin was adopted. - Steven Wright
Joined: Oct 14, 2003
thank you! i learn this way! but i want to put a property of bean into a varible,for examples ,if a prperty of bean is a int variable ,can i write in this way: <bean efine id="dd" name="xxx" property="id" /> <% int i=dd ;%> or <% int i=dd.getId(); %> but it is all wrong! i don't understand the type of the "dd"(inside the example ),how can i do?
Joined: Oct 26, 2000
Hi skyspeed, glad I could help. When you use the <bean:define>, the bean defined by the tag has to be an object. Primitives like an int are wrapped with the appropriate wrapper class behind the scenes by the Struts framework. In your case, the framework assumes you have a method called getId() in class xxx(if you don't the tag will throw a JspException). Since the method returns an int property, the tag will define a bean of type Integer wrapping the retrieved value. <bean:define id="dd" name="xxx" property="id" /> So behind the scenes, Struts has created a page-scope bean of type Integer identified as "dd", so to get the actual wrapped int you would use: <% int i=dd.intValue();%> I believe that should work for you. Post again if you have any other questions or problems. Cheers, E