• 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

Treemap with logic iterator

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,

In my project, I am getting the data from database and keeping it in the proporties with name values pair and setting that in pricingWorksheetForm.setProductTree((TreeMap)getServlet().getServletContext().getAttribute("productTree"));

and iterating in jsp

<logic:iterate id="prodTree" name="pricingWorksheetForm" property="treeSet" type="java.util.Map.Entry">
<bean efine id="product" name="prodTree" property="value" type="java.util.Properties"/><TR id="<%=prodTree.getKey()%>">

Please some one explain the code defined in jsp.


with regards,
Bhargavi.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you asking? Does the code work? Does your form have a method named getTreeSet? I suspect that method returns "produceTree.values()".

- Brent
 
Ranch Hand
Posts: 341
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The <logic:iterate /> tag is used to iterate over a named collection�which contains a Collection, Enumerator,Iterator, Map, or Array�and evaluates its body for each Object in the collection.
The id attribut specifies a JSP scripting variable, exposed by the <logic: iterate /> tag, that will hold the current object in the named collection.This attribute is mandatory.
The name attribute specifies a scripting variable that represents the
collection to be iterated over. This attribute is optional.
The property attribute specifies the data member of the scripting variable,
identified by the name attribute, that contains a reference to a collection. This is also optional.
The type attribute provides the fully qualified class name of the element
being exposed from the collection. This object is referenced by the id attribute. This is also optional.

The <bean:define /> tag is used to retrieve the value of a named bean property and define it as a scripting variable, which will be stored in the scope specified by the toScope attribute.
The id attribute of <bean:define> specifies the scripting variable that will be created and stored in a scoped attribute that will be made
available with the value of the indicated property. This is mandatory attribute.
The name attribute specifies the attribute name of the bean whose
property is retrieved to define a new scoped attribute. This attribute is optional.
The property attribute identifies the property of the bean, specified by the name attribute, that is being retrieved. This is also optional.
Lastly, the type attribute provides the fully qualified class name of the value to be exposed as the id attribute.

Assuming that you have appropriate getters&setters in your formmbean.

Coming to your code snippet

pricingWorksheetForm.setProductTree((TreeMap)getServlet().getServletContext().getAttribute("productTree"));

<logic:iterate id="prodTree" name="pricingWorksheetForm" property="treeSet" type="java.util.Map.Entry">
<bean efine id="product" name="prodTree" property="value" type="java.util.Properties"/> <TR id="<%=prodTree.getKey()%>">



Here we have a we have a collection(TreeMap) called "productTree" ( probably set in session as it seems to be a formbean variable)

The logic iterate tag defines a jsp scripting variable as "prodTree" and this will contain the current object of the collection "productTree".
Now the bean define tag takes the object and gets the "product" variable and finally we have a scripplet that displays some property of productTree.
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic