private void renderJQueryAfterComponent ( ResponseWriter rw , String clientId , SelectOneMenu menu ) throws IOException { Boolean select2 = menu . isSelect2 ( ) ; if ( select2 != null && select2 ) { rw . startElement ( "script" , menu ) ; rw . writeAttribute ( "type" , "text/javascript" , "script" ) ; StringBuilder buf = new StringBuilder ( "$(document).ready(function(){" ) ; buf . append ( "\n" ) ; // jquery selector for the ID of the select component buf . append ( " $(\"[id='" ) . append ( clientId ) . append ( "']\")" ) ; // select2 command to enable filtering buf . append ( ".select2();" ) ; buf . append ( "\n" ) ; buf . append ( "});" ) ; rw . writeText ( buf . toString ( ) , "script" ) ; rw . endElement ( "script" ) ; } }
render a jquery javascript block after the component if necessary