Franz Amador wrote: > Hi, all. I asked about this a while ago, and there was no good answer > then, but I'm hoping that there are new options now. I have a bean > that holds information about a database connection. I'm editing it > with BeanEditForm. One of the fields is the database type, an enum > that renders as a dropdown. Another field is the database-server > port. When the user picks a database type from the dropdown, I want > to update the database port to the default value for that database > type (e.g. 1521 for Oracle), while leaving the other fields alone. Is > there a good way to do this? > > I see there's now a zone parameter to BeanEditForm that causes the > specified zone to be updated when the form is submitted. This sounds > promising, but I don't see how to make it work for my case. > > 1) I would need to make the form auto-submit when the user picks a > value from the dropdown. I don't know how to do that, but there must > be a way. > > Why would you need to submit the form when a value is selected from the list? If you know the available DBs before hand, then you know the default ports. Store those as a client-side JSON object and use the select's onchange event. > 2) I would need a way to prevent validation from complaining about > missing or errant fields during the form auto-submit, but to have > validation work normally during a regular form submit (via the submit > button). > > 3) I would need the form to do an Ajax zone update on an auto-submit > (for a zone containing the form itself), but not on a regular form > submit. > > On the whole, I prefer Tapestry 5 to Wicket, but for Ajax, I think > Wicket's approach has some advantages. In Wicket, you can register an > event listener on a component (e.g. an on-change listener on a > dropdown). When the event happens, the listener method gets passed a > list to which it appends components that should be re-rendered. While tapestry's Ajax support is still in the oven, it has @OnEvent which does something similar. > In my > case, I'd append the database-port-field component to the list when > the database-type enum changes value. This approach allows me to > update multiple components anywhere on the page in response to any > event, with no need for a special update-target-wrapper component like > Zone. (You do have to call "setOutputMarkupId(true)" when creating a > component that can be rendered via Ajax.) > > I hope this doesn't come across as a "Wicket is better than Tapestry" > taunt. I've experimented with both at some length, and I find > Tapestry 5 tighter and leaner and faster. However, I really need > richer Ajax tools, and I think the Wicket approach is worth looking > at. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > >
-- http://thegodcode.net --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]