1

wrong valueException come in front of modal popup [closed]

asked 2014-06-13 06:46:51 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

updated 2014-06-16 13:39:40 +0800

Hi all,

I have a little problem with the following.(MVC)
Assume I have the following textbox :

<customtextbox constraint="no empty" ctrlKeys="^l"/>

Now on the control key we will open a catalog popup.
If the textbox is empty I will get a WrongValueException because the focus is lost of the textbox. The notification balloon pops up in front of mine catalog.

I tried before opening the modal popup :

Clients.clearWrongValue(this.textbox);

and

Clients.clearWrongValue(this);

(the this is a class that extends HtmlMacroComponent and the textbox is wired)

The popup is still there while he shouldn't be there.
Any other solutions you can suggest?

Edit : After fully debugging what the problem could be I came to the following conclusion :

With the lose of focus, I run a java script for the constraint to check if it is not null.
Because it is null, the java script opens the errormessage.
It's java script what's killing me.
Is there a possibility to disable the java-script validation with the constraint propertie?

How debugged

  1. Class overriding of Textbox.
    Add extra logging to see where the WrongValueException is coming from.
    Nu succes.
  2. Class overriding of InputElement.
    Add extra logging to see where the WrongValueException is coming from..
    Nu succes.
  3. Class overriding of WrongValueException.
    Add extra logging to all the constructors so I would see where this Exception is created.
    No such exception is created while opening the catalog, but the error message is still there.

So th eonly solution is that it is coming from java script with the focus lost event.
For me it's a bug cause constraint error message should appear in the window where the component is, not overlapping other windows who stands higher in the chain, like a messagePopup or a new window.

Greetz chill.

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by chillworld
close date 2015-04-02 05:05:49

Comments

1

This is one of the reason, i move to Server side validation. you have to manually click to close the warning message.

Senthilchettyin ( 2014-06-13 08:27:47 +0800 )edit

I'm debugging atm, seems I call the clear before the WrongValueException. I can follow you completly why you did that

chillworld ( 2014-06-13 08:48:13 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-06-16 07:51:19 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

updated 2014-06-17 08:30:18 +0800

Oke found it.

The custom component is now like this :

<hbox align="center" id="${arg.id}">
    <textbox cols="9" ctrlKeys="^l" id="personId" 
        readonly="${arg.readonly}" tooltiptext="&gt;Ctrl + L&lt; will open search dialog ">
                    <custom-attributes validation="${arg.constraint}" />
            </textbox>
    <separator width="5px" />
    <textbox readonly="true" cols="30" id="name" tabindex="-1"/>
    <image src="/img/detail.png" id="detail" />
</hbox>

In the controller (extends HtmlMacroComponent implements IdSpace) :

private boolean checkConstraint = true;
private String constraint;

@Override
public void afterCompose() {
    super.afterCompose();
    // some extra code
    constraint = (String) personId.getAttribute("validation");
    String s = null;
    personId.setConstraint(s);
}

public PersonProxy getValue() {
    if (checkConstraint) {
        personId.setConstraint(constraint);
        try {
            personId.getValue(); // needed to throw the error message.
        } finally {
            String s = null;
            personId.setConstraint(s); // ambigious situation String-Constraint when entering null directly.
        }
    }
    return this.person;
}

When the ctrl+ctrl is pressed, I set the checkConstraint to false, and set back true when I close the modal popup.

Greetz chill.

link publish delete flag offensive edit

Comments

I heard that, in web application, even though if you do validation at the client side, you need to do the same in server side also. So better control at server side. I believe, this ZK Constraint will convert into Java script at run time ./

Senthilchettyin ( 2014-06-16 08:31:54 +0800 )edit

The constraint is in fact java code. When you acces the getValue, setValue, getText or setText method it will throw the WrongValueException.

chillworld ( 2014-06-16 08:54:01 +0800 )edit
0

answered 2014-06-16 08:52:21 +0800

RaymondChao gravatar image RaymondChao
386 1 4
ZK Team

updated 2014-06-17 07:21:19 +0800

Hello,

If I only want to check single field, maybe another way is to custom constraint. Skip the validation when open popup, and revalidate textbox when popup closed, as the sample shows. Hope it could help.

link publish delete flag offensive edit

Comments

Raymond, thx for the help but your sample open and close the popup directly when textbow is empty.

chillworld ( 2014-06-16 09:15:15 +0800 )edit

So you want to keep the error message, but the popup should be at the most top?

RaymondChao ( 2014-06-16 09:34:32 +0800 )edit

@RaymondChao I have updated the question.

chillworld ( 2014-06-16 12:59:21 +0800 )edit

The popup works first time. When you select empty or clear the message you can open it a second time but it disappears directly.

chillworld ( 2014-06-16 19:11:42 +0800 )edit

Sorry I only tested ZK 6.5.5 before, I've updated the sample to clear error message first when open menupopup and it could work with ZK 7.0.2. If the sample still does not solve your problem. Please report the issue and provide a reproducible code so we can example it. Thanks.

RaymondChao ( 2014-06-17 07:29:29 +0800 )edit

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-06-13 06:46:51 +0800

Seen: 33 times

Last updated: Jun 17 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More