Hmmmm... an interesting question.
Well, the JSF component tree is forever in your forming hands, so what you could do is write e.g. a custom form which looks at the request values and does something with the component tree if a new, unknown parameter shows up. (It's easy to add components, just create a new one and add it to its parent). I am not sure though if submitting would work in all cases (especially if you clicked on a link). You might as well try it out, we have never had a use-case like this. All we did was hiding and showing fields depending on some javascript wise changed status. regards, Martin On 6/19/05, Richard Wallace <[EMAIL PROTECTED]> wrote: > Thanks, I understand how to do it on the javascript side. I'm just not > sure how to translate it into something the JavaServer Faces will be > able to understand. Optimally, of course, the values of the new > elements would be bound to the backing bean in the same way as any other > values. The difficulty is, of course, changing the state on either the > client or the server side so it is restored in the restore view phase. > If someone can tell me how to do that, I will be forever grateful. > > Rich > > David G. Friedman wrote: > > >Richard, > > > >I am still learning about MyFaces so I can only give you the JavaScript/DOM > >portion of the solution. I can't yet give you information on how to name > >your fields to work with a map/list/set backed Managed bean. I'm hoping > >this will get you far enough along so your MyFaces skills can fill in the > >gaps past my own light DOM/JavaScript knowledge. > > > >A good reference link (for me) was: > >http://www.mozilla.org/docs/dom/technote/tn-dom-table/#quick > > > >My test file used an input button on my form with an onClick like so: > > > >javascript:addFieldPlusLineBr(this);return false; > > > >To invoke a JavaScript example method of my own making to add a text field > >and line break to the form: > > > ><script language="javascript"> > >function addFieldPlusLineBr(input) { > > var form = input.form; > > alert("hello"); > > var inputNode = document.createElement("input"); > > form.appendChild(document.createElement("br")); > > inputNode.setAttribute("name","fred"); > > inputNode.setAttribute("value","fredValue"); > > form.appendChild(inputNode); > >} > ></script> > > > >Your trick will be figuring out how to place it exactly WHERE you want it in > >your form. The link I mentioned should include various methods you could > >invoke to add it after the element, or elements, of your choice. > > > >Good luck! > > > >Regards, > >David > > > >-----Original Message----- > >From: Richard Wallace [mailto:[EMAIL PROTECTED] > >Sent: Saturday, June 18, 2005 11:10 PM > >To: MyFaces Discussion > >Subject: Re: Dynamically adding form elements client-side > > > > > >David G. Friedman wrote: > > > > > > > >>Richard, > >> > >>Are you talking about hiding/showing the fields (such as using a CSS style) > >>or completely adding to the page without a resubmit? > >> > >> > >> > >> > >> > >Completely adding a new element to the form. > > > > > > > >>Regards, > >>David > >> > >>-----Original Message----- > >>From: Richard Wallace [mailto:[EMAIL PROTECTED] > >>Sent: Saturday, June 18, 2005 11:04 PM > >>To: MyFaces Discussion > >>Subject: Dynamically adding form elements client-side > >> > >> > >>Hello again, > >> > >>I'm trying to figure out how, if it's possible to add form elements, > >>like text fields, when a user clicks an add button without having to > >>have the page resubmit. I'm not even sure it's 100% possible unless the > >>STATE_SAVING_METHOD is client. And then the javascript would have to > >>manipulate that hidden field. Or do some kind of AJAX operation to > >>modify the state when it's being stored server side. At this point, I > >>think if anything prevents us from adopting JSF at work it would be > >>dynamically adding form elements. Any suggestions? > >> > >>Thanks, > >>Rich > >> > >> > >> > >> > >> > > > > > > > >

