You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Galen Meurer <ta...@galenmeurer.com> on 2004/12/21 04:08:55 UTC

is there a way to dynamically create a copy-of in a page's Java?

Is there a framework-friendly way to create a new component in a page's or
component's Java based on a component declared in the page's specification?
By this I mean essentially the copy-of functionality, but in the Java. There
is no way for me to know ahead of time how many of these I will need. It is
impossible for me to add copy-of declarations in the page specification as
there will be zero to many depending on the results of a search.

This is used on a page that includes a "finder" component that takes the
results of a search defined in the page's specification and renders a
component that is passed to it as a parameter once for each result row in
the search. Each iteration, it sets a property on this component so that the
details of this row can be rendered by the component. This is typically a
bunch of form elements so that the results can be edited. Furthermore, I
render each of these in an initially hidden div and render tabular results
with an onClick to show this div for that result.

In this way I am able to show a form for editing the details of a found
object without a page refresh. I am able to use a generic finder for all
these components and simply render the passed in component in a loop.

I should mention that up to here this all works great. However, I have had
trouble with validation and today I discovered why. Because it's the same
component rendered over and over, all the ValidFields are the same (as are
all contained components). When there's a validation error, the rendering of
each is affected. So, if the user left out a required field in one of them,
the render of all of them will be missing that field value on the next
render iteration.

My thought was to use the implicit component creation in the PageLoader, but
the PageLoader needs an engine and it only sets the engine when a full page
is being loaded and it nulls the _engine when it's done. There is no setter
for an engine.  So, calling createImplicitComponent always results in an
NPE.

I'm thinking that this is a dead end.

Has anybody done this? Can anybody point me in a (different) direction?

Your help will be greatly appreciated!

Thanks very much,
Galen


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


Re: is there a way to dynamically create a copy-of in a page's Java?

Posted by Howard Lewis Ship <hl...@gmail.com>.
The typical approach is to pass the component inside a Block as a parameter.


On Mon, 20 Dec 2004 19:08:55 -0800, Galen Meurer
<ta...@galenmeurer.com> wrote:
> Is there a framework-friendly way to create a new component in a page's or
> component's Java based on a component declared in the page's specification?
> By this I mean essentially the copy-of functionality, but in the Java. There
> is no way for me to know ahead of time how many of these I will need. It is
> impossible for me to add copy-of declarations in the page specification as
> there will be zero to many depending on the results of a search.
> 
> This is used on a page that includes a "finder" component that takes the
> results of a search defined in the page's specification and renders a
> component that is passed to it as a parameter once for each result row in
> the search. Each iteration, it sets a property on this component so that the
> details of this row can be rendered by the component. This is typically a
> bunch of form elements so that the results can be edited. Furthermore, I
> render each of these in an initially hidden div and render tabular results
> with an onClick to show this div for that result.
> 
> In this way I am able to show a form for editing the details of a found
> object without a page refresh. I am able to use a generic finder for all
> these components and simply render the passed in component in a loop.
> 
> I should mention that up to here this all works great. However, I have had
> trouble with validation and today I discovered why. Because it's the same
> component rendered over and over, all the ValidFields are the same (as are
> all contained components). When there's a validation error, the rendering of
> each is affected. So, if the user left out a required field in one of them,
> the render of all of them will be missing that field value on the next
> render iteration.
> 
> My thought was to use the implicit component creation in the PageLoader, but
> the PageLoader needs an engine and it only sets the engine when a full page
> is being loaded and it nulls the _engine when it's done. There is no setter
> for an engine.  So, calling createImplicitComponent always results in an
> NPE.
> 
> I'm thinking that this is a dead end.
> 
> Has anybody done this? Can anybody point me in a (different) direction?
> 
> Your help will be greatly appreciated!
> 
> Thanks very much,
> Galen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


-- 
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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