-
1. Re: Submitting form without submit button
ssilvert Aug 28, 2007 9:14 AM (in response to pieter.kuijpers)Yes, I think that's very useful.
I'd rather not overload the meaning of submit(componentID). I'm becoming more and more aware of how important it is to make the meaning of these methods as simple and clear as possible. So I'd rather have a new method for this. The question is what to call it. I'd like something that conveys the meaning. All I can come up with right now is nakedSubmit().
What are your thoughts?
Stan -
2. Re: Submitting form without submit button
ssilvert Aug 28, 2007 9:20 AM (in response to pieter.kuijpers)I just took a look at the HttpUnit javadoc. WebForm has a method called submitNoButton(). Maybe that's what we should call the new method. Also, it looks like that does a submit and ignores any buttons where the plain submit() does not.
So maybe we should name the method submitNoButtion() and also call submitNoButton() instead of submit().
Here is the javadoc for your reference:
http://httpunit.sourceforge.net/doc/api/com/meterware/httpunit/WebForm.html
Stan
http://www.jsfunit.org -
3. Re: Submitting form without submit button
pieter.kuijpers Aug 28, 2007 9:40 AM (in response to pieter.kuijpers)There is a slight difference between submitNoButton of HttpUnit and our method: HttpUnit's submitNoButton is invoked on a Form, where our method is invoked on ClientFacade. We must have a way to identify the form that should be submitted, and my suggestion was to submit the form of the component in the parameter. So it would become
clientFacade.submitNoButton(aComponentId)
as opposed to HttpUnit's
form.submitNoButton()
If we allow an arbitray componentId as parameter to submitNoButton, it will be entirely valid to use a button as componentId, resulting in the confusing
clientFacade.submitNoButton(buttonComponentId)
Maybe it is best to only allow a form component id?
clientFacade.submitNoButton(formId)
looks pretty intuitive to me.
Pieter -
4. Re: Submitting form without submit button
ssilvert Aug 28, 2007 11:55 AM (in response to pieter.kuijpers)Yes, I like the idea of only allowing a formId. That will be quick and easy to add.
Ajax components usually add parameters to the request before submitting. What would you think of having a method like this as well? Is that something your own javascript would commonly do?
clientFacade.submitNoButton(formId, Map extraParams);
Stan -
5. Re: Submitting form without submit button
pieter.kuijpers Aug 30, 2007 7:35 AM (in response to pieter.kuijpers)I haven't come across this need yet, as I don't use Ajax a lot.
Wouldn't it be easier to be able to add extra parameters using clientFacade.setParameter or something like clientFacade.addExtraParameter(id, value)? That would make submitNoButton a little cleaner. Otherwise I can imagine a lot of submitNoButton(formId, null) calls in my code.
Pieter. -
6. Re: Submitting form without submit button
ssilvert Aug 30, 2007 1:44 PM (in response to pieter.kuijpers)"pieter.kuijpers@gmail.com" wrote:
I haven't come across this need yet, as I don't use Ajax a lot.
Wouldn't it be easier to be able to add extra parameters using clientFacade.setParameter or something like clientFacade.addExtraParameter(id, value)? That would make submitNoButton a little cleaner. Otherwise I can imagine a lot of submitNoButton(formId, null) calls in my code.
Pieter.
I wouldn't allow submitNoButton(formId, null). If we did it, we would have two methods:
submitNoButton(formId);
submitNoButton(formId, Map extraParams)
For the second method, it would throw NullPointerException if extraParams is null.
For now, I think I'm going to just implement the first one. There is already a way to do the second one using the org.jboss.jsfunit.facade.WebRequestFactory. But it takes a little more work as you have to do:ClientFacade client = new ClientFacade("/mypage.jsf"); WebRequestFactory reqFactory = new WebRequestFactory(client); PostMethodWebRequest request = reqFactory.buildRequest("myformid"); // manipulate the request (setParameter, removeParameter, setHeaderField, etc) client.doWebRequest(request);
Also, I'm thinking of removing the no-arg submit() method. We should encourage all forms to have an ID.
Stan Silvert
http://www.jsfunit.org -
7. Re: Submitting form without submit button
ssilvert Aug 31, 2007 2:02 PM (in response to pieter.kuijpers)I implemented ClientFacade.submitNoButton(). It didn't turn out the way we planned. In looking at the rest of the API, it was hard to justify the requirement of using a formID. The only place a specific kind of component is required is the ClientFacade.submit(submitButtionId). In that one, you need to specify which button you want to press. Everywhere else, including in the WebRequestFactory, you can just pass any componentId and it will find the form for you and do the right thing.
Also, I started to think, what if you don't know the form id or you can't easily get it?
Anyhow, what is there might be wrong, but let's try it and see how things go. I've updated the online javadoc so everyone can see the very latest for the Core APIs. You can view that here:
http://labs.jboss.com/file-access/default/members/jsfunit/freezone/apidocs/index.html
There is no doubt that this will change some more. By definition, a facade is a simplification of an existing API and its design comes down to taste. I find this kind of thing really hard because I'm not sure my taste is that good. But time will tell if developers like it. And it's easy to change...
Stan
http://www.jsfunit.org