You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Антон Мезерный <an...@gmail.com> on 2010/09/17 00:09:05 UTC

Dynamic form

Hello,
I am new to Tapestry, and I am working on a project that uses it. I use
version 5.1.0.7 but I can change it to newer one.

I am trying to make a dynamic form component, something like beaneditform,
but based not on bean field type, but on some property in database.
So I have a number of components like text input, date picker and other and
I want to render  some of them in the form according to the list of
properties (for example strings - id's of components) from DB and then
properly submit these fields values and process them.
Another words I want to create something like

<t:${componentNameFromDB} ...>

inside the loop in a form. Of course this example does not work. But I think
this is the best way to explain, what I want.
I tried to use delegate component, but as I understood, I should define all
my components (inputs and other) inside one tml-page in block tags and
create block instances in java code. Can I do that with separate components
for every element in the form?
What is the best way to achieve it?

Re: Dynamic form

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sat, 18 Sep 2010 11:45:19 -0300, Josh Canfield <jo...@gmail.com>  
wrote:

>> Is there any way to get component
>> instance by its name even if this component is not used in any other  
>> page?
>
> The short answer is no. I don't remember the long answer off hand...

The long answer is also no :). A component instance only exists inside a  
page. Don't forget about Tapestry's static structure.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Dynamic form

Posted by Josh Canfield <jo...@gmail.com>.
> Is there any way to get component
> instance by its name even if this component is not used in any other page?

The short answer is no. I don't remember the long answer off hand... 

-- Josh

On Sep 18, 2010, at 5:41 AM, Anton Mezerny <an...@gmail.com> wrote:

