Re: CompoundPropertyModel - white space
Thank you, Sven. This is working. As always, The Apache Wicket team ROCKS !! -Mihir. On Tue, Jun 8, 2021 at 3:54 PM Sven Meier wrote: > Hi, > > by default textfields trim their input, so I'd expect the total count > characters to be correct to the processed input: > >"f " + "m" + "l" -> "fml" = 3 characters (also a space was entered > after the *f* > > You might want to override #shouldTrimInput if you want to keep the > whitespace. > > Have fun > Sven > > > On 08.06.21 21:05, Mihir Chhaya wrote: > > Hello, > > > > Apache Wicket version used: 8.12.0 > > > > I need to show total characters entered into First, Middle and Last name > > text fields + one drop down for Suffix. The combined length of these four > > fields should not exceed the set limit. > > For this, I have added OnChangeAjaxBehavior to all the three text fields > + > > the drop down. > > > > These fields are bound to the respective bean properties using > > CompoundProperyModel. The bean has a generic getter method to calculate > > combined length without trimming white space from any field. > > > > Issue: > > The CompoundPropertyModel bean setter method is not called when a white > > space is entered after any letter in the field. > > For example, entering "f" in the first name will call the setter method, > > but entering white space after "f" does not call the setter method until > > the next character is entered. > > This is messing up the total chars count. > > > > Here is how the length looks like without any white space trimming: > > > > (1) F + M + L = "f" + "m" + "l" = 3 > > (2) F + M + L = "f " + "m" + "l" = 3 (Please note the white space after > f) > > (3) F + M + L = "f n" + "m" + "l" = 5 > > > > As one can see, the 2nd scenario is what I am trying to solve. > > > > The OnChangeAjaxBehavior event is called when entering the white space, > but > > the bean setter is not, causing misleading total chars count. > > > > Any suggestions? > > > > Thank you, > > -Mihir. > > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > >
Re: CompoundPropertyModel - white space
Hi, by default textfields trim their input, so I'd expect the total count characters to be correct to the processed input: "f " + "m" + "l" -> "fml" = 3 characters (also a space was entered after the *f* You might want to override #shouldTrimInput if you want to keep the whitespace. Have fun Sven On 08.06.21 21:05, Mihir Chhaya wrote: Hello, Apache Wicket version used: 8.12.0 I need to show total characters entered into First, Middle and Last name text fields + one drop down for Suffix. The combined length of these four fields should not exceed the set limit. For this, I have added OnChangeAjaxBehavior to all the three text fields + the drop down. These fields are bound to the respective bean properties using CompoundProperyModel. The bean has a generic getter method to calculate combined length without trimming white space from any field. Issue: The CompoundPropertyModel bean setter method is not called when a white space is entered after any letter in the field. For example, entering "f" in the first name will call the setter method, but entering white space after "f" does not call the setter method until the next character is entered. This is messing up the total chars count. Here is how the length looks like without any white space trimming: (1) F + M + L = "f" + "m" + "l" = 3 (2) F + M + L = "f " + "m" + "l" = 3 (Please note the white space after f) (3) F + M + L = "f n" + "m" + "l" = 5 As one can see, the 2nd scenario is what I am trying to solve. The OnChangeAjaxBehavior event is called when entering the white space, but the bean setter is not, causing misleading total chars count. Any suggestions? Thank you, -Mihir. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
CompoundPropertyModel - white space
Hello, Apache Wicket version used: 8.12.0 I need to show total characters entered into First, Middle and Last name text fields + one drop down for Suffix. The combined length of these four fields should not exceed the set limit. For this, I have added OnChangeAjaxBehavior to all the three text fields + the drop down. These fields are bound to the respective bean properties using CompoundProperyModel. The bean has a generic getter method to calculate combined length without trimming white space from any field. Issue: The CompoundPropertyModel bean setter method is not called when a white space is entered after any letter in the field. For example, entering "f" in the first name will call the setter method, but entering white space after "f" does not call the setter method until the next character is entered. This is messing up the total chars count. Here is how the length looks like without any white space trimming: (1) F + M + L = "f" + "m" + "l" = 3 (2) F + M + L = "f " + "m" + "l" = 3 (Please note the white space after f) (3) F + M + L = "f n" + "m" + "l" = 5 As one can see, the 2nd scenario is what I am trying to solve. The OnChangeAjaxBehavior event is called when entering the white space, but the bean setter is not, causing misleading total chars count. Any suggestions? Thank you, -Mihir.