@ Override public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WSingleSelect listBox = ( WSingleSelect ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; String dataKey = listBox . getListCacheKey ( ) ; boolean readOnly = listBox . isReadOnly ( ) ; int rows = listBox . getRows ( ) ; xml . appendTagOpen ( "ui:listbox" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , listBox . isHidden ( ) , "true" ) ; if ( readOnly ) { xml . appendAttribute ( "readOnly" , "true" ) ; } else { xml . appendOptionalAttribute ( "data" , dataKey != null , dataKey ) ; xml . appendOptionalAttribute ( "disabled" , listBox . isDisabled ( ) , "true" ) ; xml . appendOptionalAttribute ( "required" , listBox . isMandatory ( ) , "true" ) ; xml . appendOptionalAttribute ( "submitOnChange" , listBox . isSubmitOnChange ( ) , "true" ) ; xml . appendOptionalAttribute ( "toolTip" , component . getToolTip ( ) ) ; xml . appendOptionalAttribute ( "accessibleText" , component . getAccessibleText ( ) ) ; xml . appendOptionalAttribute ( "rows" , rows >= 2 , rows ) ; String autocomplete = listBox . getAutocomplete ( ) ; xml . appendOptionalAttribute ( "autocomplete" , ! Util . empty ( autocomplete ) , autocomplete ) ; } xml . appendAttribute ( "single" , "true" ) ; xml . appendClose ( ) ; // Options List < ? > options = listBox . getOptions ( ) ; boolean renderSelectionsOnly = readOnly || dataKey != null ; if ( options != null ) { int optionIndex = 0 ; Object selectedOption = listBox . getSelected ( ) ; for ( Object option : options ) { if ( option instanceof OptionGroup ) { xml . appendTagOpen ( "ui:optgroup" ) ; xml . appendAttribute ( "label" , ( ( OptionGroup ) option ) . getDesc ( ) ) ; xml . appendClose ( ) ; for ( Object nestedOption : ( ( OptionGroup ) option ) . getOptions ( ) ) { renderOption ( listBox , nestedOption , optionIndex ++ , xml , selectedOption , renderSelectionsOnly ) ; } xml . appendEndTag ( "ui:optgroup" ) ; } else { renderOption ( listBox , option , optionIndex ++ , xml , selectedOption , renderSelectionsOnly ) ; } } } if ( ! readOnly ) { DiagnosticRenderUtil . renderDiagnostics ( listBox , renderContext ) ; } xml . appendEndTag ( "ui:listbox" ) ; }
Paints the given WSingleSelect .