How to know programmatically the actual modified component? - java-me

In J2ME there is the interface ItemStateListener which can detect exactly the item which is being changed. Is there a similar way in LWUIT ? I tried using the DataChangedListener interface but it gives the character position within the TextField , or -1 , for the index argument ! So ....

Initially set the boolean value to false and add the listener for the components then if any event occurs on that components, set the boolean value to true. Use the addDataChangeListener(It only for TextField) or addActionListener for the components. On addDataChangeListener returns two index values. Initially returns -1 and then returns current text position of the TextField. AFAIK On TextField, they set the default index value is -1 for fireDataChanged on setText method. That is why it will returns -1 initially.

Related

implementing GDC with applescriptobjc

I am making this simple ApplescriptObjC cocoa app just as an exercise for me to understand the multi treading, it is a text field and a label, I was trying to update the label in real time while typing in the text field, but it only get updated once I press enter but not in real time, any idea how I can make that work? here is the code.
Thanks
script AppDelegate
property parent : class "NSObject"
property prgLabel: missing value
property subjectFeild: missing value
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
activate
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
on textChange_(sender)
set SU to subjectFeild's stringValue() as string
prgLabel's setStringValue_(SU)
end textChange_
end script
1) Set the delegate of the textfield to be your app delegate.
2) Implement controlTextDidChange, which is called every time the text field changes during editing.
script AppDelegate
property parent : class "NSObject"
-- IBOutlets
property theWindow : missing value
property prgLabel: missing value
property subjectFeild: missing value
on applicationWillFinishLaunching:aNotification
subjectFeild's setDelegate:me
end applicationWillFinishLaunching_
on controlTextDidChange:notification
prgLabel's setStringValue:subjectFeild's stringValue()
end
end script

What is the difference between `id` and `pos` n a Spinner's OnItemSelectedListener?

When creating a Spinner, I assign an OnItemSelectedListener using setOnItemSelectedListener. When a select an item in the spinner, the onItemSelected method is called, with arguments including position and id.
From my observations, position and id always have the same values. Is there any difference in the meaning of these values when using an OnItemSelectedListener with a Spinner?

Setter method is not called when the text is deleted in an InputText field bounded to a property in Oracle MAF

I have the following inputText field in MAF.
< amx:inputText value="#{bindings.searchCivilID.inputValue}" label="civil id" id = "it1">
The setter setSearchCivilID() is called each time when i change the text in the field. (like - from "1" to "12").
But when I try to delete the text or totally remove the text , the setter method is not called and hence the previous value is retained in the property.
Can you guys help me out in this?
Thanks,
Haleem.
Tick the check box:" Notify listeners when property changes" while generating generating get() and set() . so when the value of the field changes it will fire the method propertyChangeSupport.firePropertyChange("<your_variable_name>",oldValue,newValue)

How can i get value from geb content?

I have some geb content like this
buttonName(wait: true){$("a.btn_primary")}
I need get value from {} i.e. i need string $("a.btn_primary")
For example def value = "$("a.btn_primary")"
If your buttonName is correct, then try this:
def value = buttonName.text()
Cheers!
Try
def value = buttonName.value()
if .text() does not work.
From The Book of Geb,
"The value of input, select and textarea elements can be retrieved and set with the value method. Calling value() with no arguments will return the String value of the first element in the Navigator.
Calling value(value) will set the current value of all elements in the Navigator. The argument can be of any type and will be coerced to a String if necessary. The exceptions are that when setting a checkbox value the method expects a boolean (or, an existing checkbox value) and when setting a multiple select the method expects an array or Collection of values."
Hope it works out!

UltraNumericEditor allows values larger than MaxValue setting

Using infragistics UltraNumericEditor, if I set the .MaxValue to 50, the control will allow me to enter decimals larger than the limit (for example, 50.99)
I see the same behavior if I set the .MaxValue property to 50.01 (can set values larger)
I can obviously resolve this in code but resetting the value, but it seems like the control should do this on its own.
Is there something I'm missing in how to use these properties correctly?
I suppose you are using the UltraNumericEditor with the property Style set to Decimal (or Double).
In this case the control allows you to insert digits that render the input invalid with respect to the property MaxValue. However, by default, you are not able to exit the control until the value is correct.
If you want, you can use the event ValidationError that gives your the ValidationErrorEventArgs parameter. This parameter contains the LastValidValue property to reset the wrong value, the RetainFocus to let your user exit from the editor (or, if you prefer, display an error message)
private void ultraNumericEditor1_ValidationError(object sender, ValidationErrorEventArgs e)
{
// Reset the content to the last valid value and allow the exit from the editor
ultraNumericEditor1.Value = e.LastValidValue;
e.RetainFocus = false;
// In alternative display a message, but leave the wrong value to be reedited
// DisplayValidationMessage("The max value allowed is 50.00");
}
The problem was a result of the IEditorDataFilter for percentage values.
Infragistics recommends, and I had implemented, an IEditorDataFilter which converts decimal percentages (.5 = 50%) into percentages for display.
This filter is applied before the validation for the control takes place. Therefore, setting the MaxValue to "50" allowed me to enter "50.99" but not "51"... normally this would have caused a validation error as per Steve's answer. However, because of the IEditorDataFilter applied to this control, the value was automatically converted to .5099 and this new value does not violate the constraint.
The solution I implemented was to check the value in the Validated event to see if it was larger than the MaxValue / 100, and if so to set it equal to the same.

Resources