You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Dondapati <dj...@gmail.com> on 2011/01/24 16:22:34 UTC

Dynamic Struts component type

Hi all,

I have recently started playing around with struts 2 framework. And I have
an interesting problem that I wanna solve with Struts. We are creating a
survey from the questions stored in database and even the options like
yes/no/other/comment fields come from the database. Even the html type is
stored in the database. Now, I have to create the right html type input
element based on that html type value stored in database.

For e.g. If the question is say :

Questions 1 : Are you a citizen of USA ?
option 1 : Yes <radio>
option 2 : No <radio>
option 3 : If other, please specify <text field>

This is just a sample question but there are millions like this which have
options that are more than one html type. Now, how do I go about this? Is
there a plugin/extension for struts that would let me dynamically select the
UI component type?

Any suggestions are welcome and are really appreciated. Thank you!

-- 
Cheers,
John

Re: Dynamic Struts component type

Posted by Dave Newton <da...@gmail.com>.
There's a bunch of ways this could be done.

Personally, I'd either create a standard JSP-based custom tag, do it in
JavaScript, or write a thin layer between a DB-backed UI description DSL and
a JavaScript UI builder.

Dave

On Mon, Jan 24, 2011 at 10:37 AM, John Dondapati <dj...@gmail.com>wrote:

> Would a custom component be the right direction to solve this?
>
> If this has been asked earlier, can someone please point me to that
> resource. Thanks!
>
> On Mon, Jan 24, 2011 at 10:22 AM, John Dondapati <djohnjimmy@gmail.com
> >wrote:
>
> > Hi all,
> >
> > I have recently started playing around with struts 2 framework. And I
> have
> > an interesting problem that I wanna solve with Struts. We are creating a
> > survey from the questions stored in database and even the options like
> > yes/no/other/comment fields come from the database. Even the html type is
> > stored in the database. Now, I have to create the right html type input
> > element based on that html type value stored in database.
> >
> > For e.g. If the question is say :
> >
> > Questions 1 : Are you a citizen of USA ?
> > option 1 : Yes <radio>
> > option 2 : No <radio>
> > option 3 : If other, please specify <text field>
> >
> > This is just a sample question but there are millions like this which
> have
> > options that are more than one html type. Now, how do I go about this? Is
> > there a plugin/extension for struts that would let me dynamically select
> the
> > UI component type?
> >
> > Any suggestions are welcome and are really appreciated. Thank you!
> >
> > --
> > Cheers,
> > John
> >
> >
>
>
> --
> Cheers,
> John
>

Re: Dynamic Struts component type

Posted by John Dondapati <dj...@gmail.com>.
Would a custom component be the right direction to solve this?

If this has been asked earlier, can someone please point me to that
resource. Thanks!

On Mon, Jan 24, 2011 at 10:22 AM, John Dondapati <dj...@gmail.com>wrote:

> Hi all,
>
> I have recently started playing around with struts 2 framework. And I have
> an interesting problem that I wanna solve with Struts. We are creating a
> survey from the questions stored in database and even the options like
> yes/no/other/comment fields come from the database. Even the html type is
> stored in the database. Now, I have to create the right html type input
> element based on that html type value stored in database.
>
> For e.g. If the question is say :
>
> Questions 1 : Are you a citizen of USA ?
> option 1 : Yes <radio>
> option 2 : No <radio>
> option 3 : If other, please specify <text field>
>
> This is just a sample question but there are millions like this which have
> options that are more than one html type. Now, how do I go about this? Is
> there a plugin/extension for struts that would let me dynamically select the
> UI component type?
>
> Any suggestions are welcome and are really appreciated. Thank you!
>
> --
> Cheers,
> John
>
>


-- 
Cheers,
John