Richard Wallace wrote:
Werner Punz wrote:

Richard Wallace wrote:

Werner Punz wrote:

Richard Wallace wrote:

Ok, but how should I "tinker" with the element tree? I'm guessing AJAX will need to come into play. But how do I get access to the element tree? And exactly how should I manipulate it? I'm guessing there's no ready to go methods already in the JSF APIs to accomplish this, are there?

I think you have a small misunderstanding here what JSF is and what you can do.




I completely understand that.

You cannot alter the backend element tree without any refresh, so you have to force a refresh to do that in the backend.




That's why I was wondering if AJAX could be used when a new form element is being created to modify the backend element tree without having to refresh the whole page.

Ok a misunderstanding from my part, to my knowlege, you cannot really do that, because the element tree is rebuilt at each subsequent request. The safest bet is to stay on the ajax/client side only for what you want to achieve, and once you hit a refresh, fetch the ajaxed part directly from the request object if you need to do further processing on it.

What you also could do is to componentize the ajaxed part of your form, that way you could establish a connection between the element tree and your ajaxed part of your form.


Then the flow would look like that...
pure client side... do anything with the ajax elements

submit or something else which causes a refresh:
the value binding and binding mechanisms transfers the values from the ajaxed components to the backend beans for further processing.


The third way could be to have the form parameters parsed at request level and then the component subtree rebuilt at the subsequent refresh.
But that approach is probably the messiest of all three.


Actually, on reflection, I can't really think of a good way to get everything I want for free anyways. I think I will need to develop a custom component, probably something that is composed of other existing UI elements. The three primary use cases I'm looking at currently are a dynamic, editable table with at least 2 text fields where rows can be added/removed without the need to roundtrip to the server, an editable, dynamic table with a drop down list and a text field in a row where rows can be added/removed without roundtripping and an element where a user can add multiple file upload elements without having to roundtrip. i don't really see a way this can all be done in JSF without using custom elements.

Of course, I'm open to suggestions.


Not really suggestions, I see it as you, there is no real free lunch in this case, but hard work.

But there is a small project on sourceforge which already has an ajax component in place, not something as sophisticated as what you want to do, but you can check it out it might give you a headstart with your things (and also a small push towards donating code yourself if you want :-), your components sound interesting )

the project is http://sourceforge.net/projects/jsf-comp the only ajax component currently is an autocomplete field, which basically does some element tinkering (blends in a filled div on demand which simulates a drop down box), also there is an excellent OO javascript library which is under MIT license, which delivers some effects and good ajax classes.

The ajax component however does not use the Prototype OO lib yet, it still uses a somewhat hackish messy code which was taken from the Sun blueprints catalog and hacked in no time to IE compatibility.

Also there is the Sun blueprints catalog which has some ajax stuff in there already, on java.net.

Reply via email to