> Looking on ComponentSource code I understood, that it gets only components,
> that are already defined within some page. Is there any way to get component
> instance by its name even if this component is not used in any other page?
> 
> 2010/9/18 Anton Mezerny <an...@gmail.com>
> 
>> Igor, I am now trying to write something like in your book, but first of
>> all I don't want to define blocks in one tml page, and a number or blocks in
>> java-class. I try to get component instance dynamically using method
>> componentSource.getComponent(String)
>> but I have an exception on this method.
>> 
>> 
>> org.apache.tapestry5.internal.services.RenderQueueException
>> Render queue error in BeginRender[Step:dynamicformfield.delegate]: Failure
>> reading parameter 'to' of component Step:dynamicformfield.delegate: Unable
>> to resolve 'textfield' to a known page name. Available page names: (blank),
>> About, Contact, ExceptionReport, Index, PropertyDisplayBlocks,
>> PropertyEditBlocks, ServiceStatus, Step.
>> 
>> I can't understand why Tapestry looks for pages and not components. So for
>> example if I change method to componentSource.getPage("About"); everything
>> renders fine - I get a number of About pages rendered inside my form. (About
>> is one of pages defined in my application)
>> 
>> 
>> 2010/9/18 Markus Feindler <Ma...@gmx.de>
>> 
>> Why would you need a submit notifier? I checked out your book and  it works
>>> fine without one.
>>> 
>>> What you need is a combination of Loop, Delegate, and SubmitNotifier
>>>> components and a couple of blocks inside your template. Check this out:
>>>> 
>>>> 
>>>> http://code.google.com/p/tapestrybook/source/browse/trunk/tapestry-dynamic-forms/src/main/webapp/ViewReport.tml
>>>> 
>>>> http://code.google.com/p/tapestrybook/source/browse/trunk/tapestry-dynamic-forms/src/main/java/de/t5book/pages/ViewReport.java
>>>> 
>>>> On Sat, Sep 18, 2010 at 12:03 AM, Антон Мезерный<anton.mezerny@gmail.com
>>>>> wrote:
>>>> 
>>>> 
>>>> 
>>>>> And what is the best way to create such a dynamic form? Using Delegate
>>>>> component or modifying beaneditform? Or maybe there is better approach?
>>>>> 
>>>>> I tried to write it using Delegate and I have a problem - I can't get
>>>>> component instance from ComponentSource - Exception:
>>>>> 
>>>>> org.apache.tapestry5.internal.services.RenderQueueException
>>>>> Render queue error in BeginRender[Step:dynamicformfield.delegate]:
>>>>> Failure
>>>>> reading parameter 'to' of component Step:dynamicformfield.delegate:
>>>>> Unable
>>>>> to resolve 'textfield' to a known page name. Available page names:
>>>>> (blank),
>>>>> About, Contact, ExceptionReport, Index, PropertyDisplayBlocks,
>>>>> PropertyEditBlocks, ServiceStatus, Step.
>>>>> 
>>>>> Why is it looking for a page, not component?
>>>>> 
>>>>> 2010/9/17 Thiago H. de Paula Figueiredo<th...@gmail.com>
>>>>> 
>>>>> 
>>>>> 
>>>>>> On Thu, 16 Sep 2010 19:09:05 -0300, Антон Мезерный<
>>>>>> anton.mezerny@gmail.com>  wrote:
>>>>>> 
>>>>>> Hello,
>>>>>> 
>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> Hi!
>>>>>> 
>>>>>> 
>>>>>> I am trying to make a dynamic form component, something like
>>>>>> 
>>>>>> 
>>>>> beaneditform,
>>>>> 
>>>>> 
>>>>>> but based not on bean field type, but on some property in database.
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> I strongly advise you to read the BeanEditor sources and do something
>>>>>> similar or, better yet, contribute viewing and edition blocks. The end
>>>>>> of
>>>>>> this page shows you how to add blocks:
>>>>>> http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html.
>>>>>> Besides
>>>>>> that, create one of more DataTypeAnalyzer and contribute them to the
>>>>>> DataTypeAnalyzer service. See
>>>>>> 
>>>>>> http://tapestry.1045711.n5.nabble.com/Custom-Edit-Block-td2427355.htmlfor
>>>>>> a little more detail.
>>>>>> 
>>>>>> 
>>>>>> Another words I want to create something like
>>>>>> 
>>>>>> 
>>>>>>> <t:${componentNameFromDB} ...>
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> Short answer: you can't. Tapestry pages and components have stricly
>>>>>> 
>>>>>> 
>>>>> static
>>>>> 
>>>>> 
>>>>>> structure.
>>>>>> Long answer: you can use blocks (<t:block>) and the Delegate component
>>>>>> to
>>>>>> render blocks or components dynamically.
>>>>>> 
>>>>>> 
>>>>>> I tried to use delegate component, but as I understood, I should
>>>>>> define
>>>>>> 
>>>>>> 
>>>>>>> all my components (inputs and other) inside one tml-page in block tags
>>>>>>> 
>>>>>>> 
>>>>>> and
>>>>> 
>>>>> 
>>>>>> 
>>>>>>> 
>>>>>> Not necessarily in a single page.
>>>>>> 
>>>>>> 
>>>>>> create block instances in java code. Can I do that with separate
>>>>>> 
>>>>>> 
>>>>>>> components for every element in the form?
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> Yes.
>>>>>> 
>>>>>> 
>>>>>> What is the best way to achieve it?
>>>>>> 
>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> ComponentSource will help you to grab page instances.
>>>>>> 
>>>>>> --
>>>>>> Thiago H. de Paula Figueiredo
>>>>>> Independent Java, Apache Tapestry 5 and Hibernate consultant,
>>>>>> developer,
>>>>>> and instructor
>>>>>> Owner, Ars Machina Tecnologia da Informação Ltda.
>>>>>> http://www.arsmachina.com.br
>>>>>> 
>>>>>> ---------------------------------------------------------------------
>>>>>> 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 Anton Mezerny <an...@gmail.com>.
Looking on ComponentSource code I understood, that it gets only components,
that are already defined within some page. Is there any way to get component
instance by its name even if this component is not used in any other page?

2010/9/18 Anton Mezerny <an...@gmail.com>

