Menu

#1874 Constraints on non-input fields spawns several error dialogs

5.0.0
closed-fixed
nobody
None
5
2010-03-30
2010-03-15
No

Example code:

<window>
<zscript><![CDATA[
import org.zkoss.zul.*;

Constraint cons = new Constraint() {
public void validate(Component comp, Object value) throws WrongValueException {
throw new WrongValueException(comp, "You must upload an essence file");
}
};

void doValidation() {
cons.validate(button, null);
}

]]></zscript>
<button id="button" label="Button" onClick="doValidation();"/>
</window>

When the button is clicked, a validation error is triggered and a dialog is shown pointing towards the button (as expected).

Two problems occur here:
1. For every additional click on the button, a new error window pops up, meaning several will be stacked.
2. Only the dialog that was opened last is closable, the others remain indefinitely.

I expect only one dialog to be visible for one element at a time.

I'll add that in this particular example, clicking the dialog will spawn another dialog. I assume that this is because the onClick applies to the dialog as well and I can't tell whether it is expected behavior or not.

Discussion

  • Adam Bergmark

    Adam Bergmark - 2010-03-15
    • summary: Constraints on non-input fields spawns several errors --> Constraints on non-input fields spawns several error dialogs
     
  • jimmy shiau

    jimmy shiau - 2010-03-16

    This is spec,
    It will create a error box when you throws a exception every time

    if you want "only one dialog to be visible for one element at a time"

    you can post a feature request

     
  • jimmy shiau

    jimmy shiau - 2010-03-16
    • status: open --> closed-wont-fix
     
  • jimmy shiau

    jimmy shiau - 2010-03-16
    • status: closed-wont-fix --> closed-fixed
     
  • jimmy shiau

    jimmy shiau - 2010-03-16

    OK,
    Only the dialog that was opened last is closeable
    Fixed since Mar 16 2010

     
  • Adam Bergmark

    Adam Bergmark - 2010-03-17
    • status: closed-fixed --> open-fixed
     
  • Adam Bergmark

    Adam Bergmark - 2010-03-17

    This seems to be inconsistently implemented.
    When i call validate on a textbox the validation only displays once, but when I do it on a button, serveral dialogs are displayed as I showed previously
    Try the following example, clicking the left button will not spawn additional dialogs, while clicking the right one will.

    <?page contentType="text/html;charset=UTF-8"?>
    <zk>
    <zscript><![CDATA[
    import org.zkoss.zul.Constraint;
    import org.zkoss.zk.ui.WrongValueException;
    Constraint con = new Constraint() {
    public void validate(Component comp, Object val) throws WrongValueException {
    throw new WrongValueException(comp, "fail");
    }
    }
    ]]></zscript>
    <window>
    <button onClick="con.validate(textbox, null);" label="Fail on text field"/>
    <button onClick="con.validate(button, null);" label="Fail on button"/>
    <textbox id="textbox"/>
    <button id="button" label="Button"/>
    </window>
    </zk>

     
  • Jumper Chen

    Jumper Chen - 2010-03-30

    Could you test with the latest ZK 5.0.1 version?
    In my environment, the two buttons of "Fail on text field" and "Fail on button" did the same result for me.

     
  • Jumper Chen

    Jumper Chen - 2010-03-30
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.