You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kevin White <ta...@kevbo.org> on 2009/09/28 21:08:52 UTC

Dynamic form

Hello all...

I've been using Tapestry for a while...first 3, then 4.  My main app is 
still in 4, but I'm willing to move it to 5...so...we can talk about T5, 
and apologies for what might be basic T5 questions, because I haven't 
delved too deeply into T5 yet.  I keep waiting for a book.  :)

I have found Jumpstart and have looked around there.

Anyways...most of my app has static forms and fits right in to the whole 
"static structure, dynamic behavior" thing.  But I'm running smack dab 
into the one thing that I think I'm going to have trouble with.

I need to generate a configuration file for another system.  That config 
file is XML, although that's pretty inconsequential.  The point is, I 
need to run a text file through some processing and substitute specific 
values for parameters.

I have template config files.  A given device will combine a template 
with values and produce a filled-in file.  An example at the top of the 
template config file looks like this:

     <parameters>
       <parameter name="internal_ip_address"
          description="IP Address for internal network"/>
       <parameter name="external_ip_address"
          description="IP Address for external network"/>
     </parameters>

You can guess where this is going.

I want to build a Web GUI to provide the parameter values.  It will need 
to open up the specified template, read through the list of parameters, 
and make a form.

The only way I can see to do something like that is by using a Grid, 
where each parameter would be a row in the grid.  I can't use a 
BeanEdit, because I can't define the Bean itself at compile time...it 
comes from the XML template at run time.

The problem I see with using Grid is losing the ability to do field 
validators...each particular row in the Grid would have a "value" field 
that might require a different validation for each parameter.

I'm just looking for a suggestion as to what to look at to solve this. 
The general response to questions like this seems to be "redefine your 
problem and nail down your data model".  I could...I could require that 
each template have an associated JavaBean associated with it.  This 
means a Java developer would have to be involved whenever a new template 
is needed, which I wanted to avoid.  OTOH, I can see that I could 
quickly end up reimplementing a T4 looking description language in the 
<parameter> section there if I get any more complicated (ie, validators).

I've been writing web apps for a while, primarily by hand in Perl, then 
stumbling through it by hand in JSP, then with Tapestry.  I can conceive 
of how to do this by hand using the scary old methods.  I'd like to try 
to stay "in model" with Tapestry...but I fear that my requirements are 
at odds with Tapestry's base assumptions.  I'm willing to reconsider my 
requirements, but I'd like to try to avoid requiring new Java code for a 
new template.

Anyways, thanks for any help or suggestions.

Kevin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Dynamic form

Posted by Kevin White <kw...@kevbo.org>.
On 9/29/2009 5:20 AM, Alfie Kirkpatrick wrote:
> I made a hashmap backed beaneditform for something similar, so the
> property conduit just read/writes from the hashmap and the model comes
> from somewhere else (this was a dynamic search form in my case where the
> model was a JCR repo).
>
> Happy to share the code if it would be useful.

Actually, yes, it would be!  Save me from starting completely from 
scratch, at least.

Thanks Alfie, and thanks for everyone else who's responded.  I feel much 
better knowing that there is a way to move forward on this.

Kevin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Dynamic form

Posted by Alfie Kirkpatrick <Al...@ioko.com>.
I made a hashmap backed beaneditform for something similar, so the
property conduit just read/writes from the hashmap and the model comes
from somewhere else (this was a dynamic search form in my case where the
model was a JCR repo).

Happy to share the code if it would be useful.

Regards, Alfie.

-----Original Message-----
From: Kevin White [mailto:kwhite@kevbo.org] 
Sent: 28 September 2009 20:41
To: users@tapestry.apache.org
Subject: Re: Dynamic form

On 9/28/2009 3:24 PM, Kalle Korhonen wrote:
> I would look into using a BeanEditForm and making a BeanModel with all
> synthetic properties based on your XML configuration. If you have a
> definite set of parameter types and you can map each into some field
> type, then you should be able to do it. See
> http://tapestry.apache.org/tapestry5/guide/beaneditform.html

Slick!

To make sure I understand...use the BeanModel methods like add to add 
the parameters I need?