> Igor, I am now trying to write something like in your book, but first of
> all I don't want to define blocks in one tml page, and a number or blocks in
> java-class. I try to get component instance dynamically using method
>  componentSource.getComponent(String)
> but I have an exception on this method.
>
>
> org.apache.tapestry5.internal.services.RenderQueueException
> Render queue error in BeginRender[Step:dynamicformfield.delegate]: Failure
> reading parameter 'to' of component Step:dynamicformfield.delegate: Unable
> to resolve 'textfield' to a known page name. Available page names: (blank),
> About, Contact, ExceptionReport, Index, PropertyDisplayBlocks,
> PropertyEditBlocks, ServiceStatus, Step.
>
> I can't understand why Tapestry looks for pages and not components. So for
> example if I change method to componentSource.getPage("About"); everything
> renders fine - I get a number of About pages rendered inside my form. (About
> is one of pages defined in my application)
>
>
> 2010/9/18 Markus Feindler <Ma...@gmx.de>
>
> Why would you need a submit notifier? I checked out your book and  it works
>> fine without one.
>>
>>  What you need is a combination of Loop, Delegate, and SubmitNotifier
>>> components and a couple of blocks inside your template. Check this out:
>>>
>>>
>>> http://code.google.com/p/tapestrybook/source/browse/trunk/tapestry-dynamic-forms/src/main/webapp/ViewReport.tml
>>>
>>> http://code.google.com/p/tapestrybook/source/browse/trunk/tapestry-dynamic-forms/src/main/java/de/t5book/pages/ViewReport.java
>>>
>>> On Sat, Sep 18, 2010 at 12:03 AM, Антон Мезерный<anton.mezerny@gmail.com
>>> >wrote:
>>>
>>>
>>>
>>>> And what is the best way to create such a dynamic form? Using Delegate
>>>> component or modifying beaneditform? Or maybe there is better approach?
>>>>
>>>> I tried to write it using Delegate and I have a problem - I can't get
>>>> component instance from ComponentSource - Exception:
>>>>
>>>> org.apache.tapestry5.internal.services.RenderQueueException
>>>> Render queue error in BeginRender[Step:dynamicformfield.delegate]:
>>>> Failure
>>>> reading parameter 'to' of component Step:dynamicformfield.delegate:
>>>> Unable
>>>> to resolve 'textfield' to a known page name. Available page names:
>>>> (blank),
>>>> About, Contact, ExceptionReport, Index, PropertyDisplayBlocks,
>>>> PropertyEditBlocks, ServiceStatus, Step.
>>>>
>>>> Why is it looking for a page, not component?
>>>>
>>>> 2010/9/17 Thiago H. de Paula Figueiredo<th...@gmail.com>
>>>>
>>>>
>>>>
>>>>> On Thu, 16 Sep 2010 19:09:05 -0300, Антон Мезерный<
>>>>> anton.mezerny@gmail.com>  wrote:
>>>>>
>>>>>  Hello,
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>> Hi!
>>>>>
>>>>>
>>>>>  I am trying to make a dynamic form component, something like
>>>>>
>>>>>
>>>> beaneditform,
>>>>
>>>>
>>>>> but based not on bean field type, but on some property in database.
>>>>>>
>>>>>>
>>>>>>
>>>>> I strongly advise you to read the BeanEditor sources and do something
>>>>> similar or, better yet, contribute viewing and edition blocks. The end
>>>>> of
>>>>> this page shows you how to add blocks:
>>>>> http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html.
>>>>> Besides
>>>>> that, create one of more DataTypeAnalyzer and contribute them to the
>>>>> DataTypeAnalyzer service. See
>>>>>
>>>>> http://tapestry.1045711.n5.nabble.com/Custom-Edit-Block-td2427355.htmlfor
>>>>> a little more detail.
>>>>>
>>>>>
>>>>>  Another words I want to create something like
>>>>>
>>>>>
>>>>>> <t:${componentNameFromDB} ...>
>>>>>>
>>>>>>
>>>>>>
>>>>> Short answer: you can't. Tapestry pages and components have stricly
>>>>>
>>>>>
>>>> static
>>>>
>>>>
>>>>> structure.
>>>>> Long answer: you can use blocks (<t:block>) and the Delegate component
>>>>> to
>>>>> render blocks or components dynamically.
>>>>>
>>>>>
>>>>>  I tried to use delegate component, but as I understood, I should
>>>>> define
>>>>>
>>>>>
>>>>>> all my components (inputs and other) inside one tml-page in block tags
>>>>>>
>>>>>>
>>>>> and
>>>>
>>>>
>>>>>
>>>>>>
>>>>> Not necessarily in a single page.
>>>>>
>>>>>
>>>>>  create block instances in java code. Can I do that with separate
>>>>>
>>>>>
>>>>>> components for every element in the form?
>>>>>>
>>>>>>
>>>>>>
>>>>> Yes.
>>>>>
>>>>>
>>>>>  What is the best way to achieve it?
>>>>>
>>>>>
>>>>>>
>>>>>>
>>>>> ComponentSource will help you to grab page instances.
>>>>>
>>>>> --
>>>>> Thiago H. de Paula Figueiredo
>>>>> Independent Java, Apache Tapestry 5 and Hibernate consultant,
>>>>> developer,
>>>>> and instructor
>>>>> Owner, Ars Machina Tecnologia da Informação Ltda.
>>>>> http://www.arsmachina.com.br
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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 Anton Mezerny <an...@gmail.com>.
Igor, I am now trying to write something like in your book, but first of all
I don't want to define blocks in one tml page, and a number or blocks in
java-class. I try to get component instance dynamically using method
 componentSource.getComponent(String)
