one way would be to keep a boolean somewhere that marks if the
component is valid or not...but if i were you i would figure out why
the two requests are fired and how to avoid it. can it be that your
enter key handler does not return false as the last thing and so
doesnt cancel browser's processing of enter key?

-igor


On Feb 18, 2008 6:16 AM, Federico Fanton <[EMAIL PROTECTED]> wrote:
> Hi everyone!
> I'm having a little problem..
> I have an Ajax "editable table" made with rows of custom components similar 
> to AjaxEditableLabel, that while in "edit mode" use a behavior like this one:
>
> protected class EditorBehavior extends AbstractDefaultAjaxBehavior{
>    @Override
>    protected void onComponentTag(ComponentTag tag) {
>       super.onComponentTag(tag);
>       String js="{wicketAjaxGet('" + getCallbackUrl() + 
> "&'+this.name+'='+wicketEncode(this.value)); return false;}";
>       tag.put("onblur", js);
>    }
>
>    @Override
>    protected void respond(AjaxRequestTarget target) {
>       FormComponent c = (FormComponent) getEditorComponent();
>       c.processInput();
>       if(c.hasErrorMessage()){
>          Serializable msg = c.getFeedbackMessage().getMessage();
>          Util.showAlert(target, c, msg.toString());
>       }
>    }
> }
>
>
> (Util.showAlert adds to the component a behavior that shows an alert)
>
> Everything works fine, but I need to add another behavior to intercept when 
> the user presses Enter (bound to onkeyup), so that I can validate the row as 
> a whole.
> When I press enter, two requests are fired: one for onblur and one for 
> onkeyup. My problem is that even if the onblur request finds an error during 
> validation (and shows the corresponding alert), the second request has no way 
> to know that, since feedback messages are cleaned up at the end of each 
> request..
> Any hint on how I could handle this? Should I put a flag somewhere? Or maybe 
> there's a way to stop the second request when my EditorBehavior finds a 
> validation error?
>
> Many thanks for your time!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to