It looks like I'd go down the chain and end up using PropertyConduits to

read and set the values...

Yes, I would make a set of parameter types...things like numeric IP 
address, stuff like that.

That's cool...



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Dynamic form

Posted by Kevin White <kw...@kevbo.org>.
On 9/28/2009 3:24 PM, Kalle Korhonen wrote:
> I would look into using a BeanEditForm and making a BeanModel with all
> synthetic properties based on your XML configuration. If you have a
> definite set of parameter types and you can map each into some field
> type, then you should be able to do it. See
> http://tapestry.apache.org/tapestry5/guide/beaneditform.html

Slick!

To make sure I understand...use the BeanModel methods like add to add 
the parameters I need?

It looks like I'd go down the chain and end up using PropertyConduits to 
read and set the values...

Yes, I would make a set of parameter types...things like numeric IP 
address, stuff like that.

That's cool...

On 9/28/2009 3:34 PM, Christian Riedel wrote:
 > Hi Kevin,
 >
 > I think you could also use AjaxFormLoop:
 > 
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/AjaxFormLoop.html 


I looked at AjaxFormLoop from the Jumpstart page.  I thought it would 
work at first, but then I realized I'd still have the problem where each 
row could need a different validator at a given column.  I wasn't sure 
if it could handle that or not.

Thanks,

Kevin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Dynamic form

Posted by Christian Riedel <ch...@gmx.net>.
Hi Kevin,

I think you could also use AjaxFormLoop: 
http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/AjaxFormLoop.html

Cheers,
Christian

Kalle Korhonen schrieb:
> I would look into using a BeanEditForm and making a BeanModel with all
> synthetic properties based on your XML configuration. If you have a
> definite set of parameter types and you can map each into some field
> type, then you should be able to do it. See
> http://tapestry.apache.org/tapestry5/guide/beaneditform.html
>
> Kalle
>
>
> On Mon, Sep 28, 2009 at 12:08 PM, Kevin White <ta...@kevbo.org> wrote:
>   
>> Hello all...
>>
>> I've been using Tapestry for a while...first 3, then 4.  My main app is
>> still in 4, but I'm willing to move it to 5...so...we can talk about T5, and
>> apologies for what might be basic T5 questions, because I haven't delved too
>> deeply into T5 yet.  I keep waiting for a book.  :)
>>
>> I have found Jumpstart and have looked around there.
>>
>> Anyways...most of my app has static forms and fits right in to the whole
>> "static structure, dynamic behavior" thing.  But I'm running smack dab into
>> the one thing that I think I'm going to have trouble with.
>>
>> I need to generate a configuration file for another system.  That config
>> file is XML, although that's pretty inconsequential.  The point is, I need
>> to run a text file through some processing and substitute specific values
>> for parameters.
>>
>> I have template config files.  A given device will combine a template with
>> values and produce a filled-in file.  An example at the top of the template
>> config file looks like this:
>>
>>    <parameters>
>>      <parameter name="internal_ip_address"
>>         description="IP Address for internal network"/>
>>      <parameter name="external_ip_address"
>>         description="IP Address for external network"/>
>>    </parameters>
>>
>> You can guess where this is going.
>>
>> I want to build a Web GUI to provide the parameter values.  It will need to
>> open up the specified template, read through the list of parameters, and
>> make a form.
>>
>> The only way I can see to do something like that is by using a Grid, where
>> each parameter would be a row in the grid.  I can't use a BeanEdit, because
>> I can't define the Bean itself at compile time...it comes from the XML
>> template at run time.
>>
>> The problem I see with using Grid is losing the ability to do field
>> validators...each particular row in the Grid would have a "value" field that
>> might require a different validation for each parameter.
>>
>> I'm just looking for a suggestion as to what to look at to solve this. The
>> general response to questions like this seems to be "redefine your problem
>> and nail down your data model".  I could...I could require that each
>> template have an associated JavaBean associated with it.  This means a Java
>> developer would have to be involved whenever a new template is needed, which
>> I wanted to avoid.  OTOH, I can see that I could quickly end up
>> reimplementing a T4 looking description language in the <parameter> section
>> there if I get any more complicated (ie, validators).
>>
>> I've been writing web apps for a while, primarily by hand in Perl, then
>> stumbling through it by hand in JSP, then with Tapestry.  I can conceive of
>> how to do this by hand using the scary old methods.  I'd like to try to stay
>> "in model" with Tapestry...but I fear that my requirements are at odds with
>> Tapestry's base assumptions.  I'm willing to reconsider my requirements, but
>> I'd like to try to avoid requiring new Java code for a new template.
>>
>> Anyways, thanks for any help or suggestions.
>>
>> Kevin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Dynamic form