but I have an exception on this method.

org.apache.tapestry5.internal.services.RenderQueueException
Render queue error in BeginRender[Step:dynamicformfield.delegate]: Failure
reading parameter 'to' of component Step:dynamicformfield.delegate: Unable
to resolve 'textfield' to a known page name. Available page names: (blank),
About, Contact, ExceptionReport, Index, PropertyDisplayBlocks,
PropertyEditBlocks, ServiceStatus, Step.

I can't understand why Tapestry looks for pages and not components. So for
example if I change method to componentSource.getPage("About"); everything
renders fine - I get a number of About pages rendered inside my form. (About
is one of pages defined in my application)


2010/9/18 Markus Feindler <Ma...@gmx.de>

> Why would you need a submit notifier? I checked out your book and  it works
> fine without one.
>
>  What you need is a combination of Loop, Delegate, and SubmitNotifier
>> components and a couple of blocks inside your template. Check this out:
>>
>>
>> http://code.google.com/p/tapestrybook/source/browse/trunk/tapestry-dynamic-forms/src/main/webapp/ViewReport.tml
>>
>> http://code.google.com/p/tapestrybook/source/browse/trunk/tapestry-dynamic-forms/src/main/java/de/t5book/pages/ViewReport.java
>>
>> On Sat, Sep 18, 2010 at 12:03 AM, Антон Мезерный<anton.mezerny@gmail.com
>> >wrote:
>>
>>
>>
>>> And what is the best way to create such a dynamic form? Using Delegate
>>> component or modifying beaneditform? Or maybe there is better approach?
>>>
>>> I tried to write it using Delegate and I have a problem - I can't get
>>> component instance from ComponentSource - Exception:
>>>
>>> org.apache.tapestry5.internal.services.RenderQueueException
>>> Render queue error in BeginRender[Step:dynamicformfield.delegate]:
>>> Failure
>>> reading parameter 'to' of component Step:dynamicformfield.delegate:
>>> Unable
>>> to resolve 'textfield' to a known page name. Available page names:
>>> (blank),
>>> About, Contact, ExceptionReport, Index, PropertyDisplayBlocks,
>>> PropertyEditBlocks, ServiceStatus, Step.
>>>
>>> Why is it looking for a page, not component?
>>>
>>> 2010/9/17 Thiago H. de Paula Figueiredo<th...@gmail.com>
>>>
>>>
>>>
>>>> On Thu, 16 Sep 2010 19:09:05 -0300, Антон Мезерный<
>>>> anton.mezerny@gmail.com>  wrote:
>>>>
>>>>  Hello,
>>>>
>>>>
>>>>>
>>>>>
>>>> Hi!
>>>>
>>>>
>>>>  I am trying to make a dynamic form component, something like
>>>>
>>>>
>>> beaneditform,
>>>
>>>
>>>> but based not on bean field type, but on some property in database.
>>>>>
>>>>>
>>>>>
>>>> I strongly advise you to read the BeanEditor sources and do something
>>>> similar or, better yet, contribute viewing and edition blocks. The end
>>>> of
>>>> this page shows you how to add blocks:
>>>> http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html. Besides
>>>> that, create one of more DataTypeAnalyzer and contribute them to the
>>>> DataTypeAnalyzer service. See
>>>>
>>>> http://tapestry.1045711.n5.nabble.com/Custom-Edit-Block-td2427355.htmlfor
>>>> a little more detail.
>>>>
>>>>
>>>>  Another words I want to create something like
>>>>
>>>>
>>>>> <t:${componentNameFromDB} ...>
>>>>>
>>>>>
>>>>>
>>>> Short answer: you can't. Tapestry pages and components have stricly
>>>>
>>>>
>>> static
>>>
>>>
>>>> structure.
>>>> Long answer: you can use blocks (<t:block>) and the Delegate component
>>>> to
>>>> render blocks or components dynamically.
>>>>
>>>>
>>>>  I tried to use delegate component, but as I understood, I should define
>>>>
>>>>
>>>>> all my components (inputs and other) inside one tml-page in block tags
>>>>>
>>>>>
>>>> and
>>>
>>>
>>>>
>>>>>
>>>> Not necessarily in a single page.
>>>>
>>>>
>>>>  create block instances in java code. Can I do that with separate
>>>>
>>>>
>>>>> components for every element in the form?
>>>>>
>>>>>
>>>>>
>>>> Yes.
>>>>
>>>>
>>>>  What is the best way to achieve it?
>>>>
>>>>
>>>>>
>>>>>
>>>> ComponentSource will help you to grab page instances.
>>>>
>>>> --
>>>> Thiago H. de Paula Figueiredo
>>>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>>>> and instructor
>>>> Owner, Ars Machina Tecnologia da Informação Ltda.
>>>> http://www.arsmachina.com.br
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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 Markus Feindler <Ma...@gmx.de>.
Why would you need a submit notifier? I checked out your book and  it 
works fine without one.
> What you need is a combination of Loop, Delegate, and SubmitNotifier
> components and a couple of blocks inside your template. Check this out:
>
> http://code.google.com/p/tapestrybook/source/browse/trunk/tapestry-dynamic-forms/src/main/webapp/ViewReport.tml
> http://code.google.com/p/tapestrybook/source/browse/trunk/tapestry-dynamic-forms/src/main/java/de/t5book/pages/ViewReport.java
>
> On Sat, Sep 18, 2010 at 12:03 AM, Антон Мезерный<an...@gmail.com>wrote:
>
>    
>> And what is the best way to create such a dynamic form? Using Delegate
>> component or modifying beaneditform? Or maybe there is better approach?
>>
>> I tried to write it using Delegate and I have a problem - I can't get
>> component instance from ComponentSource - Exception:
>>
>> org.apache.tapestry5.internal.services.RenderQueueException
>> Render queue error in BeginRender[Step:dynamicformfield.delegate]: Failure
>> reading parameter 'to' of component Step:dynamicformfield.delegate: Unable
>> to resolve 'textfield' to a known page name. Available page names: (blank),
>> About, Contact, ExceptionReport, Index, PropertyDisplayBlocks,
>> PropertyEditBlocks, ServiceStatus, Step.
>>
>> Why is it looking for a page, not component?
>>
>> 2010/9/17 Thiago H. de Paula Figueiredo<th...@gmail.com>
>>
>>      
>>> On Thu, 16 Sep 2010 19:09:05 -0300, Антон Мезерный<
>>> anton.mezerny@gmail.com>  wrote:
>>>
>>>   Hello,
>>>        
>>>>          
>>> Hi!
>>>
>>>
>>>   I am trying to make a dynamic form component, something like
>>>        
>> beaneditform,
>>      
>>>> but based not on bean field type, but on some property in database.
>>>>
>>>>          
>>> I strongly advise you to read the BeanEditor sources and do something
>>> similar or, better yet, contribute viewing and edition blocks. The end of
>>> this page shows you how to add blocks:
>>> http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html. Besides
>>> that, create one of more DataTypeAnalyzer and contribute them to the
>>> DataTypeAnalyzer service. See
>>> http://tapestry.1045711.n5.nabble.com/Custom-Edit-Block-td2427355.htmlfor
>>> a little more detail.
>>>
>>>
>>>   Another words I want to create something like
>>>        
>>>> <t:${componentNameFromDB} ...>
>>>>
>>>>          
>>> Short answer: you can't. Tapestry pages and components have stricly
>>>        
>> static
>>      
>>> structure.
>>> Long answer: you can use blocks (<t:block>) and the Delegate component to
>>> render blocks or components dynamically.
>>>
>>>
>>>   I tried to use delegate component, but as I understood, I should define
>>>        
>>>> all my components (inputs and other) inside one tml-page in block tags
>>>>          
>> and
>>      
>>>>          
>>> Not necessarily in a single page.
>>>
>>>
>>>   create block instances in java code. Can I do that with separate
>>>        
>>>> components for every element in the form?
>>>>
>>>>          
>>> Yes.
>>>
>>>
>>>   What is the best way to achieve it?
>>>        
>>>>          
>>> ComponentSource will help you to grab page instances.
>>>
>>> --
>>> Thiago H. de Paula Figueiredo
>>> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
>>> and instructor
>>> Owner, Ars Machina Tecnologia da Informação Ltda.
>>> http://www.arsmachina.com.br
>>>
>>> ---------------------------------------------------------------------
>>> 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 Igor Drobiazko <ig...@gmail.com>.
What you need is a combination of Loop, Delegate, and SubmitNotifier
components and a couple of blocks inside your template. Check this out:

