Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts with parsers

 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new one for struts.

I want to fetch each and every node of the xml file.
I have done to fetch each and every node

my xml looks like

<QST>
<FIELD_LIST>
<FIELD_ID="0" CREATE="1" SEARCH="1">
<FIELD_ID="1" CREATE="1" SEARCH="0">
<FIELD_LIST>
</QST>

Using dom parser i get the nodes like
My output like
===============
FIELD_ID---> 0
CREATE-----> 1
SEARCH-----> 1
FIELD_ID---> 1
CREATE-----> 1
SEARCH-----> 0

IN THE ABOVE xml file FIELD_ID is a fields
In jsp page display,if the create=1 means, i want to check the checkbox otherwise checkbox should be not checked.

How can do this.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing to realize is that Struts doen't speak the language of parsers. It speaks the language of JavaBeans. Your first task, then, will be to translate the output of your parser into JavaBeans. I would suggest that you create an ActionForm that has a property ("fields" for example) that contains a List of individual JavaBeans, each one representing one "field" with the three properties you gave in your example.

You could then use the <logic:iterate> tag and "indexed properties" to iterate through the List and create a checkbox for each "Field" bean. This link gives you some good tips on using indexed properties.

Regarding your checkbox question: The <html:checkbox> tag is tied to the JavaBean property you specify using the indexed property name. If the property is of type boolean, the box will show as checked if the boolean value is true, and unchecked if it is false.
[ August 11, 2006: Message edited by: Merrill Higginson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic