aspose file tools*
The moose likes Struts and the fly likes Is there a possible way to use index properties on this situation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Is there a possible way to use index properties on this situation" Watch "Is there a possible way to use index properties on this situation" New topic
Author

Is there a possible way to use index properties on this situation

xin xin
Greenhorn

Joined: Dec 15, 2005
Posts: 4
Hello everyone,

I have been thinking of this for weeks, but still don't know if the index properties will help or not.

Here are my application requirements, and any suggestions are needed, thanks.

This project needs to display a lot of data on a jsp page, the row number is fixed what I mean fixed is it depends on the data in database so I won't be able to hardcode them. But the columns are dynamic, user could add as many columns as they want.

For example here is the structure of 5 rows by 2 columns:

client: [text input ] | [text input ]
matter: [text input ] | [text input ]
name: [text input ] | [text input ]
address: [text input ] | [text input ]
e-mail: [text input ] | [text input ]

Does anyone know how to do this using Struts, 'cause I really don't know if the ActionForm will do the job here, since how to define the fields getter or setter methods in ActionForm?

Thanks a lot!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I'm having a hard time understanding what you want to do here. Please help me get a better idea of how the page is supposed to look as the user adds more data.

Will it look like this?

client: [text input ] | [text input ]
matter: [text input ] | [text input ]
name: [text input ] | [text input ]
address: [text input ] | [text input ]
e-mail: [text input ] | [text input ]

client: [text input ] | [text input ]
matter: [text input ] | [text input ]
name: [text input ] | [text input ]
address: [text input ] | [text input ]
e-mail: [text input ] | [text input ]

client: [text input ] | [text input ]
matter: [text input ] | [text input ]
name: [text input ] | [text input ]
address: [text input ] | [text input ]
e-mail: [text input ] | [text input ]


or like this?

client: [text input ] | [text input ] [text input ] | [text input ]
matter: [text input ] | [text input ][text input ] | [text input ]
name: [text input ] | [text input ][text input ] | [text input ]
address: [text input ] | [text input ][text input ] | [text input ]
e-mail: [text input ] | [text input ]
[text input ] | [text input ]


Merrill
Consultant, Sima Solutions
xin xin
Greenhorn

Joined: Dec 15, 2005
Posts: 4
Hi Merrill Higginson,

Thanks for reply, it will look like the second option, user is able to add a column each time, for example, here is the 5 row by 2 column:

client: [input text][input text]
metter: [input text][input text]
name: [input text][input text]
address: [input text][input text]
e-mail: [input text][input text]

If the user add one column, it will be:

client: [input text][input text][input text]
metter: [input text][input text][input text]
name: [input text][input text][input text]
address: [input text][input text][input text]
e-mail: [input text][input text][input text]

I know this is kind of abnormal, each row has the same kind of data.

Thanks
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Yes, indexed properties will work well in this situation. There are many ways to do this, but here's one suggestion:

Create a javaBean called Case or something like that which has properties for all the fields you listed (client, matter, etc.). In your ActionForm, create a collection of these beans called cases.

Then in your jsp, use indexed properties along with logic:iterate to produce the output. Something like this:
<tr>
<td>client:</td>
<logic:iterate id="case" name="myForm" property="cases" indexId="i">
<td><html:text property='<%="cases["+i+"].client" %>' /></td>
</logic:iterate>
</tr>
<tr>
<td>matter:</td>
<logic:iterate id="case2" name="myForm" property="cases" indexId="i2">
<td><html:text property='<%="cases["+i2+"].matter" %>' /></td>
</logic:iterate>
</tr>

repeat this process for name, address, and email.
xin xin
Greenhorn

Joined: Dec 15, 2005
Posts: 4
Thanks very much,

I will try it this way to see if I can get it working, because I won't be able to know the properties until I query the database, so how am I able to set up all the set and get properties. Maybe I can use a list, not sure.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you don't know the properties in advance, use one of the implementations of the java.util.Map interface (Hashmap, Treemap,etc.). You can then get the labels from the keySet() method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there a possible way to use index properties on this situation
 
Similar Threads
Opening a Spreadsheet in a JSP
storing table values in the database
saving table values in a database
Session Scope JSF
Use ArrayList in ActionForm