http://code.google.com/p/tapestrybook/source/browse/trunk/tapestry-dynamic-forms/src/main/webapp/ViewReport.tml
http://code.google.com/p/tapestrybook/source/browse/trunk/tapestry-dynamic-forms/src/main/java/de/t5book/pages/ViewReport.java

On Sat, Sep 18, 2010 at 12:03 AM, Антон Мезерный <an...@gmail.com>wrote:

> And what is the best way to create such a dynamic form? Using Delegate
> component or modifying beaneditform? Or maybe there is better approach?
>
> I tried to write it using Delegate and I have a problem - I can't get
> component instance from ComponentSource - Exception:
>
> org.apache.tapestry5.internal.services.RenderQueueException
> Render queue error in BeginRender[Step:dynamicformfield.delegate]: Failure
> reading parameter 'to' of component Step:dynamicformfield.delegate: Unable
> to resolve 'textfield' to a known page name. Available page names: (blank),
> About, Contact, ExceptionReport, Index, PropertyDisplayBlocks,
> PropertyEditBlocks, ServiceStatus, Step.
>
> Why is it looking for a page, not component?
>
> 2010/9/17 Thiago H. de Paula Figueiredo <th...@gmail.com>
>
> > On Thu, 16 Sep 2010 19:09:05 -0300, Антон Мезерный <
> > anton.mezerny@gmail.com> wrote:
> >
> >  Hello,
> >>
> >
> > Hi!
> >
> >
> >  I am trying to make a dynamic form component, something like
> beaneditform,
> >> but based not on bean field type, but on some property in database.
> >>
> >
> > I strongly advise you to read the BeanEditor sources and do something
> > similar or, better yet, contribute viewing and edition blocks. The end of
> > this page shows you how to add blocks:
> > http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html. Besides
> > that, create one of more DataTypeAnalyzer and contribute them to the
> > DataTypeAnalyzer service. See
> > http://tapestry.1045711.n5.nabble.com/Custom-Edit-Block-td2427355.htmlfor
> > a little more detail.
> >
> >
> >  Another words I want to create something like
> >> <t:${componentNameFromDB} ...>
> >>
> >
> > Short answer: you can't. Tapestry pages and components have stricly
> static
> > structure.
> > Long answer: you can use blocks (<t:block>) and the Delegate component to
> > render blocks or components dynamically.
> >
> >
> >  I tried to use delegate component, but as I understood, I should define
> >> all my components (inputs and other) inside one tml-page in block tags
> and
> >>
> >
> > Not necessarily in a single page.
> >
> >
> >  create block instances in java code. Can I do that with separate
> >> components for every element in the form?
> >>
> >
> > Yes.
> >
> >
> >  What is the best way to achieve it?
> >>
> >
> > ComponentSource will help you to grab page instances.
> >
> > --
> > Thiago H. de Paula Figueiredo
> > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> > and instructor
> > Owner, Ars Machina Tecnologia da Informação Ltda.
> > http://www.arsmachina.com.br
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>



