This project is read-only.


Parameter null in Choices method


I have a Choices method with a parameters. If this parameter is an assosiation not bounded, the parrameter is null. I've tested it just in IE.

Debugging, I found the problem in the NakedObjects-Ajax.js line 756, I have data in the variable encryptValues, but it has no length method, so the if goes througth the else.
            var encryptValues = findValues(encryptParmId);

            if (encryptValues.length > 0) {                   //  <<HERE IS THE ERROR!!!
                for (var v in encryptValues) {
                    inData[v] = encryptValues[v];
            } else {
                var rawValues = findValues(parmId);
                for (var vv in rawValues) {
                    inData[vv] = rawValues[vv];
I changed this line to
            if (Object.keys(encryptValues).length > 0) {
and worked Perfect.

Thanks a lot, Ariel
Closed Mar 21, 2014 at 4:30 PM by RichardPawson


scascarini wrote Jan 6, 2014 at 10:09 AM

This is as intended. the parameter can be null. If you think it's a problem could you explain exactly what the behaviour you're seeing is, why it's a problem and what you would expect to see.

Otherwise if you've tweaked the code yourself and you're happy with the change that's fine. Be aware though there may be other side-effects of the change (I'd suggest just checking for a null parameter is lower risk).

arilani wrote Jan 6, 2014 at 1:14 PM


I really don't understand your answer, so I think you didn't understand my question.

In my model I have this 4 (for simplicity) entities: Country - State - City and Building. (If you want, I can send you the classes to test the problem and the sugested changes).

Building has a reference to the other 3. For testing purpose, Country is not bounded (so I have a Find button) and has a default value. State and City are bounded and both have a Choices<property> method: ChoicesState(Country country) and ChoicesCity(State state).

When I change the State, both Choices<property> methods are executed, but ChoicesState receive the country parameter with null, even when the Country property has a value in the form. My ChoicesState method checks for the null, but in this situation, I expect or to not be called this Choices<property> method because is the trigger property of the Choises refresh or to receive the correct country.

The code change I introduced solve the second problem that I think is generic to the implementation (even if this is not the triggered property) for all the relation parameters not bounded.

I expect you to check the proposed changes to see what you think about them.

Thanks, Ariel

scascarini wrote Jan 6, 2014 at 5:05 PM

OK I'll take a look as soon as I have time.

scascarini wrote Feb 7, 2014 at 2:17 PM

Bug reproduced - fixed with supplied change.

Thanks for report and fix.