Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SetValueMap ordering across different browsers

    SmartClient Version: v8.2p_2012-10-22/PowerEdition Deployment (built 2012-10-22)

    I'm investigating an issue where it appears that the ordering used when placing items in a LinkedHashMap for SetValueMap is not obeyed.

    It appears to come down to a way that different browser JS engines interpret the object iteration spec: see http://stackoverflow.com/questions/280713/elements-order-in-a-for-in-loop

    Here's some example code plugged into the showcase:
    Code:
        public Canvas getViewPanel() {
        	
        	DynamicForm form = new DynamicForm();
    
        	// Set Proxy Server Usage Radio Button
    		final LinkedHashMap< String, String > proxyServerUsageStyleMap = new LinkedHashMap< String, String >();
    		proxyServerUsageStyleMap.put( "1", "On" );
    		proxyServerUsageStyleMap.put( "0", "Off" );
    
    		RadioGroupItem proxyUsageRadio = new RadioGroupItem();
    		proxyUsageRadio.setName( "Use_Proxy" );
    		proxyUsageRadio.setTitle( "Use Proxy" );
    		proxyUsageRadio.setShowTitle( true );
    		proxyUsageRadio.setWidth( 200 );
    		proxyUsageRadio.setVertical( false );
    		proxyUsageRadio.setValueMap( proxyServerUsageStyleMap );
    		proxyUsageRadio.setDisabled( false );
    		proxyUsageRadio.setDefaultValue( "0" );
    		form.setFields(proxyUsageRadio );
          return form;
    }
    You'd expect the radio buttons to appear as On, Off but under Chrome and IE8 they come out as Off, On.

    While this may not seem like a big deal, we have over 400 places in our project where we rely on this. Schemes like changing the values to strings with prefixes are going to be cumbersome to convert as values go in/out of the database.

    Any suggestions? Is there a mechanism to set a value map where ordering will be preserved across all browsers?

    #2
    You meant Chrome and IE9 (not IE8).

    To provide an ordering that browsers will respect, it's now necessary to use the optionDataSource API instead of a static valueMap.

    Comment

    Working...
    X