0

Constraint message dissapear or don't show

asked 2022-02-15 06:00:22 +0800

alexamm gravatar image alexamm
106 4

updated 2022-02-15 06:23:08 +0800

Hi, i have a listbox one column have a decimalbox, when i need to save data i loop the list and i set a custom constraint on each decimalbox, then i loop the listbox again to fire the constraints (set focus, get value). But sometimes the message constraint dissapear, simply doesn't show it, and the red rectangle no show either; i don't know the possible reason. Has anyone had a similar problem?

i'm using MVVM

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2022-02-15 13:54:59 +0800

hawk gravatar image hawk
3185 1 5
http://hawkphoenix.blogsp... ZK Team

If you call getValue() inside, that will throw WrongValueException and break the loop. So you will just trigger one error message in the end.

Hence, it's better to validate it and call decimalbox.setErrorMessage() to show errors for all decimalboxes.

If this is not your case, please show the code about how you trigger constraint errors.

link publish delete flag offensive edit
0

answered 2022-02-16 00:40:59 +0800

alexamm gravatar image alexamm
106 4

@hawk thanks for your answer here the code:

for (Listitem fila:listbox.getItems()) {
    if (fila.getChildren().get(3).getChildren().get(0) instanceof Decimalbox) {
        Decimalbox dbox = (Decimalbox)fila.getChildren().get(3).getChildren().get(0);
        dbox.setFocus(true);
    }
}

button.setFocus(true);

for (Listitem fila:listbox.getItems()) {
    Component comp = fila.getChildren().get(3).getChildren().get(0);
    if (comp instanceof Decimalbox) {
        Decimalbox dbox = (Decimalbox)comp;
        try {
            dbox.getValue();
        } catch (WrongValueException e) {
            LOGGER.error(e.getMessage());
            throw e;
        } 
   }
}
button.setFocus(true);

i don't why sometimes work, sometimes don't

link publish delete flag offensive edit

Comments

something to add, the decimalbox has inplace="true"

alexamm ( 2022-02-16 01:58:16 +0800 )edit

i think i solve it. i add in the catch dbox.setInplace(false) and Clients.wrongValue(comp, e.getMessage()); Now it show the square red on decimalbox

alexamm ( 2022-02-16 06:15:45 +0800 )edit

dbox.getValue() will throw an exception and stop the loop, so you can only trigger the first decimalbox' error.

hawk ( 2022-02-16 18:27:08 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2022-02-15 06:00:22 +0800

Seen: 5 times

Last updated: Feb 16 '22

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