Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dynamic property in Struts 1.3

 
hariharan jayaprakash
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
Column.jpg
Adding a Column to a product table thru UI itself
[Thumbnail for Column.jpg]
Product.jpg
Adding a Product Info in Product Table
[Thumbnail for Product.jpg]
 
arkaes Duraimoni
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hari, the above solution worked ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic