This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes Creating form elements at run time in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Creating form elements at run time in jsp" Watch "Creating form elements at run time in jsp" New topic

Creating form elements at run time in jsp

rachit agr

Joined: Sep 14, 2011
Posts: 5
Hi I am creating an application where for each user form elements being displayed could be different
(type of element, number of element, label of the form element, order of appearance : all these could differ from user to user).
I am fetching these user prefernece from DB.
I was hoping to implement some technique/tool/method so that I could create the JSP to be shown to the user at runtime from centralized framework
(I want to reuse the same component for creating JSP for the users).
Any suggestions?
PS : I am using Struts + Spring Framework.
Harsha Ka
Ranch Hand

Joined: Mar 14, 2010
Posts: 45

A way of doing this would be to create distinct groups/names for the different user experience and map this in your user preference table. In your action class fetch this value, set it as request parameter and forward the control to the JSP, where suitably using the conditional tags, create form elements based on the user group name.

SCJP 1.6,Preparing (Tryin to prepare) for scwcd
rachit agr

Joined: Sep 14, 2011
Posts: 5
My question is related only to the rendering part of the form elements.
I dont want to use conditional tags and render the elements.Because this rule is followed for several pages in my application. I want to have centeralized mechanism for this,
Yogesh Lonkar
Ranch Hand

Joined: Jul 17, 2012
Posts: 94

I am working on some thing similar situation, what we are doing is we have made one addition property for user which is called Role, and it is stored in DB there can be various roles for users,
so when you create user you assign him a role now there is 1 more transit Entity which assigns action to certain roles and you can use interceptor to check action against role from data base.
like wise you can customize your pages to be displayed to user depending on user's Role

Learning some thing New Every Day
I agree. Here's the link:
subject: Creating form elements at run time in jsp
It's not a secret anymore!