aspose file tools*
The moose likes Struts and the fly likes Dynamic property in Struts 1.3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dynamic property in Struts 1.3" Watch "Dynamic property in Struts 1.3" New topic
Author

Dynamic property in Struts 1.3

hariharan jayaprakash
Ranch Hand

Joined: Sep 09, 2010
Posts: 63
I want to use jsp with fields are dynamic.

For eg:
<html:text property="username"/>
. so we can use setter and getter for the property "username" in corresponding actionform(like LoginForm) to get the form inputs....

If we don't know the property name before, it ll be dynamically evalvuated means, how we need to handle in action form class?. how to handle getter and setter for the dynamic property(i.e form fields in jsp).
arkaes Duraimoni
Greenhorn

Joined: Jan 23, 2013
Posts: 14
Could you please tell me the exact requirement.
if the fields need to dynamic means.
you can have array of fields.
hariharan jayaprakash
Ranch Hand

Joined: Sep 09, 2010
Posts: 63
I have two pages in my application...


1) Product.jsp, It contains many fields like product code, product name, product category etc to add product details in product table...


2) AddColumn.jsp This is another page, Add new column.. In this page, am providing a feauture to add a new column to product in thru UI itself...

so accordingly product.jsp will hold those many fields...

so if i add new column like "STOCKS" thru AddColumn.jsp, Then in Product.jsp, I need to have see a new field like "STOCKS" in product.jsp..

so that how can i handle actionform <html:text property=""/>

Hope i am clear...



[Thumbnail for Column.jpg]


[Thumbnail for Product.jpg]

arkaes Duraimoni
Greenhorn

Joined: Jan 23, 2013
Posts: 14
fine hariharan

you can have your stock as array

in your form you can have

private String stock[];
and getter and setter

then in your jsp
<html:text property="stock"/>
now you will get array of stocks.

but you have to take care of adding new stock.

after clicking the add new button you have to call the action and add the total value of the stocks.
and set it in to the request or your form

<logic:terate.....>
<html:text property="stock"/>
</logic:iterate>

now your property have the all new dynamic properties

now in action you will get

String stocks[] =actionform.getStock();
arkaes Duraimoni
Greenhorn

Joined: Jan 23, 2013
Posts: 14
Hari, the above solution worked ?
 
wood burning stoves
 
subject: Dynamic property in Struts 1.3