idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
19,000 | private static WComponent loadUI ( final String key ) { String classname = key . trim ( ) ; try { Class < ? > clas = Class . forName ( classname ) ; if ( WComponent . class . isAssignableFrom ( clas ) ) { WComponent instance = ( WComponent ) clas . newInstance ( ) ; LOG . debug ( "WComponent successfully loaded with class name \"" + classname + "\"." ) ; return instance ; } else { throw new SystemException ( "The resource with the name \"" + classname + "\" is not a WComponent." ) ; } } catch ( Exception ex ) { LOG . error ( "Unable to load a WComponent using the resource name \"" + classname + "\"" , ex ) ; boolean friendly = ConfigurationProperties . getDeveloperErrorHandling ( ) ; FatalErrorPageFactory factory = Factory . newInstance ( FatalErrorPageFactory . class ) ; WComponent errorPage = factory . createErrorPage ( friendly , ex ) ; return errorPage ; } } | Attempts to load a UI using the key as a class name . |
19,001 | private void addList ( final WList . Type type , final WList . Separator separator , final boolean renderBorder , final WComponent renderer ) { WList list = new WList ( type ) ; if ( separator != null ) { list . setSeparator ( separator ) ; } list . setRenderBorder ( renderBorder ) ; list . setRepeatedComponent ( renderer ) ; add ( list ) ; lists . add ( list ) ; } | Adds a list to the example . |
19,002 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WMenu menu = ( WMenu ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; int rows = menu . getRows ( ) ; xml . appendTagOpen ( "ui:menu" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; switch ( menu . getType ( ) ) { case BAR : xml . appendAttribute ( "type" , "bar" ) ; break ; case FLYOUT : xml . appendAttribute ( "type" , "flyout" ) ; break ; case TREE : xml . appendAttribute ( "type" , "tree" ) ; break ; case COLUMN : xml . appendAttribute ( "type" , "column" ) ; break ; default : throw new IllegalStateException ( "Invalid menu type: " + menu . getType ( ) ) ; } xml . appendOptionalAttribute ( "disabled" , menu . isDisabled ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , menu . isHidden ( ) , "true" ) ; xml . appendOptionalAttribute ( "rows" , rows > 0 , rows ) ; switch ( menu . getSelectionMode ( ) ) { case NONE : break ; case SINGLE : xml . appendAttribute ( "selectMode" , "single" ) ; break ; case MULTIPLE : xml . appendAttribute ( "selectMode" , "multiple" ) ; break ; default : throw new IllegalStateException ( "Invalid select mode: " + menu . getSelectMode ( ) ) ; } xml . appendClose ( ) ; MarginRendererUtil . renderMargin ( menu , renderContext ) ; paintChildren ( menu , renderContext ) ; xml . appendEndTag ( "ui:menu" ) ; } | Paints the given WMenu . |
19,003 | public SearchInAppResponse searchInApp ( int appId , String query , Boolean counts , Boolean highlights , Integer limit , Integer offset , ReferenceTypeSearchInApp refType , String searchFields ) { WebResource resource = getResourceFactory ( ) . getApiResource ( "/search/app/" + appId + "/v2" ) ; resource = resource . queryParam ( "query" , query ) ; if ( counts != null ) { resource = resource . queryParam ( "counts" , counts ? "1" : "0" ) ; } if ( highlights != null ) { resource = resource . queryParam ( "highlights" , highlights ? "1" : "0" ) ; } if ( limit != null ) { resource = resource . queryParam ( "limit" , limit . toString ( ) ) ; } if ( offset != null ) { resource = resource . queryParam ( "offset" , offset . toString ( ) ) ; } if ( refType != null ) { resource = resource . queryParam ( "ref_type" , refType . toString ( ) ) ; } if ( searchFields != null && ! searchFields . equals ( "" ) ) { resource = resource . queryParam ( "search_fields" , searchFields ) ; } return resource . get ( SearchInAppResponse . class ) ; } | Searches in all items files and tasks in the application . The objects will be returned sorted descending by the time the object had any update . |
19,004 | private void renderOption ( final WMultiSelect listBox , final Object option , final int optionIndex , final XmlStringBuilder html , final List < ? > selections , final boolean renderSelectionsOnly ) { boolean selected = selections . contains ( option ) ; if ( selected || ! renderSelectionsOnly ) { String code = listBox . getCode ( option , optionIndex ) ; String desc = listBox . getDesc ( option , optionIndex ) ; html . appendTagOpen ( "ui:option" ) ; html . appendAttribute ( "value" , code ) ; html . appendOptionalAttribute ( "selected" , selected , "true" ) ; html . appendClose ( ) ; html . appendEscaped ( desc ) ; html . appendEndTag ( "ui:option" ) ; } } | Renders a single option within the list box . |
19,005 | public void paint ( final RenderContext renderContext ) { super . paint ( renderContext ) ; if ( ! DebugUtil . isDebugFeaturesEnabled ( ) || ! ( renderContext instanceof WebXmlRenderContext ) ) { return ; } XmlStringBuilder xml = ( ( WebXmlRenderContext ) renderContext ) . getWriter ( ) ; xml . appendTag ( "ui:debug" ) ; writeDebugInfo ( getUI ( ) , xml ) ; xml . appendEndTag ( "ui:debug" ) ; } | Override paint to render additional information for debugging purposes . |
19,006 | protected void writeDebugInfo ( final WComponent component , final XmlStringBuilder xml ) { if ( component != null && ( component . isVisible ( ) || component instanceof WInvisibleContainer ) ) { xml . appendTagOpen ( "ui:debugInfo" ) ; xml . appendAttribute ( "for" , component . getId ( ) ) ; xml . appendAttribute ( "class" , component . getClass ( ) . getName ( ) ) ; xml . appendOptionalAttribute ( "type" , getType ( component ) ) ; xml . appendClose ( ) ; xml . appendTagOpen ( "ui:debugDetail" ) ; xml . appendAttribute ( "key" , "defaultState" ) ; xml . appendAttribute ( "value" , component . isDefaultState ( ) ) ; xml . appendEnd ( ) ; xml . appendEndTag ( "ui:debugInfo" ) ; if ( component instanceof WRepeater ) { WRepeater repeater = ( WRepeater ) component ; List < UIContext > contexts = repeater . getRowContexts ( ) ; for ( int i = 0 ; i < contexts . size ( ) ; i ++ ) { UIContextHolder . pushContext ( contexts . get ( i ) ) ; try { writeDebugInfo ( repeater . getRepeatedComponent ( i ) , xml ) ; } finally { UIContextHolder . popContext ( ) ; } } } else if ( component instanceof WCardManager ) { writeDebugInfo ( ( ( WCardManager ) component ) . getVisible ( ) , xml ) ; } else if ( component instanceof Container ) { final int size = ( ( Container ) component ) . getChildCount ( ) ; for ( int i = 0 ; i < size ; i ++ ) { writeDebugInfo ( ( ( Container ) component ) . getChildAt ( i ) , xml ) ; } } } } | Writes debugging information for the given component . |
19,007 | private String getType ( final WComponent component ) { for ( Class < ? > clazz = component . getClass ( ) ; clazz != null && WComponent . class . isAssignableFrom ( clazz ) ; clazz = clazz . getSuperclass ( ) ) { if ( "com.github.bordertech.wcomponents" . equals ( clazz . getPackage ( ) . getName ( ) ) ) { return clazz . getName ( ) ; } } return null ; } | Tries to return the type of component . |
19,008 | public static void deserializeSessionAttributes ( final HttpSession session ) { File file = new File ( SERIALIZE_SESSION_NAME ) ; FileInputStream fis = null ; ObjectInputStream ois = null ; if ( file . canRead ( ) ) { try { fis = new FileInputStream ( file ) ; ois = new ObjectInputStream ( fis ) ; List data = ( List ) ois . readObject ( ) ; for ( Iterator i = data . iterator ( ) ; i . hasNext ( ) ; ) { String key = ( String ) i . next ( ) ; Object value = i . next ( ) ; session . setAttribute ( key , value ) ; } } catch ( Exception e ) { LOG . error ( "Failed to read serialized session from " + file , e ) ; } finally { if ( ois != null ) { StreamUtil . safeClose ( ois ) ; } else { StreamUtil . safeClose ( fis ) ; } } } else { LOG . warn ( "Unable to read serialized session from " + file ) ; } } | Attempts to deserialize the persisted session attributes into the given session . |
19,009 | public static synchronized void serializeSessionAttributes ( final HttpSession session ) { if ( session != null ) { File file = new File ( SERIALIZE_SESSION_NAME ) ; if ( ! file . exists ( ) || file . canWrite ( ) ) { List data = new ArrayList ( ) ; for ( Enumeration keyEnum = session . getAttributeNames ( ) ; keyEnum . hasMoreElements ( ) ; ) { String attributeName = ( String ) keyEnum . nextElement ( ) ; Object attributeValue = session . getAttribute ( attributeName ) ; if ( attributeValue instanceof Serializable ) { data . add ( attributeName ) ; data . add ( attributeValue ) ; } else { LOG . error ( "Skipping attribute \"" + attributeName + "\" as it is not Serializable" ) ; } } FileOutputStream fos = null ; ObjectOutputStream oos = null ; try { fos = new FileOutputStream ( file ) ; oos = new ObjectOutputStream ( fos ) ; oos . writeObject ( data ) ; } catch ( Exception e ) { LOG . error ( "Failed to write serialized session to " + file , e ) ; } finally { if ( oos != null ) { StreamUtil . safeClose ( oos ) ; } else { StreamUtil . safeClose ( fos ) ; } } } else { LOG . warn ( "Unable to write serialized session to " + file ) ; } } } | Serializes the session attributes of the given session . |
19,010 | public static void incrementSessionStep ( final UIContext uic ) { int step = uic . getEnvironment ( ) . getStep ( ) ; uic . getEnvironment ( ) . setStep ( step + 1 ) ; } | Increments the step that is recorded in session . |
19,011 | public static int getRequestStep ( final Request request ) { String val = request . getParameter ( Environment . STEP_VARIABLE ) ; if ( val == null ) { return 0 ; } try { return Integer . parseInt ( val ) ; } catch ( NumberFormatException ex ) { return - 1 ; } } | Retrieves the value of the step variable from the given request . |
19,012 | public static boolean isStepOnRequest ( final Request request ) { String val = request . getParameter ( Environment . STEP_VARIABLE ) ; return val != null ; } | Checks if the step count is on the request . |
19,013 | public static boolean isCachedContentRequest ( final Request request ) { String targetId = request . getParameter ( Environment . TARGET_ID ) ; if ( targetId == null ) { return false ; } ComponentWithContext targetWithContext = WebUtilities . getComponentById ( targetId , true ) ; if ( targetWithContext == null ) { return false ; } WComponent target = targetWithContext . getComponent ( ) ; UIContextHolder . pushContext ( targetWithContext . getContext ( ) ) ; try { String key = null ; if ( target instanceof WContent ) { key = ( ( WContent ) target ) . getCacheKey ( ) ; } else if ( target instanceof WImage ) { key = ( ( WImage ) target ) . getCacheKey ( ) ; } else if ( target instanceof WVideo ) { key = ( ( WVideo ) target ) . getCacheKey ( ) ; } else if ( target instanceof WAudio ) { key = ( ( WAudio ) target ) . getCacheKey ( ) ; } return ! Util . empty ( key ) ; } finally { UIContextHolder . popContext ( ) ; } } | Check if the request is for cached content . |
19,014 | private synchronized HttpSubSession getSubSession ( ) { HttpSession backingSession = super . getSession ( ) ; Map < Integer , HttpSubSession > subsessions = ( Map < Integer , HttpSubSession > ) backingSession . getAttribute ( SESSION_MAP_KEY ) ; HttpSubSession subsession = subsessions . get ( sessionId ) ; subsession . setLastAccessedTime ( System . currentTimeMillis ( ) ) ; return subsession ; } | Retrieves the subsession for this request . If there is no existing subsession a new one is created . |
19,015 | private void addSubordinate ( ) { WComponentGroup < SubordinateTarget > inputs = new WComponentGroup < > ( ) ; add ( inputs ) ; inputs . addToGroup ( checkBoxSelect ) ; inputs . addToGroup ( multiDropdown ) ; inputs . addToGroup ( multiSelect ) ; inputs . addToGroup ( multiSelectPair ) ; inputs . addToGroup ( dropdown ) ; inputs . addToGroup ( radioButtonSelect ) ; inputs . addToGroup ( singleSelect ) ; inputs . addToGroup ( checkBox ) ; inputs . addToGroup ( dateField ) ; inputs . addToGroup ( emailField ) ; inputs . addToGroup ( fileWidget ) ; inputs . addToGroup ( multiFileWidget ) ; inputs . addToGroup ( multiTextField ) ; inputs . addToGroup ( numberField ) ; inputs . addToGroup ( partialDateField ) ; inputs . addToGroup ( phoneNumberField ) ; inputs . addToGroup ( radioButton ) ; inputs . addToGroup ( shuffler ) ; inputs . addToGroup ( textField ) ; inputs . addToGroup ( textArea ) ; inputs . addToGroup ( radioButton1 ) ; inputs . addToGroup ( radioButton2 ) ; inputs . addToGroup ( radioButton3 ) ; WSubordinateControl control = new WSubordinateControl ( ) ; add ( control ) ; Rule rule = new Rule ( ) ; rule . setCondition ( new Equal ( mandatory , "true" ) ) ; rule . addActionOnTrue ( new Mandatory ( inputs ) ) ; rule . addActionOnFalse ( new Optional ( inputs ) ) ; control . addRule ( rule ) ; rule = new Rule ( ) ; rule . setCondition ( new Equal ( disabled , "true" ) ) ; rule . addActionOnTrue ( new Disable ( inputs ) ) ; rule . addActionOnFalse ( new Enable ( inputs ) ) ; control . addRule ( rule ) ; } | Setup the subordinate control . |
19,016 | private void addButtons ( ) { WButton buttonValidate = new WButton ( "Validate and Update Bean" ) ; add ( buttonValidate ) ; buttonValidate . setAction ( new ValidatingAction ( messages . getValidationErrors ( ) , layout ) { public void executeOnValid ( final ActionEvent event ) { WebUtilities . updateBeanValue ( layout ) ; messages . success ( "OK" ) ; } } ) ; WButton buttonUpdate = new WButton ( "Update Bean" ) ; add ( buttonUpdate ) ; buttonUpdate . setAction ( new Action ( ) { public void execute ( final ActionEvent event ) { WebUtilities . updateBeanValue ( layout ) ; } } ) ; WButton buttonReset = new WButton ( "Reset Inputs" ) ; add ( buttonReset ) ; buttonReset . setAction ( new Action ( ) { public void execute ( final ActionEvent event ) { layout . reset ( ) ; } } ) ; WButton buttonBean = new WButton ( "Reset Bean" ) ; add ( buttonBean ) ; buttonBean . setAction ( new Action ( ) { public void execute ( final ActionEvent event ) { InputBeanBindingExample . this . setBean ( new MyDemoBean ( ) ) ; } } ) ; add ( new WButton ( "submit" ) ) ; } | Setup the action buttons . |
19,017 | public String getWServletPath ( ) { final String configValue = ConfigurationProperties . getServletSupportPath ( ) ; return configValue == null ? getPostPath ( ) : getServletPath ( configValue ) ; } | Construct the path to the support servlet . Web components that need to construct a URL to target this servlet will use this method . |
19,018 | private String getServletPath ( final String relativePath ) { if ( relativePath == null ) { LOG . error ( "relativePath must not be null" ) ; } String context = getHostFreeBaseUrl ( ) ; if ( ! Util . empty ( context ) ) { return context + relativePath ; } return relativePath ; } | Constructs the path to one of the various helper servlets . This is used by the more specific getXXXPath methods . |
19,019 | private static WComponent build ( ) { WContainer root = new WContainer ( ) ; WSubordinateControl control = new WSubordinateControl ( ) ; root . add ( control ) ; WFieldLayout layout = new WFieldLayout ( ) ; layout . setLabelWidth ( 25 ) ; layout . setMargin ( new com . github . bordertech . wcomponents . Margin ( 0 , 0 , 12 , 0 ) ) ; WCheckBox checkBox = new WCheckBox ( ) ; layout . addField ( "Set Mandatory" , checkBox ) ; WTextField text = new WTextField ( ) ; layout . addField ( "Might need this field" , text ) ; WTextField mandatoryField = new WTextField ( ) ; layout . addField ( "Another field always mandatory" , mandatoryField ) ; mandatoryField . setMandatory ( true ) ; final WRadioButtonSelect rbSelect = new WRadioButtonSelect ( "australian_state" ) ; layout . addField ( "Select a state" , rbSelect ) ; root . add ( layout ) ; Rule rule = new Rule ( ) ; rule . setCondition ( new Equal ( checkBox , Boolean . TRUE . toString ( ) ) ) ; rule . addActionOnTrue ( new Mandatory ( text ) ) ; rule . addActionOnFalse ( new Optional ( text ) ) ; rule . addActionOnTrue ( new Mandatory ( rbSelect ) ) ; rule . addActionOnFalse ( new Optional ( rbSelect ) ) ; control . addRule ( rule ) ; return root ; } | Creates the component to be added to the validation container . This is doen in a static method because the component is passed into the superclass constructor . |
19,020 | public void paint ( final RenderContext renderContext ) { if ( ! DebugValidateXML . isEnabled ( ) ) { super . paint ( renderContext ) ; return ; } if ( ! ( renderContext instanceof WebXmlRenderContext ) ) { LOG . warn ( "Unable to validate against a " + renderContext ) ; super . paint ( renderContext ) ; return ; } LOG . debug ( "Validate XML Interceptor: Start" ) ; WebXmlRenderContext webRenderContext = ( WebXmlRenderContext ) renderContext ; PrintWriter writer = webRenderContext . getWriter ( ) ; StringWriter tempBuffer = new StringWriter ( ) ; PrintWriter tempWriter = new PrintWriter ( tempBuffer ) ; WebXmlRenderContext tempContext = new WebXmlRenderContext ( tempWriter , UIContextHolder . getCurrent ( ) . getLocale ( ) ) ; super . paint ( tempContext ) ; String xml = tempBuffer . toString ( ) ; String error = DebugValidateXML . validateXMLAgainstSchema ( xml ) ; if ( error != null ) { LOG . debug ( "Validate XML Interceptor: XML Has Errors" ) ; writer . println ( "<div>" ) ; writer . println ( "<div>" ) ; writer . println ( "Invalid XML" ) ; writer . println ( "<ul><li>" + WebUtilities . encode ( error ) + "</li></ul>" ) ; writer . println ( "<br/>" ) ; writer . println ( "</div>" ) ; String testXML = DebugValidateXML . wrapXMLInRootElement ( xml ) ; paintOriginalXML ( testXML , writer ) ; writer . println ( "</div>" ) ; } else { writer . write ( xml ) ; } LOG . debug ( "Validate XML Interceptor: Finished" ) ; } | Override paint to include XML Validation . |
19,021 | private void paintOriginalXML ( final String originalXML , final PrintWriter writer ) { String xml = originalXML . replaceAll ( "<!\\[CDATA\\[" , "CDATASTART" ) ; xml = xml . replaceAll ( "\\]\\]>" , "CDATAFINISH" ) ; writer . println ( "<div>" ) ; writer . println ( "<!-- VALIDATE XML ERROR - START XML ) ; writer . println ( "<![CDATA[" ) ; writer . println ( xml ) ; writer . println ( "]]>" ) ; writer . println ( "<!-- VALIDATE XML ERROR - END XML ) ; writer . println ( "</div>" ) ; } | Paint the original XML wrapped in a CDATA Section . |
19,022 | protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; if ( ! this . isInitialised ( ) ) { List recent = loadRecentList ( ) ; if ( recent != null && ! recent . isEmpty ( ) ) { String selection = ( String ) recent . get ( 0 ) ; displaySelection ( selection ) ; } this . setInitialised ( true ) ; } updateTitle ( ) ; } | When the example picker starts up we want to display the last selection the user made in their previous session . We can do this because the list of recent selections is stored in a file on the file system . |
19,023 | private void updateTitle ( ) { String title ; if ( this . getCurrentComponent ( ) == null ) { title = "Example Picker" ; } else { title = this . getCurrentComponent ( ) . getClass ( ) . getName ( ) ; } WApplication app = WebUtilities . getAncestorOfClass ( WApplication . class , this ) ; if ( app != null ) { app . setTitle ( title ) ; } } | Updates the title based on the selected example . |
19,024 | protected void afterPaint ( final RenderContext renderContext ) { super . afterPaint ( renderContext ) ; if ( profileBtn . isPressed ( ) ) { UicStats stats = new UicStats ( UIContextHolder . getCurrent ( ) ) ; WComponent currentComp = this . getCurrentComponent ( ) ; if ( currentComp != null ) { stats . analyseWC ( currentComp ) ; } if ( renderContext instanceof WebXmlRenderContext ) { PrintWriter writer = ( ( WebXmlRenderContext ) renderContext ) . getWriter ( ) ; writer . println ( "<hr />" ) ; writer . println ( "<h2>Serialization Profile of UIC</h2>" ) ; UicStatsAsHtml . write ( writer , stats ) ; if ( currentComp != null ) { writer . println ( "<hr />" ) ; writer . println ( "<h2>ObjectProfiler - " + currentComp + "</h2>" ) ; writer . println ( "<pre>" ) ; try { writer . println ( ObjectGraphDump . dump ( currentComp ) . toFlatSummary ( ) ) ; } catch ( Exception e ) { LOG . error ( "Failed to dump component" , e ) ; } writer . println ( "</pre>" ) ; } } } } | Override afterPaint in order to paint the UIContext serialization statistics if the profile button has been pressed . |
19,025 | private List loadRecentList ( ) { try { InputStream in = new BufferedInputStream ( new FileInputStream ( RECENT_FILE_NAME ) ) ; XMLDecoder d = new XMLDecoder ( in ) ; Object result = d . readObject ( ) ; d . close ( ) ; return ( List ) result ; } catch ( FileNotFoundException ex ) { return new ArrayList ( ) ; } } | Retrieves the list of recently selected examples from a file on the file system . |
19,026 | public Container getCurrentComponent ( ) { Container currentComponent = null ; if ( ( ( Container ) ( container . getChildAt ( 0 ) ) ) . getChildCount ( ) > 0 ) { currentComponent = ( Container ) container . getChildAt ( 0 ) ; } return currentComponent ; } | Retrieves the component that is currently being displayed by the example picker . |
19,027 | public void displaySelection ( final String selection ) { WComponent selectedComponent = UIRegistry . getInstance ( ) . getUI ( selection ) ; if ( selectedComponent == null ) { WMessages . getInstance ( this ) . error ( "Unable to load example: " + selection + ", see log for details." ) ; return ; } displaySelection ( selectedComponent ) ; } | Get the example picker to display the given selection . |
19,028 | public void displaySelection ( final WComponent selectedComponent ) { WComponent currentComponent = getCurrentComponent ( ) ; if ( selectedComponent == currentComponent ) { return ; } container . removeAll ( ) ; container . add ( selectedComponent ) ; } | Get the example picker to display the given selected component . |
19,029 | private void storeRecentList ( final List recent ) { try { if ( recent == null ) { return ; } while ( recent . size ( ) > 8 ) { recent . remove ( recent . size ( ) - 1 ) ; } OutputStream out = new BufferedOutputStream ( new FileOutputStream ( RECENT_FILE_NAME ) ) ; XMLEncoder e = new XMLEncoder ( out ) ; e . writeObject ( recent ) ; e . close ( ) ; } catch ( IOException ex ) { LOG . error ( "Unable to save recent list" , ex ) ; } } | Store the list of recent selections to a file on the file system . |
19,030 | public static void setCurrentOperationDetails ( final AjaxOperation operation , final ComponentWithContext trigger ) { if ( operation == null ) { THREAD_LOCAL_OPERATION . remove ( ) ; } else { THREAD_LOCAL_OPERATION . set ( operation ) ; } if ( trigger == null ) { THREAD_LOCAL_COMPONENT_WITH_CONTEXT . remove ( ) ; } else { THREAD_LOCAL_COMPONENT_WITH_CONTEXT . set ( trigger ) ; } } | Sets the current AJAX operation details . |
19,031 | public static AjaxOperation registerComponents ( final List < String > targetIds , final String triggerId ) { AjaxOperation operation = new AjaxOperation ( triggerId , targetIds ) ; registerAjaxOperation ( operation ) ; return operation ; } | Registers one or more components as being AJAX capable . |
19,032 | public static AjaxOperation registerComponent ( final String targetId , final String triggerId ) { AjaxOperation operation = new AjaxOperation ( triggerId , targetId ) ; registerAjaxOperation ( operation ) ; return operation ; } | Registers a single component as being AJAX capable . |
19,033 | public static AjaxOperation getAjaxOperation ( final String triggerId ) { Map < String , AjaxOperation > operations = getRegisteredOperations ( ) ; return operations == null ? null : operations . get ( triggerId ) ; } | Retrieves the AjaxOperation that has been registered for the given trigger . This method will return null if there is no corresponding operation registered . |
19,034 | public static void clearAllRegisteredOperations ( ) { UIContext uic = UIContextHolder . getCurrentPrimaryUIContext ( ) ; if ( uic != null ) { uic . setFwkAttribute ( AJAX_OPERATIONS_SESSION_KEY , null ) ; } } | Clear the registered AJAX operations for this user context . |
19,035 | private static void registerAjaxOperation ( final AjaxOperation operation ) { UIContext uic = UIContextHolder . getCurrentPrimaryUIContext ( ) ; if ( uic == null ) { throw new SystemException ( "No User Context Available to Register AJAX Operations." ) ; } Map < String , AjaxOperation > operations = ( Map < String , AjaxOperation > ) uic . getFwkAttribute ( AJAX_OPERATIONS_SESSION_KEY ) ; if ( operations == null ) { operations = new HashMap < > ( ) ; uic . setFwkAttribute ( AJAX_OPERATIONS_SESSION_KEY , operations ) ; } operations . put ( operation . getTriggerId ( ) , operation ) ; } | The Ajax servlet needs access to the AjaxOperation Store the operation in the user context using the trigger Id as this will be present in the Servlet HttpRequest . agreed key . The ajax id is passed in the url to the servlet so it can then access the context . |
19,036 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WCheckBoxSelect select = ( WCheckBoxSelect ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; int cols = select . getButtonColumns ( ) ; boolean readOnly = select . isReadOnly ( ) ; xml . appendTagOpen ( "ui:checkboxselect" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , select . isHidden ( ) , "true" ) ; if ( readOnly ) { xml . appendAttribute ( "readOnly" , "true" ) ; } else { int min = select . getMinSelect ( ) ; int max = select . getMaxSelect ( ) ; xml . appendOptionalAttribute ( "disabled" , select . isDisabled ( ) , "true" ) ; xml . appendOptionalAttribute ( "required" , select . isMandatory ( ) , "true" ) ; xml . appendOptionalAttribute ( "submitOnChange" , select . isSubmitOnChange ( ) , "true" ) ; xml . appendOptionalAttribute ( "toolTip" , component . getToolTip ( ) ) ; xml . appendOptionalAttribute ( "accessibleText" , component . getAccessibleText ( ) ) ; xml . appendOptionalAttribute ( "min" , min > 0 , min ) ; xml . appendOptionalAttribute ( "max" , max > 0 , max ) ; } xml . appendOptionalAttribute ( "frameless" , select . isFrameless ( ) , "true" ) ; switch ( select . getButtonLayout ( ) ) { case COLUMNS : xml . appendAttribute ( "layout" , "column" ) ; xml . appendOptionalAttribute ( "layoutColumnCount" , cols > 0 , cols ) ; break ; case FLAT : xml . appendAttribute ( "layout" , "flat" ) ; break ; case STACKED : xml . appendAttribute ( "layout" , "stacked" ) ; break ; default : throw new SystemException ( "Unknown layout type: " + select . getButtonLayout ( ) ) ; } xml . appendClose ( ) ; List < ? > options = select . getOptions ( ) ; boolean renderSelectionsOnly = readOnly ; if ( options != null ) { int optionIndex = 0 ; List < ? > selections = select . getSelected ( ) ; for ( Object option : options ) { if ( option instanceof OptionGroup ) { throw new SystemException ( "Option groups not supported in WCheckBoxSelect." ) ; } else { renderOption ( select , option , optionIndex ++ , xml , selections , renderSelectionsOnly ) ; } } } if ( ! readOnly ) { DiagnosticRenderUtil . renderDiagnostics ( select , renderContext ) ; } xml . appendEndTag ( "ui:checkboxselect" ) ; } | Paints the given WCheckBoxSelect . |
19,037 | public WSubordinateControl build ( ) { if ( ! condition ( ) . validate ( ) ) { throw new SystemException ( "Invalid condition: " + condition ) ; } if ( getActionsWhenTrue ( ) . isEmpty ( ) && getActionsWhenFalse ( ) . isEmpty ( ) ) { throw new SystemException ( "No actions to execute" ) ; } WSubordinateControl subordinate = new WSubordinateControl ( ) ; Rule rule = new Rule ( ) ; BooleanExpression expression = getCondition ( ) ; rule . setCondition ( expression . build ( ) ) ; for ( Action action : getActionsWhenTrue ( ) ) { rule . addActionOnTrue ( action . build ( ) ) ; } for ( Action action : getActionsWhenFalse ( ) ) { rule . addActionOnFalse ( action . build ( ) ) ; } subordinate . addRule ( rule ) ; return subordinate ; } | This builds the SubordinateControl . This method will throw a SystemException if the condition is invalid or there are no actions specified . |
19,038 | public void preparePaint ( final Request request ) { Headers headers = this . getUI ( ) . getHeaders ( ) ; headers . reset ( ) ; headers . setContentType ( WebUtilities . CONTENT_TYPE_XML ) ; super . preparePaint ( request ) ; } | Override preparePaint in order to prepare the headers . |
19,039 | public void paint ( final RenderContext renderContext ) { WebXmlRenderContext webRenderContext = ( WebXmlRenderContext ) renderContext ; PrintWriter writer = webRenderContext . getWriter ( ) ; beforePaint ( writer ) ; getBackingComponent ( ) . paint ( renderContext ) ; afterPaint ( writer ) ; } | Produce the html output . |
19,040 | protected void beforePaint ( final PrintWriter writer ) { PageShell pageShell = Factory . newInstance ( PageShell . class ) ; pageShell . openDoc ( writer ) ; pageShell . writeHeader ( writer ) ; } | Renders the content before the backing component . |
19,041 | protected void afterPaint ( final PrintWriter writer ) { PageShell pageShell = Factory . newInstance ( PageShell . class ) ; pageShell . writeFooter ( writer ) ; pageShell . closeDoc ( writer ) ; } | Renders the content after the backing component . |
19,042 | public void handleRequest ( final Request request ) { clearPressed ( ) ; String requestValue = request . getParameter ( getId ( ) ) ; boolean pressed = "x" . equals ( requestValue ) ; if ( pressed && ! "POST" . equals ( request . getMethod ( ) ) ) { LOG . warn ( "Button pressed on a request that is not a POST. Will be ignored." ) ; return ; } setPressed ( pressed , request ) ; } | Override handleRequest in order to perform processing for this component . This implementation checks whether the button has been pressed in the request . |
19,043 | protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; UIContext uic = UIContextHolder . getCurrent ( ) ; if ( isAjax ( ) && uic . getUI ( ) != null ) { AjaxTarget target = getAjaxTarget ( ) ; AjaxHelper . registerComponent ( target . getId ( ) , getId ( ) ) ; } } | Override preparePaintComponent to register an AJAX operation if this button is AJAX enabled . |
19,044 | public String getValue ( ) { Object value = getData ( ) ; if ( value != null ) { return value . toString ( ) ; } String text = getText ( ) ; return text == null ? NO_VALUE : text ; } | Return the button value . By default the value is the same as the text placed on the button . |
19,045 | public void setImage ( final Image image ) { ButtonModel model = getOrCreateComponentModel ( ) ; model . image = image ; model . imageUrl = null ; } | Sets the image to display on the button . The text alternative for the image is generated from the button text . |
19,046 | protected void preparePaintComponent ( final Request request ) { if ( OPTION_CONTENT1 . equals ( rbSelect . getSelected ( ) ) ) { content . setText ( "This is content 1" ) ; } else if ( OPTION_CONTENT2 . equals ( rbSelect . getSelected ( ) ) ) { content . setText ( "This is content 2" ) ; } else if ( OPTION_CONTENT3 . equals ( rbSelect . getSelected ( ) ) ) { content . setText ( "This is content 3" ) ; } else { content . setText ( null ) ; } } | Set the content of the text field depending on the selected option in the radio button select . |
19,047 | public void execute ( ) { if ( condition == null ) { throw new SystemException ( "Rule cannot be executed as it has no condition" ) ; } if ( condition . isTrue ( ) ) { for ( Action action : onTrue ) { action . execute ( ) ; } } else { for ( Action action : onFalse ) { action . execute ( ) ; } } } | Executes the rule . |
19,048 | public static void applyRegisteredControls ( final Request request , final boolean useRequestValues ) { Set < String > controls = getRegisteredSubordinateControls ( ) ; if ( controls == null ) { return ; } for ( String controlId : controls ) { ComponentWithContext controlWithContext = WebUtilities . getComponentById ( controlId , true ) ; if ( controlWithContext == null ) { LOG . warn ( "Subordinate control for id " + controlId + " is no longer in the tree." ) ; continue ; } if ( ! ( controlWithContext . getComponent ( ) instanceof WSubordinateControl ) ) { LOG . warn ( "Component for id " + controlId + " is not a subordinate control." ) ; continue ; } WSubordinateControl control = ( WSubordinateControl ) controlWithContext . getComponent ( ) ; UIContext uic = controlWithContext . getContext ( ) ; UIContextHolder . pushContext ( uic ) ; try { if ( useRequestValues ) { control . applyTheControls ( request ) ; } else { control . applyTheControls ( ) ; } } finally { UIContextHolder . popContext ( ) ; } } } | Apply the registered Subordinate Controls . |
19,049 | public static void clearAllRegisteredControls ( ) { UIContext uic = UIContextHolder . getCurrentPrimaryUIContext ( ) ; if ( uic != null ) { uic . setFwkAttribute ( SUBORDINATE_CONTROL_SESSION_KEY , null ) ; } } | Clear all registered Subordinate Controls on the session . |
19,050 | public void setContent ( final WComponent content ) { getOrCreateComponentModel ( ) . content = content ; holder . removeAll ( ) ; holder . add ( content ) ; } | Set the WComponent which will handle the content for this dialog . |
19,051 | public void setTitle ( final String title , final Serializable ... args ) { getOrCreateComponentModel ( ) . title = I18nUtilities . asMessage ( title , args ) ; } | Sets the dialog title . |
19,052 | public void setTrigger ( final DialogOpenTrigger trigger ) { if ( this . hasLegacyTriggerButton ( ) ) { DialogOpenTrigger theTrigger = getTrigger ( ) ; if ( theTrigger instanceof WButton ) { remove ( theTrigger ) ; } setLegacyTriggerButton ( false ) ; } getOrCreateComponentModel ( ) . trigger = trigger ; } | Set the component which will open the WDialog . |
19,053 | protected void handleTriggerOpenAction ( final Request request ) { final Action action = getTriggerOpenAction ( ) ; if ( action != null ) { final ActionEvent event = new ActionEvent ( this , OPEN_DIALOG_ACTION ) ; Runnable later = new Runnable ( ) { public void run ( ) { action . execute ( event ) ; } } ; invokeLater ( later ) ; } } | Run the trigger open action . |
19,054 | public final boolean isAjaxTargeted ( ) { AjaxOperation operation = AjaxHelper . getCurrentOperation ( ) ; if ( operation == null ) { return false ; } String dialogId = getId ( ) ; String containerId = operation . getTargetContainerId ( ) ; if ( containerId != null && containerId . startsWith ( dialogId ) ) { return true ; } if ( operation . getTargets ( ) != null && UIContextHolder . getCurrent ( ) != null ) { for ( String targetId : operation . getTargets ( ) ) { if ( targetId . startsWith ( dialogId ) ) { return true ; } } } return false ; } | Indicates whether the dialog is currently the target of an AJAX operation . |
19,055 | public List < Application > getAppsOnSpace ( int spaceId ) { return getResourceFactory ( ) . getApiResource ( "/app/space/" + spaceId + "/" ) . get ( new GenericType < List < Application > > ( ) { } ) ; } | Returns all the apps on the space that are visible . The apps are sorted by any custom ordering and else by name . |
19,056 | public List < Application > getTopApps ( Integer limit ) { WebResource resource = getResourceFactory ( ) . getApiResource ( "/app/top/" ) ; if ( limit != null ) { resource = resource . queryParam ( "limit" , limit . toString ( ) ) ; } return resource . get ( new GenericType < List < Application > > ( ) { } ) ; } | Returns the top apps for the active user . This is the apps that the user have interacted with the most . |
19,057 | public int addApp ( ApplicationCreate app ) { return getResourceFactory ( ) . getApiResource ( "/app/" ) . entity ( app , MediaType . APPLICATION_JSON_TYPE ) . post ( ApplicationCreateResponse . class ) . getId ( ) ; } | Creates a new app on a space . |
19,058 | public void updateApp ( int appId , ApplicationUpdate app ) { getResourceFactory ( ) . getApiResource ( "/app/" + appId ) . entity ( app , MediaType . APPLICATION_JSON ) . put ( ) ; } | Updates an app . The update can contain an new configuration for the app addition of new fields as well as updates to the configuration of existing fields . Fields not included will not be deleted . To delete a field use the delete field operation . |
19,059 | public int addField ( int appId , ApplicationFieldCreate field ) { return getResourceFactory ( ) . getApiResource ( "/app/" + appId + "/field/" ) . entity ( field , MediaType . APPLICATION_JSON_TYPE ) . post ( ApplicationFieldCreateResponse . class ) . getId ( ) ; } | Adds a new field to an app |
19,060 | public void updateField ( int appId , int fieldId , ApplicationFieldConfiguration configuration ) { getResourceFactory ( ) . getApiResource ( "/app/" + appId + "/field/" + fieldId ) . entity ( configuration , MediaType . APPLICATION_JSON_TYPE ) . put ( ) ; } | Updates the configuration of an app field . The type of the field cannot be updated only the configuration . |
19,061 | public int install ( int appId , int spaceId ) { return getResourceFactory ( ) . getApiResource ( "/app/" + appId + "/install" ) . entity ( new ApplicationInstall ( spaceId ) , MediaType . APPLICATION_JSON_TYPE ) . post ( ApplicationCreateResponse . class ) . getId ( ) ; } | Installs the app with the given id on the space . |
19,062 | public void updateOrder ( int spaceId , List < Integer > appIds ) { getResourceFactory ( ) . getApiResource ( "/app/space/" + spaceId + "/order" ) . entity ( appIds , MediaType . APPLICATION_JSON_TYPE ) . put ( ) ; } | Updates the order of the apps on the space . It should post all the apps from the space in the order required . |
19,063 | public void deactivateApp ( int appId ) { getResourceFactory ( ) . getApiResource ( "/app/" + appId + "/deactivate" ) . entity ( new Empty ( ) , MediaType . APPLICATION_JSON_TYPE ) . post ( ) ; } | Deactivates the app with the given id . This removes the app from the app navigator and disables insertion of new items . |
19,064 | public void downloadFile ( int fileId , java . io . File target , FileSize size ) throws IOException { WebResource builder = getResourceFactory ( ) . getFileResource ( "/" + fileId ) ; if ( size != null ) { builder = builder . path ( "/" + size . name ( ) . toLowerCase ( ) ) ; } byte [ ] data = builder . get ( byte [ ] . class ) ; FileUtils . writeByteArrayToFile ( target , data ) ; } | Downloads the file and saves it to given file |
19,065 | public int uploadFile ( String name , java . io . File file ) { FileDataBodyPart filePart = new FileDataBodyPart ( "source" , file ) ; FormDataContentDisposition . FormDataContentDispositionBuilder builder = FormDataContentDisposition . name ( filePart . getName ( ) ) ; builder . fileName ( file . getName ( ) ) ; builder . size ( file . length ( ) ) ; filePart . setFormDataContentDisposition ( builder . build ( ) ) ; FormDataMultiPart multiPart = new FormDataMultiPart ( ) ; multiPart . bodyPart ( filePart ) ; multiPart . field ( "filename" , name ) ; Builder resource = getResourceFactory ( ) . getApiResource ( "/file/v2/" ) . entity ( multiPart , new MediaType ( "multipart" , "form-data" , Collections . singletonMap ( "boundary" , "AaB03x" ) ) ) ; return resource . post ( File . class ) . getId ( ) ; } | Uploads the file to the API |
19,066 | public void updateFile ( int fileId , FileUpdate update ) { getResourceFactory ( ) . getApiResource ( "/file/" + fileId ) . entity ( update , MediaType . APPLICATION_JSON_TYPE ) . put ( ) ; } | Used to update the description of the file . |
19,067 | public List < File > getOnApp ( int appId , Integer limit , Integer offset ) { WebResource resource = getResourceFactory ( ) . getApiResource ( "/file/app/" + appId + "/" ) ; if ( limit != null ) { resource = resource . queryParam ( "limit" , limit . toString ( ) ) ; } if ( offset != null ) { resource = resource . queryParam ( "offset" , offset . toString ( ) ) ; } return resource . get ( new GenericType < List < File > > ( ) { } ) ; } | Returns all the files related to the items in the application . This includes files both on the item itself and in comments on the item . |
19,068 | public List < File > getOnSpace ( int spaceId , Integer limit , Integer offset ) { WebResource resource = getResourceFactory ( ) . getApiResource ( "/file/space/" + spaceId + "/" ) ; if ( limit != null ) { resource = resource . queryParam ( "limit" , limit . toString ( ) ) ; } if ( offset != null ) { resource = resource . queryParam ( "offset" , offset . toString ( ) ) ; } return resource . get ( new GenericType < List < File > > ( ) { } ) ; } | Returns all the files on the space order by the file name . |
19,069 | public List < Diagnostic > validate ( final List < Diagnostic > diags ) { if ( ! isValid ( ) ) { List < Serializable > argList = getMessageArguments ( ) ; Serializable [ ] args = argList . toArray ( new Serializable [ argList . size ( ) ] ) ; diags . add ( new DiagnosticImpl ( Diagnostic . ERROR , input , getErrorMessage ( ) , args ) ) ; } return diags ; } | Validates the input field . |
19,070 | public R between ( int lower , int upper ) { expr ( ) . between ( _name , lower , upper ) ; return _root ; } | Between lower and upper values . |
19,071 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WFieldSet fieldSet = ( WFieldSet ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; xml . appendTagOpen ( "ui:fieldset" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , fieldSet . isHidden ( ) , "true" ) ; switch ( fieldSet . getFrameType ( ) ) { case NO_BORDER : xml . appendOptionalAttribute ( "frame" , "noborder" ) ; break ; case NO_TEXT : xml . appendOptionalAttribute ( "frame" , "notext" ) ; break ; case NONE : xml . appendOptionalAttribute ( "frame" , "none" ) ; break ; case NORMAL : default : break ; } xml . appendOptionalAttribute ( "required" , fieldSet . isMandatory ( ) , "true" ) ; xml . appendClose ( ) ; MarginRendererUtil . renderMargin ( fieldSet , renderContext ) ; WDecoratedLabel label = fieldSet . getTitle ( ) ; label . paint ( renderContext ) ; xml . appendTag ( "ui:content" ) ; int size = fieldSet . getChildCount ( ) ; for ( int i = 0 ; i < size ; i ++ ) { WComponent child = fieldSet . getChildAt ( i ) ; if ( child != label ) { child . paint ( renderContext ) ; } } xml . appendEndTag ( "ui:content" ) ; DiagnosticRenderUtil . renderDiagnostics ( fieldSet , renderContext ) ; xml . appendEndTag ( "ui:fieldset" ) ; } | Paints the given WFieldSet . |
19,072 | private WApplication findApplication ( ) { WApplication appl = WApplication . instance ( this ) ; if ( appl == null ) { messages . addMessage ( new Message ( Message . WARNING_MESSAGE , "There is no WApplication available for this example." ) ) ; } return appl ; } | Find the closest WApplication instance . |
19,073 | public void addTaggedComponent ( final String tag , final WComponent component ) { if ( Util . empty ( tag ) ) { throw new IllegalArgumentException ( "A tag must be provided." ) ; } if ( component == null ) { throw new IllegalArgumentException ( "A component must be provided." ) ; } TemplateModel model = getOrCreateComponentModel ( ) ; if ( model . taggedComponents == null ) { model . taggedComponents = new HashMap < > ( ) ; } else { if ( model . taggedComponents . containsKey ( tag ) ) { throw new IllegalArgumentException ( "The tag [" + tag + "] has already been added." ) ; } if ( model . taggedComponents . containsValue ( component ) ) { throw new IllegalArgumentException ( "Component has already been added." ) ; } } model . taggedComponents . put ( tag , component ) ; add ( component ) ; } | Add a tagged component to be included in the template . The component will be rendered in place of the corresponding tag in the template . |
19,074 | public void removeTaggedComponent ( final WComponent component ) { TemplateModel model = getOrCreateComponentModel ( ) ; if ( model . taggedComponents != null ) { String tag = null ; for ( Map . Entry < String , WComponent > entry : model . taggedComponents . entrySet ( ) ) { if ( entry . getValue ( ) . equals ( component ) ) { tag = entry . getKey ( ) ; break ; } } if ( tag != null ) { removeTaggedComponent ( tag ) ; } } } | Remove a tagged component via the component instance . |
19,075 | public void removeTaggedComponent ( final String tag ) { TemplateModel model = getOrCreateComponentModel ( ) ; if ( model . taggedComponents != null ) { WComponent component = model . taggedComponents . remove ( tag ) ; if ( model . taggedComponents . isEmpty ( ) ) { model . taggedComponents = null ; } if ( component != null ) { remove ( component ) ; } } } | Remove a tagged component by its tag . |
19,076 | public void addParameter ( final String tag , final Object value ) { if ( Util . empty ( tag ) ) { throw new IllegalArgumentException ( "A tag must be provided" ) ; } TemplateModel model = getOrCreateComponentModel ( ) ; if ( model . parameters == null ) { model . parameters = new HashMap < > ( ) ; } model . parameters . put ( tag , value ) ; } | Add a template parameter . |
19,077 | public void setEngineName ( final TemplateRendererFactory . TemplateEngine templateEngine ) { setEngineName ( templateEngine == null ? null : templateEngine . getEngineName ( ) ) ; } | Set a predefined template engine . If null then the default engine is used . |
19,078 | public void removeEngineOption ( final String key ) { TemplateModel model = getOrCreateComponentModel ( ) ; if ( model . engineOptions != null ) { model . engineOptions . remove ( key ) ; } } | Remove a template engine option . |
19,079 | public static Date createDate ( final int day , final int month , final int year ) { Calendar cal = Calendar . getInstance ( ) ; cal . clear ( ) ; cal . set ( Calendar . DAY_OF_MONTH , day ) ; cal . set ( Calendar . MONTH , month - 1 ) ; cal . set ( Calendar . YEAR , year ) ; return cal . getTime ( ) ; } | Creates a date from the given components . |
19,080 | public void preparePaint ( final Request request ) { Headers headers = this . getUI ( ) . getHeaders ( ) ; headers . reset ( ) ; super . preparePaint ( request ) ; } | Override preparePaint in order to perform processing specific to this interceptor . Any old headers are cleared out before preparePaint is called on the main UI . |
19,081 | public void paint ( final RenderContext renderContext ) { if ( renderContext instanceof WebXmlRenderContext ) { PageContentHelper . addAllHeadlines ( ( ( WebXmlRenderContext ) renderContext ) . getWriter ( ) , getUI ( ) . getHeaders ( ) ) ; } getBackingComponent ( ) . paint ( renderContext ) ; } | Override paint in order to perform processing specific to this interceptor . This implementation is responsible for rendering the headlines for the UI . |
19,082 | public void handleRequest ( final Request request ) { super . handleRequest ( request ) ; WComponent visibleDialog = getVisible ( ) ; if ( visibleDialog != null ) { visibleDialog . serviceRequest ( request ) ; } } | Since none of the children are visible to standard processing handleRequest has been overridden so that the visible card is processed . |
19,083 | protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; WComponent visibleDialog = getVisible ( ) ; if ( visibleDialog != null ) { visibleDialog . preparePaint ( request ) ; } } | Since none of the children are visible to standard processing preparePaintComponent has been overridden so that the visible card is prepared . |
19,084 | protected void paintComponent ( final RenderContext renderContext ) { super . paintComponent ( renderContext ) ; WComponent visibleDialog = getVisible ( ) ; if ( visibleDialog != null ) { visibleDialog . paint ( renderContext ) ; } } | Since none of the children are visible to standard processing paintComponent has been overridden so that the visible card is painted . |
19,085 | protected void validateComponent ( final List < Diagnostic > diags ) { super . validateComponent ( diags ) ; WComponent visibleDialog = getVisible ( ) ; if ( visibleDialog != null ) { visibleDialog . validate ( diags ) ; } } | Since none of the children are visible to standard processing validateComponent has been overridden so that the visible card is processed . |
19,086 | public void showErrorIndicators ( final List < Diagnostic > diags ) { WComponent visibleComponent = getVisible ( ) ; visibleComponent . showErrorIndicators ( diags ) ; } | Override method to show Error indicators on the visible card . |
19,087 | public void showWarningIndicators ( final List < Diagnostic > diags ) { WComponent visibleComponent = getVisible ( ) ; visibleComponent . showWarningIndicators ( diags ) ; } | Override method to show Warning indicators on the visible card . |
19,088 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WList list = ( WList ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; WList . Type type = list . getType ( ) ; WList . Separator separator = list . getSeparator ( ) ; Size gap = list . getSpace ( ) ; String gapString = gap == null ? null : gap . toString ( ) ; xml . appendTagOpen ( "ui:panel" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendOptionalAttribute ( "type" , list . isRenderBorder ( ) , "box" ) ; xml . appendClose ( ) ; MarginRendererUtil . renderMargin ( list , renderContext ) ; xml . appendTagOpen ( "ui:listlayout" ) ; xml . appendOptionalAttribute ( "gap" , gapString ) ; if ( type != null ) { switch ( type ) { case FLAT : xml . appendAttribute ( "type" , "flat" ) ; break ; case STACKED : xml . appendAttribute ( "type" , "stacked" ) ; break ; case STRIPED : xml . appendAttribute ( "type" , "striped" ) ; break ; default : throw new SystemException ( "Unknown list type: " + type ) ; } } if ( separator != null ) { switch ( separator ) { case BAR : xml . appendAttribute ( "separator" , "bar" ) ; break ; case DOT : xml . appendAttribute ( "separator" , "dot" ) ; break ; case NONE : break ; default : throw new SystemException ( "Unknown list type: " + type ) ; } } xml . appendClose ( ) ; paintRows ( list , renderContext ) ; xml . appendEndTag ( "ui:listlayout" ) ; xml . appendEndTag ( "ui:panel" ) ; } | Paints the given WList . |
19,089 | private void addInteractiveExamples ( ) { add ( new WHeading ( HeadingLevel . H2 , "Simple WCheckBoxSelect examples" ) ) ; addExampleUsingLookupTable ( ) ; addExampleUsingArrayList ( ) ; addExampleUsingStringArray ( ) ; addInsideAFieldLayoutExamples ( ) ; add ( new WHeading ( HeadingLevel . H2 , "Examples showing LAYOUT properties" ) ) ; addFlatSelectExample ( ) ; addColumnSelectExample ( ) ; addSingleColumnSelectExample ( ) ; add ( new WHeading ( HeadingLevel . H2 , "WCheckBoxSelect showing the frameless state" ) ) ; add ( new WHeading ( HeadingLevel . H3 , "Normal (with frame)" ) ) ; WCheckBoxSelect select = new WCheckBoxSelect ( "australian_state" ) ; add ( select ) ; select . setToolTip ( "Make a selection" ) ; add ( new WHeading ( HeadingLevel . H3 , "Without frame" ) ) ; select = new WCheckBoxSelect ( "australian_state" ) ; add ( select ) ; select . setFrameless ( true ) ; select . setToolTip ( "Make a selection (no frame)" ) ; } | Simple interactive - state WCheckBoxSelect examples . |
19,090 | private void addExampleUsingStringArray ( ) { add ( new WHeading ( HeadingLevel . H3 , "WCheckBoxSelect created using a String array" ) ) ; String [ ] options = new String [ ] { "Dog" , "Cat" , "Bird" , "Turtle" } ; final WCheckBoxSelect select = new WCheckBoxSelect ( options ) ; select . setToolTip ( "Animals" ) ; select . setMandatory ( true ) ; final WTextField text = new WTextField ( ) ; text . setReadOnly ( true ) ; text . setText ( NO_SELECTION ) ; WButton update = new WButton ( "Select Animals" ) ; update . setAction ( new Action ( ) { public void execute ( final ActionEvent event ) { String output = select . getSelected ( ) . isEmpty ( ) ? NO_SELECTION : "The selected animals are: " + select . getSelected ( ) ; text . setText ( output ) ; } } ) ; select . setDefaultSubmitButton ( update ) ; WLabel animalLabel = new WLabel ( "A selection is required" , select ) ; animalLabel . setHint ( "mandatory" ) ; add ( animalLabel ) ; add ( select ) ; add ( update ) ; add ( text ) ; add ( new WAjaxControl ( update , text ) ) ; } | This example creates the WCheckBoxSelect from an array of Strings . |
19,091 | private void addExampleUsingArrayList ( ) { add ( new WHeading ( HeadingLevel . H3 , "WCheckBoxSelect created using an array list of options" ) ) ; List < CarOption > options = new ArrayList < > ( ) ; options . add ( new CarOption ( "1" , "Ferrari" , "F-360" ) ) ; options . add ( new CarOption ( "2" , "Mercedez Benz" , "amg" ) ) ; options . add ( new CarOption ( "3" , "Nissan" , "Skyline" ) ) ; options . add ( new CarOption ( "5" , "Toyota" , "Prius" ) ) ; final WCheckBoxSelect select = new WCheckBoxSelect ( options ) ; select . setToolTip ( "Cars" ) ; final WTextField text = new WTextField ( ) ; text . setReadOnly ( true ) ; text . setText ( NO_SELECTION ) ; WButton update = new WButton ( "Select Cars" ) ; update . setAction ( new Action ( ) { public void execute ( final ActionEvent event ) { String output = select . getSelected ( ) . isEmpty ( ) ? NO_SELECTION : "The selected cars are: " + select . getSelected ( ) ; text . setText ( output ) ; } } ) ; select . setDefaultSubmitButton ( update ) ; add ( select ) ; add ( update ) ; add ( text ) ; add ( new WAjaxControl ( update , text ) ) ; } | This example creates the WCheckBoxSelect from a List of CarOptions . |
19,092 | private void addInsideAFieldLayoutExamples ( ) { add ( new WHeading ( HeadingLevel . H3 , "WCheckBoxSelect inside a WFieldLayout" ) ) ; add ( new ExplanatoryText ( "When a WCheckBoxSelect is inside a WField its label is exposed in a way which appears and behaves like a regular " + "HTML label. This allows WCheckBoxSelects to be used in a layout with simple form controls (such as WTextField) and produce a " + "consistent and predicatable interface. The third example in this set uses a null label and a toolTip to hide the labelling " + "element. This can lead to user confusion and is not recommended." ) ) ; WFieldLayout layout = new WFieldLayout ( ) ; layout . setLabelWidth ( 25 ) ; add ( layout ) ; String [ ] options = new String [ ] { "Dog" , "Cat" , "Bird" , "Turtle" } ; WCheckBoxSelect select = new WCheckBoxSelect ( options ) ; layout . addField ( "Select some animals" , select ) ; String [ ] options2 = new String [ ] { "Parrot" , "Galah" , "Cockatoo" , "Lyre" } ; select = new WCheckBoxSelect ( options2 ) ; layout . addField ( "Select some birds" , select ) ; select . setFrameless ( true ) ; String [ ] options3 = new String [ ] { "Carrot" , "Beet" , "Brocolli" , "Bacon - the perfect vegetable" } ; select = new WCheckBoxSelect ( options3 ) ; layout . addField ( ( WLabel ) null , select ) ; select . setToolTip ( "Veggies" ) ; select = new WCheckBoxSelect ( "australian_state" ) ; layout . addField ( "Select a state" , select ) . getLabel ( ) . setHint ( "This is an ajax trigger" ) ; add ( new WAjaxControl ( select , layout ) ) ; } | When a WCheckBoxSelect is added to a WFieldLayout the legend is moved . The first CheckBoxSelect has a frame the second doesn t |
19,093 | private void addColumnSelectExample ( ) { add ( new WHeading ( HeadingLevel . H3 , "WCheckBoxSelect laid out in columns" ) ) ; add ( new ExplanatoryText ( "Setting the layout to COLUMN will make the check boxes be rendered in 'n' columns. The number of columns is" + " determined by the layoutColumnCount property." ) ) ; final WCheckBoxSelect select = new WCheckBoxSelect ( "australian_state" ) ; select . setToolTip ( "Make a selection" ) ; select . setButtonLayout ( WCheckBoxSelect . LAYOUT_COLUMNS ) ; select . setButtonColumns ( 2 ) ; add ( select ) ; add ( new WHeading ( HeadingLevel . H3 , "Options equal to columns" ) ) ; String [ ] options = new String [ ] { "Dog" , "Cat" , "Bird" } ; final WCheckBoxSelect select2 = new WCheckBoxSelect ( options ) ; select2 . setToolTip ( "Animals" ) ; select2 . setButtonColumns ( 3 ) ; final WTextField text = new WTextField ( ) ; text . setReadOnly ( true ) ; text . setText ( NO_SELECTION ) ; WButton update = new WButton ( "Select Animals" ) ; update . setAction ( new Action ( ) { public void execute ( final ActionEvent event ) { String output = select2 . getSelected ( ) . isEmpty ( ) ? NO_SELECTION : "The selected animals are: " + select2 . getSelected ( ) ; text . setText ( output ) ; } } ) ; select2 . setDefaultSubmitButton ( update ) ; add ( select2 ) ; add ( update ) ; add ( text ) ; add ( new WAjaxControl ( update , text ) ) ; } | adds a WCheckBoxSelect with LAYOUT_COLUMN in 2 columns . |
19,094 | private void addAntiPatternExamples ( ) { add ( new WHeading ( HeadingLevel . H2 , "WCheckBoxSelect anti-pattern examples" ) ) ; add ( new WMessageBox ( WMessageBox . WARN , "These examples are purposely bad and should not be used as samples of how to use WComponents but samples of how NOT to use them." ) ) ; add ( new WHeading ( HeadingLevel . H3 , "WCheckBoxSelect with submitOnChange" ) ) ; WFieldLayout layout = new WFieldLayout ( WFieldLayout . LAYOUT_STACKED ) ; add ( layout ) ; WCheckBoxSelect select = new WCheckBoxSelect ( "australian_state" ) ; select . setSubmitOnChange ( true ) ; layout . addField ( "Select a state or territory with auto save" , select ) ; select = new WCheckBoxSelect ( "australian_state" ) ; select . setSubmitOnChange ( true ) ; layout . addField ( "Select a state or territory with auto save and hint" , select ) . getLabel ( ) . setHint ( "This is a hint" ) ; add ( new WHeading ( HeadingLevel . H3 , "WCheckBoxSelect with no labelling component" ) ) ; add ( new ExplanatoryText ( "All input controls, even those which are complex and do not output labellable HTML elements, must be associated with" + " a WLabel or have a toolTip." ) ) ; add ( new WCheckBoxSelect ( "australian_state" ) ) ; add ( new WHeading ( HeadingLevel . H3 , "WCheckBoxSelect with too many options" ) ) ; add ( new ExplanatoryText ( "Don't use a WCheckBoxSelect if you have more than a handful of options. A good rule of thumb is fewer than 10." ) ) ; select = new WCheckBoxSelect ( new String [ ] { "a" , "b" , "c" , "d" , "e" , "f" , "g" , "h" , "i" , "j" , "k" , "l" , "m" , "n" , "o" , "p" , "q" , "r" , "s" , "t" , "u" , "v" , "w" , "x" , "y" , "z" } ) ; select . setButtonLayout ( WCheckBoxSelect . LAYOUT_COLUMNS ) ; select . setButtonColumns ( 6 ) ; select . setFrameless ( true ) ; add ( new WLabel ( "Select your country of birth" , select ) ) ; add ( select ) ; add ( new WHeading ( HeadingLevel . H3 , "WCheckBoxSelect with no options." ) ) ; add ( new ExplanatoryText ( "An interactive WCheckBoxSelect with no options is rather pointless." ) ) ; select = new WCheckBoxSelect ( ) ; add ( new WLabel ( "WCheckBoxSelect with no options" , select ) ) ; add ( select ) ; } | Examples of what not to do when using WCheckBoxSelect . |
19,095 | private void paintAjaxTrigger ( final WLink link , final XmlStringBuilder xml ) { AjaxTarget [ ] actionTargets = link . getActionTargets ( ) ; xml . appendTagOpen ( "ui:ajaxtrigger" ) ; xml . appendAttribute ( "triggerId" , link . getId ( ) ) ; xml . appendClose ( ) ; if ( actionTargets != null && actionTargets . length > 0 ) { for ( AjaxTarget target : actionTargets ) { xml . appendTagOpen ( "ui:ajaxtargetid" ) ; xml . appendAttribute ( "targetId" , target . getId ( ) ) ; xml . appendEnd ( ) ; } } else { xml . appendTagOpen ( "ui:ajaxtargetid" ) ; xml . appendAttribute ( "targetId" , link . getId ( ) ) ; xml . appendEnd ( ) ; } xml . appendEndTag ( "ui:ajaxtrigger" ) ; } | Paint the AJAX trigger if the link has an action . |
19,096 | public void paint ( final RenderContext renderContext ) { if ( ! ( renderContext instanceof WebXmlRenderContext ) ) { throw new SystemException ( "Unable to render to " + renderContext ) ; } PrintWriter writer = ( ( WebXmlRenderContext ) renderContext ) . getWriter ( ) ; Template template = null ; try { template = VelocityEngineFactory . getVelocityEngine ( ) . getTemplate ( templateUrl ) ; } catch ( Exception ex ) { String message = "Could not open velocity template \"" + templateUrl + "\" for \"" + this . getClass ( ) . getName ( ) + "\"" ; LOG . error ( message , ex ) ; writer . println ( message ) ; return ; } try { VelocityContext context = new VelocityContext ( ) ; fillContext ( context ) ; template . merge ( context , writer ) ; } catch ( ResourceNotFoundException rnfe ) { LOG . error ( "Could not find template " + templateUrl , rnfe ) ; } catch ( ParseErrorException pee ) { LOG . error ( "Parse problems" , pee ) ; } catch ( MethodInvocationException mie ) { Throwable wrapped = mie . getWrappedThrowable ( ) ; LOG . error ( "Problems with velocity" , mie ) ; if ( wrapped != null ) { LOG . error ( "Wrapped exception..." , wrapped ) ; } } catch ( Exception e ) { LOG . error ( "Problems with velocity" , e ) ; } } | Renders the component using the velocity template which has been provided . |
19,097 | private static String [ ] getRegions ( final String state ) { if ( "ACT" . equals ( state ) ) { return ACT_REGIONS ; } else if ( "VIC" . equals ( state ) ) { return VIC_REGIONS ; } else { return null ; } } | Retrieves the regions in a state . |
19,098 | private static String [ ] getSuburbs ( final String region ) { if ( "Tuggeranong" . equals ( region ) ) { return TUGGERANONG_SUBURBS ; } else if ( "Woden" . equals ( region ) ) { return WODEN_SUBURBS ; } else if ( "Melbourne" . equals ( region ) ) { return MELBOURNE_SUBURBS ; } else if ( "Mornington Peninsula" . equals ( region ) ) { return MORNINGTON_SUBURBS ; } else { return null ; } } | Retrieves the suburbs in a region . |
19,099 | private void applySettings ( ) { container . reset ( ) ; WText component1 = new WText ( "Here is some text that is collapsible via ajax." ) ; WCollapsible collapsible1 = new WCollapsible ( component1 , "Collapsible" , ( CollapsibleMode ) rbCollapsibleSelect . getSelected ( ) ) ; collapsible1 . setCollapsed ( cbCollapsed . isSelected ( ) ) ; collapsible1 . setVisible ( cbVisible . isSelected ( ) ) ; if ( collapsible1 . getMode ( ) == CollapsibleMode . DYNAMIC ) { component1 . setText ( component1 . getText ( ) + "\u00a0Generated on " + new Date ( ) ) ; } if ( drpHeadingLevels . getSelected ( ) != null ) { collapsible1 . setHeadingLevel ( ( HeadingLevel ) drpHeadingLevels . getSelected ( ) ) ; } container . add ( collapsible1 ) ; } | applySettings creates the WCollapsible and loads it into the container . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.