So you mean the JavaScript should store the path to the component in the hidden field and the form reads this out (if present) looks-up the component and calls some (interface) method on the component. This would be at least JavaScript wise the best solution - I don't know how older browser behave when the name of the input field is changed.

A problem with this aproach is that Form.onFormSubmitted() is final and I don't realy know how to parse the path back because the component ids can be any string - AFAIK.

However also with the current aproach which stays with the 'normal' form and button behaviour, you can bypass the Form.process().

In the following example there is a DropDownChoice with which you can either reset or submit the form. You wouldn't need a roundtrip for that. Anyway important is that the default fromprocessing is turned off, so that JSButton's onSubmit is called directly without involving the form-component and that you can use the same aproach for any tag or component in the page for any JS event.

    class ChoiceForm extends JSForm {

        String choice = "save";
        String value = "";

        public ChoiceForm(String id) {
            super(id);
            setModel(new CompoundPropertyModel(this));

            add(new RequiredTextField("value"));
final DropDownChoice dChoice = new DropDownChoice("choice", Arrays
                    .asList(new String[] { "save", "reset" }));
            add(dChoice);

            JSSubmit sub = new JSSubmit("jssubmit") {
                protected void onSubmit() {
                    dChoice.updateModel();
                    if ("reset".equals(choice)) {
                        value = "";
                    } else {
                        process();//call Form's regular processing
                    }
                };
            };
            sub.setDefaultFormProcessing(false);//!!
            add(sub);
            //add the JS to the choice onChange
dChoice.add(new AttributeModifier("onChange", true, new Model(sub
                    .getTriggerJavaScript())));

        }
          //setter/getters
    }

What I do not know is how to implement a WebMarkupContainer like JSButton so that it does not need a tag in the page-templat.

Christian

On Mon, 21 Nov 2005 22:55:48 +0100, Johan Compagner <[EMAIL PROTECTED]> wrote:

that's not what i mean

Should youre SubmitLink do the normal validation of the form? Is it a normal
submit?
I think so.

But my other example the onChange on a drop down. If that one is triggered
it is not a normal submit
The form shouldn't do anything, so defaultFormProcessing == false but where
is that boolean? It is not a button that is called

So i think by default when the hidden input field of the form where the
event that must be called is in is filled
then the form will not validate it self, so it behaves as a
defaultFormProcessing == false button.
If you want to do a real submit then we should make it easy to call
Form.process() or something.

johan


On 11/21/05, Christian Essl <[EMAIL PROTECTED]> wrote:


> Will check youre code out. i hope this week.
>
> The problem now is that now always should the form completely be
> processed
> and other times is should
> for example a Submit Link should i think process the form. But a
onChange
> listener on a DropDownChoice shouldn't
> That last one shouldn't be a real submit with validation. Just a submit
> to
> keep the current editting values.

Maybe I don't understand you right.

However I think currently you can use a JSButton with
defaultFormProcessing = false. JSButton is a server-only component. It
does not get rendered in html and it is only there to receive onSubmit()
notificatons. It can be triggered with the script gotten from
JSButton.getTriggerJavaScript() ie by the DrowDownChoice-onClick.

Christian
>
> johan
>
>
> On 11/21/05, Christian Essl <[EMAIL PROTECTED]> wrote:
>>
>> > nice!
>>
>> Thanks
>>
>> > what you do in the submit link i want to do in the form itself (so
the
>> > form
>> > generates a hidden input)
>> > Then everything in that form, Links, onChange listenerers will/can
use
>> > that
>> > one to do the form submit but then dispatch the event)
>> >
>> > johan
>>
>> That's much better. Enclosed is the revised code. For demonstration
>> there
>> is also a wicket Button (JSButton) you can use to trigger from outside
>> the
>> form and which does itself not render anything.
>>
>> A SubmitLink has now to be inside a JSForm:
>>
>> JSForm f = new JSForm("linkForm", new CompoundPropertyModel(mod));
>> f.add(new TextField("value1"));
>> f.add(new SubmitLink("link1") {
>> protected void onSubmit() {
>> System.out.println("Link1 was clicked, value1 is: "
>> + mod.getValue1());
>> };
>> });
>> f.add(new SubmitLink("link2") {
>> protected void onSubmit() {
>> System.out.println("Link2 was clicked, value1 is: "
>> + mod.getValue1());
>> };
>> });
>>
>> Manuel please test this new code.
>>
>> Christian
>>
>>
>>



--
Christian Essl





___________________________________________________________
Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier
anmelden: http://mail.yahoo.de



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc. Get Certified Today
Register for a JBoss Training Course. Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user




--
Christian Essl
        

        
                
___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.  Get Certified Today
Register for a JBoss Training Course.  Free Certification Exam
for All Training Attendees Through End of 2005. For more info visit:
http://ads.osdn.com/?ad_id=7628&alloc_id=16845&op=click
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to