Re: Inject dynamic number of components
I have a form with many inputs, selects, etc, which I want to submit. Some of these inputs are in some custom components in order to reduce repeating code and to add some specific behavior visual as some dynamic css passed to the custom components and functional as some of them are fileuploads for example so I need to access them and get the files or do something by the submit. The form also have dynamic number of components. Let's say I have a list of people in the db, so when I get the whole list, I want to render a form with upload profile picture for all these people, also some other inputs... so in a loop, I'm listing all these input fields, so after fill in I want to submit the whole form, but right before submits I have to access the UploadedFile-s, which are wrapped in custom component with method which does this. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Inject dynamic number of components
On Mon, 21 Jul 2014 05:14:33 -0300, nn kk inv...@abv.bg wrote: I have a form with many inputs, selects, etc, which I want to submit. Some of these inputs are in some custom components in order to reduce repeating code and to add some specific behavior visual as some dynamic css passed to the custom components and functional as some of them are fileuploads for example so I need to access them and get the files or do something by the submit. The form also have dynamic number of components. Let's say I have a list of people in the db, so when I get the whole list, I want to render a form with upload profile picture for all these people, also some other inputs... so in a loop, I'm listing all these input fields, Again, if you have t:loopt:upload//t:loop, independently of how many times you iterate the loop, you're using a single Upload component and rendering it once per loop iteration. so after fill in I want to submit the whole form, but right before submits I have to access the UploadedFile-s, which are wrapped in custom component with method which does this. These components are editing some property. Read this property instead of asking the components directly. You should avoid calling methods directly on injected components as much as possible. Your approach described above goes against Tapestry's best practices. I think you should turn your custom components into actual form fields, i.e., implement Field and most probably subclass AbstractField. We cannot help much without the source of your components. -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Inject dynamic number of components
Hi all, how can I inject and access dynamic number of custom components, I want to access them in the Java class. I have: loop t:myCustomComponent/ /loop I want to access these components as they are injected and to execute in the onSuccess for everyone of them some method as if it is a single component: @inject MyCustomComponent component; void onSuccess() { component.method(); } I want to the the same for dynamic number of components, created by the loop - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Inject dynamic number of components
On Fri, 18 Jul 2014 19:42:26 -0300, nn kk inv...@abv.bg wrote: Hi all, Hi! how can I inject and access dynamic number of custom components, I want to access them in the Java class. I have: loop t:myCustomComponent/ /loop I'm sorry, but your question doesn't even make sense, because Tapestry doesn't create components instance dynamically. It's all 100% static. The rendering of them, though, is 100% dynamic. In your template above, there are just two component instances, one Loop, one MyCustomComponent, no matter how many times the Loop iterates. A single MyCustomComponent instance will be rendered many times. -- Thiago H. de Paula Figueiredo Tapestry, Java and Hibernate consultant and developer http://machina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Inject dynamic number of components
You need SubmitNotifier: http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/corelib/components/SubmitNotifier.html On Friday, July 18, 2014, nn kk inv...@abv.bg wrote: Hi all, how can I inject and access dynamic number of custom components, I want to access them in the Java class. I have: loop t:myCustomComponent/ /loop I want to access these components as they are injected and to execute in the onSuccess for everyone of them some method as if it is a single component: @inject MyCustomComponent component; void onSuccess() { component.method(); } I want to the the same for dynamic number of components, created by the loop - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org javascript:; For additional commands, e-mail: users-h...@tapestry.apache.org javascript:; -- Dmitry Gusev AnjLab Team http://anjlab.com