Posted by Kalle Korhonen <ka...@gmail.com>.
I would look into using a BeanEditForm and making a BeanModel with all
synthetic properties based on your XML configuration. If you have a
definite set of parameter types and you can map each into some field
type, then you should be able to do it. See
http://tapestry.apache.org/tapestry5/guide/beaneditform.html

Kalle


On Mon, Sep 28, 2009 at 12:08 PM, Kevin White <ta...@kevbo.org> wrote:
> Hello all...
>
> I've been using Tapestry for a while...first 3, then 4.  My main app is
> still in 4, but I'm willing to move it to 5...so...we can talk about T5, and
> apologies for what might be basic T5 questions, because I haven't delved too
> deeply into T5 yet.  I keep waiting for a book.  :)
>
> I have found Jumpstart and have looked around there.
>
> Anyways...most of my app has static forms and fits right in to the whole
> "static structure, dynamic behavior" thing.  But I'm running smack dab into
> the one thing that I think I'm going to have trouble with.
>
> I need to generate a configuration file for another system.  That config
> file is XML, although that's pretty inconsequential.  The point is, I need
> to run a text file through some processing and substitute specific values
> for parameters.
>
> I have template config files.  A given device will combine a template with
> values and produce a filled-in file.  An example at the top of the template
> config file looks like this:
>
>    <parameters>
>      <parameter name="internal_ip_address"
>         description="IP Address for internal network"/>
>      <parameter name="external_ip_address"
>         description="IP Address for external network"/>
>    </parameters>
>
> You can guess where this is going.
>
> I want to build a Web GUI to provide the parameter values.  It will need to
> open up the specified template, read through the list of parameters, and
> make a form.
>
> The only way I can see to do something like that is by using a Grid, where
> each parameter would be a row in the grid.  I can't use a BeanEdit, because
> I can't define the Bean itself at compile time...it comes from the XML
> template at run time.
>
> The problem I see with using Grid is losing the ability to do field
> validators...each particular row in the Grid would have a "value" field that
> might require a different validation for each parameter.
>
> I'm just looking for a suggestion as to what to look at to solve this. The
> general response to questions like this seems to be "redefine your problem
> and nail down your data model".  I could...I could require that each
> template have an associated JavaBean associated with it.  This means a Java
> developer would have to be involved whenever a new template is needed, which
> I wanted to avoid.  OTOH, I can see that I could quickly end up
> reimplementing a T4 looking description language in the <parameter> section
> there if I get any more complicated (ie, validators).
>
> I've been writing web apps for a while, primarily by hand in Perl, then
> stumbling through it by hand in JSP, then with Tapestry.  I can conceive of
> how to do this by hand using the scary old methods.  I'd like to try to stay
> "in model" with Tapestry...but I fear that my requirements are at odds with
> Tapestry's base assumptions.  I'm willing to reconsider my requirements, but
> I'd like to try to avoid requiring new Java code for a new template.
>
> Anyways, thanks for any help or suggestions.
>
> Kevin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Dynamic form

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 28 Sep 2009 16:08:52 -0300, Kevin White <ta...@kevbo.org>  
escreveu:

> Hello all...

Hi!

> The only way I can see to do something like that is by using a Grid,  
> where each parameter would be a row in the grid.  I can't use a  
> BeanEdit, because I can't define the Bean itself at compile time...it  
> comes from the XML template at run time.

I've never tested it, but I think you can, as long as you add the  
properties to the BeanModel yourself and implement a PropertyConduit for  
them.
Or you can just not use Form and get the request values from an @Inject'ed  
Request.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org