Thanks for help!

using default button the reason is:
Only When directly press enter key or click default button(etc. Search
button) , 
page's search conditions will be saved.

When in the page change search conditions and click other button, page's
search conditions will not be saved or changed.
Page's search conditions  still are which are saved at the last time
clicking default button(or press enter key).

Now, I catch form' onSumbit event to look for clicked button. If finded
button is null, I think about the enter key is pressed.
Some source code:
                Form form = new Form("frmCourseSelectRuleList", new
CompoundPropertyModel(courseSelectionRuleSearch)) {
                        protected void onSubmit() {
                                Button button = this.findSubmittingButton();
                                if (null == button) {
                                        
setSearchCondition(courseSelectionRuleSearch, objSearch);  // the same
as default button' procedure
                                }
                        }
                };
                add(form);

... ...
                Button searchButton = new Button("searchButton") {
                        protected void onSubmit() {
                                setSearchCondition(courseSelectionRuleSearch, 
objSearch);
                        }
                };
                form.add(searchButton);

                form.setDefaultButton(searchButton);

The above code may temporarily solve my problem.
If have good ideas, please tell me. Thanks a lot.



Eelco Hillenius wrote:
> 
> interesting, thanks (if it works :))
> 
> Eelco
> 
> On 2/2/07, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
>> ah, but see my tweak
>>
>> now when we look for a submit button and not find one i also check for
>> the
>> default button. so if you do manage to somehow bypass the hidden field
>> and
>> submit the button it should still work.
>>
>> the "problem" i see for this is if you have the default button set and
>> submit the form using javascript form.submit(); but then i dont know if
>> you
>> really do want the default button called or not, i think you still do.
>>
>> also what i did is always move the button off screen instead of making it
>> display:none. maybe some browsers do not let you submit using hidden
>> buttons.
>>
>> -igor
>>
>>
>> On 2/2/07, Eelco Hillenius <[EMAIL PROTECTED]> wrote:
>> >
>> > On 2/2/07, netfork <[EMAIL PROTECTED]> wrote:
>> > >
>> > > test example abracadabra, also can't call default button' onSubmit
>> > method.
>> > >
>> > > Screenshot:
>> > > http://www.nabble.com/file/6211/screenshot2.gif
>> >
>> > That does work for me though...
>> >
>> > The javadoc of setDefaultButton reads:
>> >
>> >         /**
>> >          * Sets the default button. If set (not null), a hidden submit
>> > button will
>> >          * be rendered right after the form tag, so that when users
>> press
>> > enter in a
>> >          * textfield, this button's action will be selected. If no
>> default
>> > button is
>> >          * set (so unset by calling this method with null), nothing
>> > additional is
>> >          * rendered.
>> >          * <p>
>> >          * WARNING: note that this is a best effort only. Unfortunately
>> > having a
>> >          * 'default' button in a form is ill defined in the standards,
>> and
>> > of course
>> >          * IE has it's own way of doing things.
>> >          * </p>
>> >          *
>> >          * @param button
>> >          *            The button to set as the default button, or null
>> > when you want
>> >          *            to 'unset' any previously set default button
>> >          */
>> >
>> > Note the warning. The tactic I used I to put a submit button field
>> > right after the form declaration in HTML and hide it (e.g. in the
>> > wizard: <input type="submit" value="Next &gt;" name="buttons:next"
>> > style="display: none" />). Unfortunately, HTML doesn't have the
>> > concept of a default button. The heuristic in this case is that if you
>> > press enter in a text field, most if not all browsers will choose the
>> > first button that was defined in the form.
>> >
>> > Doing it with javascript (catching onkeypressed or something similar)
>> > would be too intrusive for the framework, though it might be a good
>> > solution for your specific case.
>> >
>> > Eelco
>> >
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/form%27s-DefaultButon%2C-Click%27event-is-invalidation-tf3155687.html#a8778573
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Reply via email to