-- 
Best regards,

Igor Drobiazko
http://tapestry5.de

Re: Dynamic form

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 17 Sep 2010 19:03:01 -0300, Антон Мезерный  
<an...@gmail.com> wrote:

> And what is the best way to create such a dynamic form?

Provide DataTypeAnalyzer to define new BeanModel types (which are just  
names) and edition and viewing blocks for them. This way, BeanEditForm,  
BeanEditor, Grid, and BeanDisplay will recognize everything automatically.

> I tried to write it using Delegate and I have a problem - I can't get
> component instance from ComponentSource - Exception:
>
> org.apache.tapestry5.internal.services.RenderQueueException
> Render queue error in BeginRender[Step:dynamicformfield.delegate]:  
> Failure reading parameter 'to' of component  
> Step:dynamicformfield.delegate: Unable to resolve 'textfield' to a known  
> page name.

You should pass a block or a component instance. You tried to pass a  
component name.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Dynamic form

Posted by Антон Мезерный <an...@gmail.com>.
And what is the best way to create such a dynamic form? Using Delegate
component or modifying beaneditform? Or maybe there is better approach?

I tried to write it using Delegate and I have a problem - I can't get
component instance from ComponentSource - Exception:

org.apache.tapestry5.internal.services.RenderQueueException
Render queue error in BeginRender[Step:dynamicformfield.delegate]: Failure
reading parameter 'to' of component Step:dynamicformfield.delegate: Unable
to resolve 'textfield' to a known page name. Available page names: (blank),
About, Contact, ExceptionReport, Index, PropertyDisplayBlocks,
PropertyEditBlocks, ServiceStatus, Step.

