• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help :how to get value from logic:iterate

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Robert Smith
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Eric Fletcher
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Robert Smith
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much ! i learn a lot!
 
Eric Fletcher
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are very welcome, glad to help.
E
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But is also not working.
I got errors saying as follows...




What is the actual solution? Please help me.

 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just give the type in the bean:define tag

 
reply
    Bookmark Topic Watch Topic
  • New Topic