Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Validating a custom field
Validating a custom field [message #1060593] Mon, 27 May 2013 04:27 Go to next message
Urs Beeli is currently offline Urs Beeli
Messages: 167
Registered: October 2012
Location: Bern, Switzerland
Senior Member
I've created a rather complex custom field that lets me select dates using various methods. I now have the requirement that depending on the situation I need to define a minimum and maximum number of days that must be selected.

I was hoping to add some way of checking the currently selected number of days in a method like execValidateValue() after each change of selection and when clicking the ok button.

Is there an easy way to add this functionality without having to implement all of IValueField (which would be massive overkill in my case)? Ideally I would like the functionality to be caught by the form without having to add extra code to the form.
Re: Validating a custom field [message #1060597 is a reply to message #1060593] Mon, 27 May 2013 04:52 Go to previous messageGo to next message
Ivan Motsch is currently offline Ivan Motsch
Messages: 84
Registered: March 2010
Member
What is the base type (super class) of your custom field?
May you share with us some source code? We only need the relevant parts,
cut out the other parts.
Re: Validating a custom field [message #1060624 is a reply to message #1060597] Mon, 27 May 2013 07:22 Go to previous message
Urs Beeli is currently offline Urs Beeli
Messages: 167
Registered: October 2012
Location: Bern, Switzerland
Senior Member
The class definition of my custom field looks as follows:
public abstract class AbstractTagesfilterField extends AbstractCustomField implements ITagesfilterField {

where ITagesfilterField defines a few setters/getters to access the selected days.

However, I think the solution to my problem is easier than I had anticipated. The only "loss" of my solution is that the validation is not executed automatically, but needs to be triggered explicitely in my field.

I've added a method validateValue() which evaluates the min/max limites (defined as configuration properties) and the currently selected number of days. Depending on the outcome it just calls clearErrorStatus()/setErrorStatus() on the field. This is enough to be taken into account when I press the OK button on the form, the only thing that remains is to also use this information to graphically indicate the error status on the control itself. To handle dynamic changes, I am calling validateValue() in my UIFacade whenever a user interaction (mouse click) effects a change in selected days.

Below you see the result of all this (left side: invalid selection, right side: valid selection):
index.php/fa/15059/0/

  • Attachment: kalender.png
    (Size: 150.17KB, Downloaded 42 times)

[Updated on: Mon, 27 May 2013 07:23]

Report message to a moderator

Previous Topic:Change Icon of checkable Table
Next Topic:Logout fails
Goto Forum:
  


Current Time: Tue May 28 03:15:10 EDT 2013

Powered by FUDForum. Page generated in 0.02254 seconds