Why is it looking for a page, not component?

2010/9/17 Thiago H. de Paula Figueiredo <th...@gmail.com>

> On Thu, 16 Sep 2010 19:09:05 -0300, Антон Мезерный <
> anton.mezerny@gmail.com> wrote:
>
>  Hello,
>>
>
> Hi!
>
>
>  I am trying to make a dynamic form component, something like beaneditform,
>> but based not on bean field type, but on some property in database.
>>
>
> I strongly advise you to read the BeanEditor sources and do something
> similar or, better yet, contribute viewing and edition blocks. The end of
> this page shows you how to add blocks:
> http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html. Besides
> that, create one of more DataTypeAnalyzer and contribute them to the
> DataTypeAnalyzer service. See
> http://tapestry.1045711.n5.nabble.com/Custom-Edit-Block-td2427355.html for
> a little more detail.
>
>
>  Another words I want to create something like
>> <t:${componentNameFromDB} ...>
>>
>
> Short answer: you can't. Tapestry pages and components have stricly static
> structure.
> Long answer: you can use blocks (<t:block>) and the Delegate component to
> render blocks or components dynamically.
>
>
>  I tried to use delegate component, but as I understood, I should define
>> all my components (inputs and other) inside one tml-page in block tags and
>>
>
> Not necessarily in a single page.
>
>
>  create block instances in java code. Can I do that with separate
>> components for every element in the form?
>>
>
> Yes.
>
>
>  What is the best way to achieve it?
>>
>
> ComponentSource will help you to grab page instances.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> 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>.
On Thu, 16 Sep 2010 19:09:05 -0300, Антон Мезерный  
<an...@gmail.com> wrote:

> Hello,

Hi!

> I am trying to make a dynamic form component, something like  
> beaneditform, but based not on bean field type, but on some property in  
> database.

I strongly advise you to read the BeanEditor sources and do something  
similar or, better yet, contribute viewing and edition blocks. The end of  
this page shows you how to add blocks:  
http://tapestry.apache.org/tapestry5.1/guide/beaneditform.html. Besides  
that, create one of more DataTypeAnalyzer and contribute them to the  
DataTypeAnalyzer service. See  
http://tapestry.1045711.n5.nabble.com/Custom-Edit-Block-td2427355.html for  
a little more detail.

> Another words I want to create something like
> <t:${componentNameFromDB} ...>

Short answer: you can't. Tapestry pages and components have stricly static  
structure.
Long answer: you can use blocks (<t:block>) and the Delegate component to  
render blocks or components dynamically.

> I tried to use delegate component, but as I understood, I should define  
> all my components (inputs and other) inside one tml-page in block tags  
> and

Not necessarily in a single page.

> create block instances in java code. Can I do that with separate  
> components for every element in the form?

Yes.

> What is the best way to achieve it?

ComponentSource will help you to grab page instances.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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