idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
18,700 | private void load ( final String key , final String value , final String location ) { if ( INCLUDE . equals ( key ) ) { load ( parseStringArray ( value ) ) ; } else { backing . put ( key , value ) ; if ( "yes" . equals ( value ) || "true" . equals ( value ) ) { booleanBacking . add ( key ) ; } else { booleanBacking . remove ( key ) ; } String history = locations . get ( key ) ; if ( history == null ) { history = location ; } else { history = location + "; " + history ; } locations . put ( key , history ) ; } } | Loads a single parameter into the configuration . This handles the special directives such as include . |
18,701 | private void load ( final String [ ] subFiles ) { for ( int i = 0 ; i < subFiles . length ; i ++ ) { load ( subFiles [ i ] ) ; } } | Loads the configuration from a set of files . |
18,702 | public Properties getSubProperties ( final String prefix , final boolean truncate ) { String cacheKey = truncate + prefix ; Properties sub = subcontextCache . get ( cacheKey ) ; if ( sub != null ) { Properties copy = new Properties ( ) ; copy . putAll ( sub ) ; return copy ; } sub = new Properties ( ) ; int length = prefix . length ( ) ; for ( Map . Entry < String , Object > entry : backing . entrySet ( ) ) { String key = entry . getKey ( ) ; if ( key . startsWith ( prefix ) ) { String newKey = key ; if ( truncate ) { newKey = key . substring ( length ) ; } sub . setProperty ( newKey , ( String ) entry . getValue ( ) ) ; } } subcontextCache . put ( cacheKey , sub ) ; Properties copy = new Properties ( ) ; copy . putAll ( sub ) ; return copy ; } | Returns a sub - set of the parameters contained in this configuration . |
18,703 | public void preparePaintComponent ( final Request request ) { if ( ! this . isInitialised ( ) ) { productRepeater . setData ( fetchProductData ( ) ) ; this . setInitialised ( true ) ; } } | Override to initialise some data . |
18,704 | public static String unescapeToXML ( final String input ) { if ( Util . empty ( input ) ) { return input ; } String encoded = WebUtilities . doubleEncodeBrackets ( input ) ; String unescaped = UNESCAPE_HTML_TO_XML . translate ( encoded ) ; String decoded = WebUtilities . doubleDecodeBrackets ( unescaped ) ; return decoded ; } | Unescape HTML entities to safe XML . |
18,705 | public Message toMessage ( final Throwable throwable ) { LOG . error ( "The system is currently unavailable" , throwable ) ; return new Message ( Message . ERROR_MESSAGE , InternalMessages . DEFAULT_SYSTEM_ERROR ) ; } | This method converts a java Throwable into a user friendly error message . |
18,706 | public void addTargets ( final List < ? extends AjaxTarget > targets ) { if ( targets != null ) { for ( AjaxTarget target : targets ) { this . addTarget ( target ) ; } } } | Add a list of target components that should be targets for this AJAX request . |
18,707 | public void addTarget ( final AjaxTarget target ) { AjaxControlModel model = getOrCreateComponentModel ( ) ; if ( model . targets == null ) { model . targets = new ArrayList < > ( ) ; } model . targets . add ( target ) ; MemoryUtil . checkSize ( model . targets . size ( ) , this . getClass ( ) . getSimpleName ( ) ) ; } | Add a single target WComponent to this AJAX control . |
18,708 | protected void preparePaintComponent ( final Request request ) { super . preparePaintComponent ( request ) ; List < AjaxTarget > targets = getTargets ( ) ; if ( targets != null && ! targets . isEmpty ( ) ) { WComponent triggerComponent = trigger == null ? this : trigger ; UIContext triggerContext = WebUtilities . getContextForComponent ( triggerComponent ) ; UIContextHolder . pushContext ( triggerContext ) ; try { List < String > targetIds = new ArrayList < > ( ) ; for ( AjaxTarget target : getTargets ( ) ) { targetIds . add ( target . getId ( ) ) ; } AjaxHelper . registerComponents ( targetIds , triggerComponent . getId ( ) ) ; } finally { UIContextHolder . popContext ( ) ; } } } | Override preparePaintComponent in order to register the components for the current request . |
18,709 | public void setCaseSensitiveMatch ( final Boolean caseInsensitive ) { FilterableBeanBoundDataModel model = getFilterableTableModel ( ) ; if ( model != null ) { model . setCaseSensitiveMatch ( caseInsensitive ) ; } } | Set the filter case sensitivity . |
18,710 | private WDecoratedLabel buildColumnHeader ( final String text , final WMenu menu ) { WDecoratedLabel label = new WDecoratedLabel ( null , new WText ( text ) , menu ) ; return label ; } | Helper to create the table column heading s WDecoratedLabel . |
18,711 | private void buildFilterMenus ( ) { buildFilterSubMenu ( firstNameFilterMenu , FIRST_NAME ) ; if ( firstNameFilterMenu . getChildCount ( ) == 0 ) { firstNameFilterMenu . setVisible ( false ) ; } buildFilterSubMenu ( lastNameFilterMenu , LAST_NAME ) ; if ( lastNameFilterMenu . getChildCount ( ) == 0 ) { lastNameFilterMenu . setVisible ( false ) ; } buildFilterSubMenu ( dobFilterMenu , DOB ) ; if ( dobFilterMenu . getChildCount ( ) == 0 ) { dobFilterMenu . setVisible ( false ) ; } } | Builds the menu content for each column heading s filter menu . |
18,712 | private void setUpClearAllAction ( ) { int visibleMenus = 0 ; if ( firstNameFilterMenu . isVisible ( ) ) { visibleMenus ++ ; } if ( lastNameFilterMenu . isVisible ( ) ) { visibleMenus ++ ; } if ( dobFilterMenu . isVisible ( ) ) { visibleMenus ++ ; } clearAllFiltersButton . setVisible ( visibleMenus > 1 ) ; if ( clearAllFiltersButton . isVisible ( ) ) { List < ? > fullList = getFilterableTableModel ( ) . getFullBeanList ( ) ; List < ? > filteredList = getFilterableTableModel ( ) . getBeanList ( ) ; clearAllFiltersButton . setDisabled ( fullList == null || filteredList == null || fullList . size ( ) == filteredList . size ( ) ) ; } } | Sets the state of the clearAllActions button based on the visibility of the filter menus and if the button is visible sets its disabled state if nothing is filtered . |
18,713 | private void buildFilterSubMenu ( final WMenu menu , final int column ) { List < ? > beanList = getFilterableTableModel ( ) . getFullBeanList ( ) ; int rows = ( beanList == null ) ? 0 : beanList . size ( ) ; if ( rows == 0 ) { return ; } final List < String > found = new ArrayList < > ( ) ; final WDecoratedLabel filterSubMenuLabel = new WDecoratedLabel ( new WText ( "\u200b" ) ) ; filterSubMenuLabel . setToolTip ( "Filter this column" ) ; filterSubMenuLabel . setHtmlClass ( HtmlIconUtil . getIconClasses ( "fa-filter" ) ) ; final WSubMenu submenu = new WSubMenu ( filterSubMenuLabel ) ; submenu . setSelectionMode ( SELECTION_MODE ) ; menu . add ( submenu ) ; WMenuItem item = new WMenuItem ( CLEAR_ALL , new ClearFilterAction ( ) ) ; submenu . add ( item ) ; item . setActionObject ( item ) ; item . setSelectability ( false ) ; add ( new WAjaxControl ( item , table ) ) ; Object cellObject ; String cellContent , cellContentMatch ; Object bean ; if ( beanList != null ) { for ( int i = 0 ; i < rows ; ++ i ) { bean = beanList . get ( i ) ; if ( bean != null ) { cellObject = getFilterableTableModel ( ) . getBeanPropertyValueFullList ( BEAN_PROPERTIES [ column ] , bean ) ; if ( cellObject != null ) { if ( cellObject instanceof Date ) { cellContent = new SimpleDateFormat ( DATE_FORMAT ) . format ( ( Date ) cellObject ) ; } else { cellContent = cellObject . toString ( ) ; } if ( "" . equals ( cellContent ) ) { cellContent = EMPTY ; } cellContentMatch = ( getFilterableTableModel ( ) . isCaseInsensitiveMatch ( ) ) ? cellContent . toLowerCase ( ) : cellContent ; if ( found . indexOf ( cellContentMatch ) == - 1 ) { item = new WMenuItem ( cellContent , new FilterAction ( ) ) ; submenu . add ( item ) ; add ( new WAjaxControl ( item , table ) ) ; found . add ( cellContentMatch ) ; } } } } } } | Creates and populates the sub - menu for each filter menu . |
18,714 | public void setUrl ( final String url ) { String currUrl = getUrl ( ) ; if ( ! Objects . equals ( url , currUrl ) ) { getOrCreateComponentModel ( ) . url = url ; } } | Sets the URL . |
18,715 | public void setTargetWindow ( final String targetWindow ) { String currTargWin = getTargetWindow ( ) ; if ( ! Objects . equals ( targetWindow , currTargWin ) ) { getOrCreateComponentModel ( ) . targetWindow = targetWindow ; } } | Sets the target window name . |
18,716 | private void dumpWEnvironment ( ) { StringBuffer text = new StringBuffer ( ) ; Environment env = getEnvironment ( ) ; text . append ( "\n\nWEnvironment" + "\n------------" ) ; text . append ( "\nAppId: " ) . append ( env . getAppId ( ) ) ; text . append ( "\nBaseUrl: " ) . append ( env . getBaseUrl ( ) ) ; text . append ( "\nHostFreeBaseUrl: " ) . append ( env . getHostFreeBaseUrl ( ) ) ; text . append ( "\nPostPath: " ) . append ( env . getPostPath ( ) ) ; text . append ( "\nTargetablePath: " ) . append ( env . getWServletPath ( ) ) ; text . append ( "\nAppHostPath: " ) . append ( env . getAppHostPath ( ) ) ; text . append ( "\nThemePath: " ) . append ( env . getThemePath ( ) ) ; text . append ( "\nStep: " ) . append ( env . getStep ( ) ) ; text . append ( "\nSession Token: " ) . append ( env . getSessionToken ( ) ) ; text . append ( "\nFormEncType: " ) . append ( env . getFormEncType ( ) ) ; text . append ( '\n' ) ; appendToConsole ( text . toString ( ) ) ; } | Appends the current environment to the console . |
18,717 | public static Configuration copyConfiguration ( final Configuration original ) { Configuration copy = new MapConfiguration ( new HashMap < String , Object > ( ) ) ; for ( Iterator < ? > i = original . getKeys ( ) ; i . hasNext ( ) ; ) { String key = ( String ) i . next ( ) ; Object value = original . getProperty ( key ) ; if ( value instanceof List ) { value = new ArrayList ( ( List ) value ) ; } copy . setProperty ( key , value ) ; } return copy ; } | Creates a deep - copy of the given configuration . This is useful for unit - testing . |
18,718 | public List < String > getFileTypes ( ) { List < String > fileTypes = getComponentModel ( ) . fileTypes ; if ( fileTypes == null ) { return Collections . emptyList ( ) ; } return Collections . unmodifiableList ( fileTypes ) ; } | Returns a list of strings that determine the allowable file mime types accepted by the file input . If no types have been added an empty list is returned . An empty list indicates that all file types are accepted . |
18,719 | public void setFileTypes ( final String [ ] types ) { if ( types == null ) { setFileTypes ( ( List < String > ) null ) ; } else { setFileTypes ( Arrays . asList ( types ) ) ; } } | Set each file type to be accepted by the WFileWidget . |
18,720 | private void resetValidationState ( ) { final FileWidgetModel componentModel = getComponentModel ( ) ; if ( ! componentModel . validFileSize || ! componentModel . validFileType ) { final FileWidgetModel userModel = getOrCreateComponentModel ( ) ; userModel . validFileType = true ; userModel . validFileSize = true ; } } | Reset validation state . |
18,721 | public InputStream getInputStream ( ) throws IOException { FileItemWrap wrapper = getValue ( ) ; if ( wrapper != null ) { return wrapper . getInputStream ( ) ; } return null ; } | Retrieves an input stream of the uploaded file s contents . |
18,722 | public Object getData ( ) { Object data = super . getData ( ) ; if ( isRichTextArea ( ) && isSanitizeOnOutput ( ) && data != null ) { return sanitizeOutputText ( data . toString ( ) ) ; } return data ; } | The data for this WTextArea . If the text area is not rich text its output is XML escaped so we can ignore sanitization . If the text area is a rich text area then we check the sanitizeOnOutput flag as sanitization is rather resource intensive . |
18,723 | public void setData ( final Object data ) { if ( isRichTextArea ( ) && data instanceof String ) { super . setData ( sanitizeInputText ( ( String ) data ) ) ; } else { super . setData ( data ) ; } } | Set data in this component . If the WTextArea is a rich text input we need to sanitize the input . |
18,724 | public static List < Diagnostic > extractDiagnostics ( final List < Diagnostic > diagnostics , final int severity ) { ArrayList < Diagnostic > extract = new ArrayList < > ( ) ; for ( Diagnostic diagnostic : diagnostics ) { if ( diagnostic . getSeverity ( ) == severity ) { extract . add ( diagnostic ) ; } } return extract ; } | Extract diagnostics with a given severity from a list of Diagnostic objects . This is useful for picking errors out from a list of diagnostics for example . |
18,725 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WCollapsible collapsible = ( WCollapsible ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; WComponent content = collapsible . getContent ( ) ; boolean collapsed = collapsible . isCollapsed ( ) ; xml . appendTagOpen ( "ui:collapsible" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendAttribute ( "groupName" , collapsible . getGroupName ( ) ) ; xml . appendOptionalAttribute ( "collapsed" , collapsed , "true" ) ; xml . appendOptionalAttribute ( "hidden" , collapsible . isHidden ( ) , "true" ) ; switch ( collapsible . getMode ( ) ) { case CLIENT : xml . appendAttribute ( "mode" , "client" ) ; break ; case LAZY : xml . appendAttribute ( "mode" , "lazy" ) ; break ; case EAGER : xml . appendAttribute ( "mode" , "eager" ) ; break ; case DYNAMIC : xml . appendAttribute ( "mode" , "dynamic" ) ; break ; case SERVER : xml . appendAttribute ( "mode" , "server" ) ; break ; default : throw new SystemException ( "Unknown collapsible mode: " + collapsible . getMode ( ) ) ; } HeadingLevel level = collapsible . getHeadingLevel ( ) ; if ( level != null ) { xml . appendAttribute ( "level" , level . getLevel ( ) ) ; } xml . appendClose ( ) ; MarginRendererUtil . renderMargin ( collapsible , renderContext ) ; collapsible . getDecoratedLabel ( ) . paint ( renderContext ) ; xml . appendTagOpen ( "ui:content" ) ; xml . appendAttribute ( "id" , component . getId ( ) + "-content" ) ; xml . appendClose ( ) ; if ( CollapsibleMode . EAGER != collapsible . getMode ( ) || AjaxHelper . isCurrentAjaxTrigger ( collapsible ) ) { content . paint ( renderContext ) ; } xml . appendEndTag ( "ui:content" ) ; xml . appendEndTag ( "ui:collapsible" ) ; } | Paints the given WCollapsible . |
18,726 | private void toggleReadOnly ( ) { allFiles . setReadOnly ( ! allFiles . isReadOnly ( ) ) ; imageFiles . setReadOnly ( ! imageFiles . isReadOnly ( ) ) ; textFiles . setReadOnly ( ! textFiles . isReadOnly ( ) ) ; pdfFiles . setReadOnly ( ! pdfFiles . isReadOnly ( ) ) ; } | Toggles the readonly state off all file widgets in the example . |
18,727 | private void processFiles ( ) { StringBuffer buf = new StringBuffer ( ) ; appendFileDetails ( buf , allFiles ) ; appendFileDetails ( buf , textFiles ) ; appendFileDetails ( buf , pdfFiles ) ; console . setText ( buf . toString ( ) ) ; } | Outputs information on the uploaded files to the text area . |
18,728 | private void appendFileDetails ( final StringBuffer buf , final WMultiFileWidget fileWidget ) { List < FileWidgetUpload > files = fileWidget . getFiles ( ) ; if ( files != null ) { for ( FileWidgetUpload file : files ) { String streamedSize ; try { InputStream in = file . getFile ( ) . getInputStream ( ) ; int size = 0 ; while ( in . read ( ) >= 0 ) { size ++ ; } streamedSize = String . valueOf ( size ) ; } catch ( IOException e ) { streamedSize = e . getMessage ( ) ; } buf . append ( "Name: " ) . append ( file . getFile ( ) . getName ( ) ) ; buf . append ( "\nSize: " ) . append ( streamedSize ) . append ( " bytes\n\n" ) ; } } } | Appends details of the uploaded files to the given string buffer . |
18,729 | public String getUrl ( ) { ContentAccess content = getContentAccess ( ) ; String mode = DisplayMode . PROMPT_TO_SAVE . equals ( getDisplayMode ( ) ) ? "attach" : "inline" ; if ( content instanceof InternalResource ) { String url = ( ( InternalResource ) content ) . getTargetUrl ( ) ; url = url + "&" + URL_CONTENT_MODE_PARAMETER_KEY + "=" + mode ; return url ; } Environment env = getEnvironment ( ) ; Map < String , String > parameters = env . getHiddenParameters ( ) ; parameters . put ( Environment . TARGET_ID , getTargetId ( ) ) ; if ( Util . empty ( getCacheKey ( ) ) ) { String random = WebUtilities . generateRandom ( ) ; parameters . put ( Environment . UNIQUE_RANDOM_PARAM , random ) ; } else { parameters . remove ( Environment . STEP_VARIABLE ) ; parameters . remove ( Environment . SESSION_TOKEN_VARIABLE ) ; parameters . put ( Environment . CONTENT_CACHE_KEY , getCacheKey ( ) ) ; } parameters . put ( URL_CONTENT_MODE_PARAMETER_KEY , mode ) ; String url = env . getWServletPath ( ) ; return WebUtilities . getPath ( url , parameters , true ) ; } | Retrieves a dynamic URL which this targetable component can be accessed from . |
18,730 | private void applySettings ( ) { container . reset ( ) ; WList list = new WList ( ( com . github . bordertech . wcomponents . WList . Type ) ddType . getSelected ( ) ) ; List < String > selected = ( List < String > ) cgBeanFields . getSelected ( ) ; SimpleListRenderer renderer = new SimpleListRenderer ( selected , cbRenderUsingFieldLayout . isSelected ( ) ) ; list . setRepeatedComponent ( renderer ) ; list . setSeparator ( ( Separator ) ddSeparator . getSelected ( ) ) ; list . setRenderBorder ( cbRenderBorder . isSelected ( ) ) ; container . add ( list ) ; List < SimpleTableBean > items = new ArrayList < > ( ) ; items . add ( new SimpleTableBean ( "A" , "none" , "thing" ) ) ; items . add ( new SimpleTableBean ( "B" , "some" , "thing2" ) ) ; items . add ( new SimpleTableBean ( "C" , "little" , "thing3" ) ) ; items . add ( new SimpleTableBean ( "D" , "lots" , "thing4" ) ) ; list . setData ( items ) ; list . setVisible ( cbVisible . isSelected ( ) ) ; } | Apply settings is responsible for building the list to be displayed and adding it to the container . |
18,731 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WNumberField field = ( WNumberField ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; boolean readOnly = field . isReadOnly ( ) ; BigDecimal value = field . getValue ( ) ; String userText = field . getText ( ) ; xml . appendTagOpen ( "ui:numberfield" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , component . isHidden ( ) , "true" ) ; if ( readOnly ) { xml . appendAttribute ( "readOnly" , "true" ) ; } else { WComponent submitControl = field . getDefaultSubmitButton ( ) ; String submitControlId = submitControl == null ? null : submitControl . getId ( ) ; BigDecimal min = field . getMinValue ( ) ; BigDecimal max = field . getMaxValue ( ) ; BigDecimal step = field . getStep ( ) ; int decimals = field . getDecimalPlaces ( ) ; xml . appendOptionalAttribute ( "disabled" , field . isDisabled ( ) , "true" ) ; xml . appendOptionalAttribute ( "required" , field . isMandatory ( ) , "true" ) ; xml . appendOptionalAttribute ( "toolTip" , field . getToolTip ( ) ) ; xml . appendOptionalAttribute ( "accessibleText" , field . getAccessibleText ( ) ) ; xml . appendOptionalAttribute ( "min" , min != null , String . valueOf ( min ) ) ; xml . appendOptionalAttribute ( "max" , max != null , String . valueOf ( max ) ) ; xml . appendOptionalAttribute ( "step" , step != null , String . valueOf ( step ) ) ; xml . appendOptionalAttribute ( "decimals" , decimals > 0 , decimals ) ; xml . appendOptionalAttribute ( "buttonId" , submitControlId ) ; String autocomplete = field . getAutocomplete ( ) ; xml . appendOptionalAttribute ( "autocomplete" , ! Util . empty ( autocomplete ) , autocomplete ) ; } xml . appendClose ( ) ; xml . appendEscaped ( value == null ? userText : value . toString ( ) ) ; if ( ! readOnly ) { DiagnosticRenderUtil . renderDiagnostics ( field , renderContext ) ; } xml . appendEndTag ( "ui:numberfield" ) ; } | Paints the given WNumberField . |
18,732 | public void write ( final int c ) { WhiteSpaceFilterStateMachine . StateChange change = stateMachine . nextState ( ( char ) c ) ; if ( change . getOutputBytes ( ) != null ) { for ( int i = 0 ; i < change . getOutputBytes ( ) . length ; i ++ ) { super . write ( change . getOutputBytes ( ) [ i ] ) ; } } if ( ! change . isSuppressCurrentChar ( ) ) { super . write ( c ) ; } } | Writes the given byte to the underlying output stream if it passes filtering . |
18,733 | public void write ( final String string , final int off , final int len ) { for ( int i = off ; i < off + len ; i ++ ) { write ( string . charAt ( i ) ) ; } } | Writes the given String to the underlying output stream filtering as necessary . |
18,734 | protected boolean execute ( final Request request ) { for ( Condition condition : conditions ) { if ( condition . isTrue ( request ) ) { return true ; } } return false ; } | Evaluates the condition using values on the Request . Note that this uses the short - circuit or operator so condition b will not necessarily be evaluated . |
18,735 | public R fetch ( String properties ) { ( ( TQRootBean ) _root ) . query ( ) . fetch ( _name , properties ) ; return _root ; } | Eagerly fetch this association with the properties specified . |
18,736 | public R fetchQuery ( String properties ) { ( ( TQRootBean ) _root ) . query ( ) . fetchQuery ( _name , properties ) ; return _root ; } | Eagerly fetch this association using a query join with the properties specified . |
18,737 | protected R fetchProperties ( TQProperty < ? > ... props ) { ( ( TQRootBean ) _root ) . query ( ) . fetch ( _name , properties ( props ) ) ; return _root ; } | Eagerly fetch this association fetching some of the properties . |
18,738 | protected String properties ( TQProperty < ? > ... props ) { StringBuilder selectProps = new StringBuilder ( 50 ) ; for ( int i = 0 ; i < props . length ; i ++ ) { if ( i > 0 ) { selectProps . append ( "," ) ; } selectProps . append ( props [ i ] . propertyName ( ) ) ; } return selectProps . toString ( ) ; } | Append the properties as a comma delimited string . |
18,739 | public R filterMany ( ExpressionList < T > filter ) { @ SuppressWarnings ( "unchecked" ) ExpressionList < T > expressionList = ( ExpressionList < T > ) expr ( ) . filterMany ( _name ) ; expressionList . addAll ( filter ) ; return _root ; } | Apply a filter when fetching these beans . |
18,740 | public List < Event > getApp ( int appId , LocalDate dateFrom , LocalDate dateTo , ReferenceType ... types ) { return getCalendar ( "app/" + appId , dateFrom , dateTo , null , types ) ; } | Returns the items and tasks that are related to the given app . |
18,741 | public List < Event > getSpace ( int spaceId , LocalDate dateFrom , LocalDate dateTo , ReferenceType ... types ) { return getCalendar ( "space/" + spaceId , dateFrom , dateTo , null , types ) ; } | Returns all items and tasks that the user have access to in the given space . Tasks with reference to other spaces are not returned or tasks with no reference . |
18,742 | public List < Event > getGlobal ( LocalDate dateFrom , LocalDate dateTo , List < Integer > spaceIds , ReferenceType ... types ) { return getCalendar ( "" , dateFrom , dateTo , spaceIds , types ) ; } | Returns all items that the user have access to and all tasks that are assigned to the user . The items and tasks can be filtered by a list of space ids but tasks without a reference will always be returned . |
18,743 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WPasswordField field = ( WPasswordField ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; boolean readOnly = field . isReadOnly ( ) ; xml . appendTagOpen ( TAG_NAME ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , component . isHidden ( ) , "true" ) ; if ( readOnly ) { xml . appendAttribute ( "readOnly" , "true" ) ; xml . appendEnd ( ) ; return ; } int cols = field . getColumns ( ) ; int minLength = field . getMinLength ( ) ; int maxLength = field . getMaxLength ( ) ; WComponent submitControl = field . getDefaultSubmitButton ( ) ; String submitControlId = submitControl == null ? null : submitControl . getId ( ) ; xml . appendOptionalAttribute ( "disabled" , field . isDisabled ( ) , "true" ) ; xml . appendOptionalAttribute ( "required" , field . isMandatory ( ) , "true" ) ; xml . appendOptionalAttribute ( "minLength" , minLength > 0 , minLength ) ; xml . appendOptionalAttribute ( "maxLength" , maxLength > 0 , maxLength ) ; xml . appendOptionalAttribute ( "toolTip" , field . getToolTip ( ) ) ; xml . appendOptionalAttribute ( "accessibleText" , field . getAccessibleText ( ) ) ; xml . appendOptionalAttribute ( "size" , cols > 0 , cols ) ; xml . appendOptionalAttribute ( "buttonId" , submitControlId ) ; String placeholder = field . getPlaceholder ( ) ; xml . appendOptionalAttribute ( "placeholder" , ! Util . empty ( placeholder ) , placeholder ) ; String autocomplete = field . getAutocomplete ( ) ; xml . appendOptionalAttribute ( "autocomplete" , ! Util . empty ( autocomplete ) , autocomplete ) ; List < Diagnostic > diags = field . getDiagnostics ( Diagnostic . ERROR ) ; if ( diags == null || diags . isEmpty ( ) ) { xml . appendEnd ( ) ; return ; } xml . appendClose ( ) ; DiagnosticRenderUtil . renderDiagnostics ( field , renderContext ) ; xml . appendEndTag ( TAG_NAME ) ; } | Paints the given WPasswordField . |
18,744 | public void handleRequest ( final Request request ) { if ( ! isInitialised ( ) ) { getOrCreateComponentModel ( ) . delegate = new SafetyContainerDelegate ( UIContextHolder . getCurrent ( ) ) ; setInitialised ( true ) ; } try { UIContext delegate = getComponentModel ( ) . delegate ; UIContextHolder . pushContext ( delegate ) ; try { for ( int i = 0 ; i < shim . getChildCount ( ) ; i ++ ) { shim . getChildAt ( i ) . serviceRequest ( request ) ; } delegate . doInvokeLaters ( ) ; } finally { UIContextHolder . popContext ( ) ; } } catch ( final ActionEscape e ) { throw e ; } catch ( final Exception e ) { if ( isAjaxOrTargetedRequest ( request ) ) { throw new SystemException ( e . getMessage ( ) , e ) ; } else { setAttribute ( ERROR_KEY , e ) ; } } } | Override handleRequest in order to safely process the example component which has been excluded from normal WComponent processing . |
18,745 | public void resetContent ( ) { for ( int i = 0 ; i < shim . getChildCount ( ) ; i ++ ) { WComponent child = shim . getChildAt ( i ) ; child . reset ( ) ; } removeAttribute ( SafetyContainer . ERROR_KEY ) ; } | Resets the contents . |
18,746 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WRadioButton button = ( WRadioButton ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; boolean readOnly = button . isReadOnly ( ) ; String value = button . getValue ( ) ; xml . appendTagOpen ( "ui:radiobutton" ) ; xml . appendAttribute ( "id" , component . getId ( ) ) ; xml . appendOptionalAttribute ( "class" , component . getHtmlClass ( ) ) ; xml . appendOptionalAttribute ( "track" , component . isTracking ( ) , "true" ) ; xml . appendOptionalAttribute ( "hidden" , button . isHidden ( ) , "true" ) ; xml . appendAttribute ( "groupName" , button . getGroupName ( ) ) ; xml . appendAttribute ( "value" , WebUtilities . encode ( value ) ) ; if ( readOnly ) { xml . appendAttribute ( "readOnly" , "true" ) ; } else { xml . appendOptionalAttribute ( "disabled" , button . isDisabled ( ) , "true" ) ; xml . appendOptionalAttribute ( "required" , button . isMandatory ( ) , "true" ) ; xml . appendOptionalAttribute ( "submitOnChange" , button . isSubmitOnChange ( ) , "true" ) ; xml . appendOptionalAttribute ( "toolTip" , button . getToolTip ( ) ) ; xml . appendOptionalAttribute ( "accessibleText" , button . getAccessibleText ( ) ) ; boolean isNull = value == null ? true : ( value . length ( ) == 0 ) ; xml . appendOptionalAttribute ( "isNull" , isNull , "true" ) ; } xml . appendOptionalAttribute ( "selected" , button . isSelected ( ) , "true" ) ; xml . appendEnd ( ) ; } | Paints the given WRadioButton . |
18,747 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WTabGroup group = ( WTabGroup ) component ; paintChildren ( group , renderContext ) ; } | Paints the given WTabGroup . |
18,748 | private String getApplicationTitle ( final UIContext uic ) { WComponent root = uic . getUI ( ) ; String title = root instanceof WApplication ? ( ( WApplication ) root ) . getTitle ( ) : null ; Map < String , String > params = uic . getEnvironment ( ) . getHiddenParameters ( ) ; String target = params . get ( WWindow . WWINDOW_REQUEST_PARAM_KEY ) ; if ( target != null ) { ComponentWithContext targetComp = WebUtilities . getComponentById ( target , true ) ; if ( targetComp != null && targetComp . getComponent ( ) instanceof WWindow ) { try { UIContextHolder . pushContext ( targetComp . getContext ( ) ) ; title = ( ( WWindow ) targetComp . getComponent ( ) ) . getTitle ( ) ; } finally { UIContextHolder . popContext ( ) ; } } } return title == null ? "" : title ; } | Retrieves the application title for the given context . This mess is required due to WWindow essentially existing as a separate UI root . If WWindow is eventually removed then we can just retrieve the title from the root WApplication . |
18,749 | private String getFilterValues ( final TableDataModel dataModel , final int rowIndex ) { List < String > filterValues = dataModel . getFilterValues ( rowIndex ) ; if ( filterValues == null || filterValues . isEmpty ( ) ) { return null ; } StringBuffer buf = new StringBuffer ( filterValues . get ( 0 ) ) ; for ( int i = 1 ; i < filterValues . size ( ) ; i ++ ) { buf . append ( ", " ) ; buf . append ( filterValues . get ( i ) ) ; } return buf . toString ( ) ; } | Retrieves the filter values for the given row in the data model as a comma - separated string . |
18,750 | public static Renderer getRenderer ( final WComponent component , final RenderContext context ) { Class < ? extends WComponent > clazz = component . getClass ( ) ; Duplet < String , Class < ? > > key = new Duplet < String , Class < ? > > ( context . getRenderPackage ( ) , clazz ) ; Renderer renderer = INSTANCE . renderers . get ( key ) ; if ( renderer == null ) { renderer = INSTANCE . findRenderer ( component , key ) ; } else if ( renderer == NULL_RENDERER ) { return null ; } return renderer ; } | Retrieves a renderer which can renderer the given component to the context . |
18,751 | public static Renderer getTemplateRenderer ( final RenderContext context ) { String packageName = context . getRenderPackage ( ) ; Renderer renderer = INSTANCE . templateRenderers . get ( packageName ) ; if ( renderer == null ) { renderer = INSTANCE . findTemplateRenderer ( packageName ) ; } else if ( renderer == NULL_RENDERER ) { return null ; } return renderer ; } | Retrieves a renderer which can renderer templates for the given context . |
18,752 | private synchronized Renderer findTemplateRenderer ( final String packageName ) { RendererFactory factory = INSTANCE . findRendererFactory ( packageName ) ; Renderer renderer = factory . getTemplateRenderer ( ) ; if ( renderer == null ) { templateRenderers . put ( packageName , NULL_RENDERER ) ; } else { templateRenderers . put ( packageName , renderer ) ; } return renderer ; } | Retrieves the template renderer for the given package . |
18,753 | public static Renderer getDefaultRenderer ( final WComponent component ) { LOG . warn ( "The getDefaultRenderer() method is deprecated. Do not obtain renderers directly." ) ; return getRenderer ( component , new WebXmlRenderContext ( new PrintWriter ( new NullWriter ( ) ) ) ) ; } | Retrieves the default LayoutManager for the given component . This method must no longer be used as it will only ever return a web - xml renderer . |
18,754 | private synchronized Renderer findRenderer ( final WComponent component , final Duplet < String , Class < ? > > key ) { LOG . info ( "Looking for layout for " + key . getSecond ( ) . getName ( ) + " in " + key . getFirst ( ) ) ; Renderer renderer = findConfiguredRenderer ( component , key . getFirst ( ) ) ; if ( renderer == null ) { renderers . put ( key , NULL_RENDERER ) ; } else { renderers . put ( key , renderer ) ; } return renderer ; } | Finds the layout for the given theme and component . |
18,755 | private synchronized RendererFactory findRendererFactory ( final String packageName ) { RendererFactory factory = factoriesByPackage . get ( packageName ) ; if ( factory == null ) { try { factory = ( RendererFactory ) Class . forName ( packageName + ".RendererFactoryImpl" ) . newInstance ( ) ; factoriesByPackage . put ( packageName , factory ) ; } catch ( Exception e ) { throw new SystemException ( "Failed to create layout manager factory for " + packageName , e ) ; } } return factory ; } | Finds the renderer factory for the given package . |
18,756 | private Renderer findConfiguredRenderer ( final WComponent component , final String rendererPackage ) { Renderer renderer = null ; for ( Class < ? > c = component . getClass ( ) ; renderer == null && c != null && ! AbstractWComponent . class . equals ( c ) ; c = c . getSuperclass ( ) ) { String qualifiedClassName = c . getName ( ) ; String rendererName = ConfigurationProperties . getRendererOverride ( qualifiedClassName ) ; if ( rendererName != null ) { renderer = createRenderer ( rendererName ) ; if ( renderer == null ) { LOG . warn ( "Layout Manager \"" + rendererName + "\" specified for " + qualifiedClassName + " was not found" ) ; } else { return renderer ; } } renderer = findRendererFactory ( rendererPackage ) . getRenderer ( c ) ; } return renderer ; } | Attempts to find the configured renderer for the given output format and component . |
18,757 | private static Renderer createRenderer ( final String rendererName ) { if ( rendererName . endsWith ( ".vm" ) ) { return new VelocityRenderer ( rendererName ) ; } try { Class < ? > managerClass = Class . forName ( rendererName ) ; Object manager = managerClass . newInstance ( ) ; if ( ! ( manager instanceof Renderer ) ) { throw new SystemException ( rendererName + " is not a Renderer" ) ; } return ( Renderer ) manager ; } catch ( ClassNotFoundException e ) { return null ; } catch ( InstantiationException e ) { throw new SystemException ( "Failed to instantiate " + rendererName , e ) ; } catch ( IllegalAccessException e ) { throw new SystemException ( "Failed to access " + rendererName , e ) ; } } | Attempts to create a Renderer with the given name . |
18,758 | private void fakeServiceCall ( ) { poller . enablePoll ( ) ; Cache . getCache ( ) . invalidate ( DATA_KEY ) ; new Thread ( ) { public void run ( ) { try { Thread . sleep ( SERVICE_TIME ) ; Cache . getCache ( ) . put ( DATA_KEY , "SUCCESS!" ) ; } catch ( InterruptedException e ) { LOG . error ( "Timed out calling service" , e ) ; Cache . getCache ( ) . put ( DATA_KEY , "Timed out!" ) ; } } } . start ( ) ; } | Fakes a service call using the WorkManager for threading . |
18,759 | public void analyseWC ( final WComponent comp ) { if ( comp == null ) { return ; } statsByWCTree . put ( comp , createWCTreeStats ( comp ) ) ; } | Creates statistics for the given WComponent within the uicontext being analysed . |
18,760 | private void addStats ( final Map < WComponent , Stat > statsMap , final WComponent comp ) { Stat stat = createStat ( comp ) ; statsMap . put ( comp , stat ) ; if ( comp instanceof Container ) { Container container = ( Container ) comp ; int childCount = container . getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { WComponent child = container . getChildAt ( i ) ; addStats ( statsMap , child ) ; } } } | Recursively adds statistics for a component and its children to the stats map . |
18,761 | private Stat createStat ( final WComponent comp ) { Stat stat = new Stat ( ) ; stat . setClassName ( comp . getClass ( ) . getName ( ) ) ; stat . setName ( comp . getId ( ) ) ; if ( stat . getName ( ) == null ) { stat . setName ( "Unknown" ) ; } if ( comp instanceof AbstractWComponent ) { Object obj = AbstractWComponent . replaceWComponent ( ( AbstractWComponent ) comp ) ; if ( obj instanceof AbstractWComponent . WComponentRef ) { stat . setRef ( obj . toString ( ) ) ; } } ComponentModel model = ( ComponentModel ) uic . getModel ( comp ) ; stat . setModelState ( Stat . MDL_NONE ) ; if ( model != null ) { if ( comp . isDefaultState ( ) ) { stat . setModelState ( Stat . MDL_DEFAULT ) ; } else { addSerializationStat ( model , stat ) ; } } return stat ; } | Creates statistics for a component in the given context . |
18,762 | private int getSerializationSize ( final Object obj ) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( bos ) ; oos . writeObject ( obj ) ; oos . close ( ) ; byte [ ] bytes = bos . toByteArray ( ) ; return bytes . length ; } catch ( IOException ex ) { return - 1 ; } } | Determines the serialized size of an object by serializng it to a byte array . |
18,763 | private WDataTable createTable ( ) { WDataTable tbl = new WDataTable ( ) ; tbl . addColumn ( new WTableColumn ( "First name" , new WTextField ( ) ) ) ; tbl . addColumn ( new WTableColumn ( "Last name" , new WTextField ( ) ) ) ; tbl . addColumn ( new WTableColumn ( "DOB" , new WDateField ( ) ) ) ; return tbl ; } | Creates and configures the table to be used by the example . |
18,764 | protected void preparePaintComponent ( final Request request ) { if ( ! isInitialised ( ) ) { MyData data = new MyData ( "Homer" ) ; basic . setData ( data ) ; List < MyData > dataList = new ArrayList < > ( ) ; dataList . add ( new MyData ( "Homer" ) ) ; dataList . add ( new MyData ( "Marge" ) ) ; dataList . add ( new MyData ( "Bart" ) ) ; repeated . setBeanList ( dataList ) ; dataList = new ArrayList < > ( ) ; dataList . add ( new MyData ( "Greg" ) ) ; dataList . add ( new MyData ( "Jeff" ) ) ; dataList . add ( new MyData ( "Anthony" ) ) ; dataList . add ( new MyData ( "Murray" ) ) ; repeatedLink . setData ( dataList ) ; List < List < MyData > > rootList = new ArrayList < > ( ) ; List < MyData > subList = new ArrayList < > ( ) ; subList . add ( new MyData ( "Ernie" ) ) ; subList . add ( new MyData ( "Bert" ) ) ; rootList . add ( subList ) ; subList = new ArrayList < > ( ) ; subList . add ( new MyData ( "Starsky" ) ) ; subList . add ( new MyData ( "Hutch" ) ) ; rootList . add ( subList ) ; nestedRepeaterTab . setData ( rootList ) ; setInitialised ( true ) ; } } | Override preparePaint to initialise the data the first time through . |
18,765 | private int getSize ( final String fieldType , final Object fieldValue ) { Integer fieldSize = SIMPLE_SIZES . get ( fieldType ) ; if ( fieldSize != null ) { if ( PRIMITIVE_TYPES . contains ( fieldType ) ) { return fieldSize ; } return OBJREF_SIZE + fieldSize ; } else if ( fieldValue instanceof String ) { return ( OBJREF_SIZE + OBJECT_SHELL_SIZE ) * 2 + INT_FIELD_SIZE * 3 + ( ( String ) fieldValue ) . length ( ) * CHAR_FIELD_SIZE ; } else if ( fieldValue != null ) { return OBJECT_SHELL_SIZE + OBJREF_SIZE ; } else { return OBJREF_SIZE ; } } | Calculates the size of a field value obtained using the reflection API . |
18,766 | private void toFlatSummary ( final String indent , final StringBuffer buffer ) { buffer . append ( indent ) ; ObjectGraphNode root = ( ObjectGraphNode ) getRoot ( ) ; double pct = 100.0 * getSize ( ) / root . getSize ( ) ; buffer . append ( getSize ( ) ) . append ( " (" ) ; buffer . append ( new DecimalFormat ( "0.0" ) . format ( pct ) ) ; buffer . append ( "%) - " ) . append ( getFieldName ( ) ) . append ( " - " ) ; if ( getRefNode ( ) != null ) { buffer . append ( "ref (" ) . append ( getRefNode ( ) . getValue ( ) . getClass ( ) . getName ( ) ) . append ( ')' ) ; } else if ( getValue ( ) == null ) { buffer . append ( "null (" ) . append ( getType ( ) ) . append ( ')' ) ; } else { buffer . append ( getType ( ) ) ; } buffer . append ( '\n' ) ; String newIndent = indent + " " ; for ( int i = 0 ; i < getChildCount ( ) ; i ++ ) { ( ( ObjectGraphNode ) getChildAt ( i ) ) . toFlatSummary ( newIndent , buffer ) ; } } | Generates a flat format summary XML representation of this ObjectGraphNode . |
18,767 | private void toXml ( final String indent , final StringBuffer xml ) { String primitiveString = formatSimpleValue ( ) ; xml . append ( indent ) ; xml . append ( isPrimitive ( ) ? "<primitive" : "<object" ) ; if ( refNode == null ) { xml . append ( " id=\"" ) . append ( id ) . append ( '"' ) ; if ( fieldName != null ) { xml . append ( " field=\"" ) . append ( fieldName ) . append ( '"' ) ; } if ( primitiveString != null ) { primitiveString = WebUtilities . encode ( primitiveString ) ; xml . append ( " value=\"" ) . append ( primitiveString ) . append ( '"' ) ; } if ( type != null ) { xml . append ( " type=\"" ) . append ( type ) . append ( '"' ) ; } xml . append ( " size=\"" ) . append ( getSize ( ) ) . append ( '"' ) ; if ( getChildCount ( ) == 0 ) { xml . append ( "/>\n" ) ; } else { xml . append ( ">\n" ) ; String newIndent = indent + " " ; for ( int i = 0 ; i < getChildCount ( ) ; i ++ ) { ( ( ObjectGraphNode ) getChildAt ( i ) ) . toXml ( newIndent , xml ) ; } xml . append ( indent ) ; xml . append ( isPrimitive ( ) ? "</primitive>\n" : "</object>\n" ) ; } } else { if ( fieldName != null ) { xml . append ( " field=\"" ) . append ( fieldName ) . append ( '"' ) ; } xml . append ( " refId=\"" ) . append ( refNode . id ) . append ( '"' ) ; if ( refNode . value == null ) { xml . append ( " type=\"" ) . append ( refNode . type ) . append ( '"' ) ; } else { xml . append ( " type=\"" ) . append ( refNode . value . getClass ( ) . getName ( ) ) . append ( '"' ) ; } xml . append ( " size=\"" ) . append ( OBJREF_SIZE ) . append ( '"' ) ; xml . append ( "/>\n" ) ; } } | Emits an XML representation of this ObjectGraphNode . |
18,768 | private void addClientOnlyExamples ( ) { add ( new WHeading ( HeadingLevel . H2 , "Client command buttons" ) ) ; add ( new ExplanatoryText ( "These examples show buttons which do not submit the form" ) ) ; WButton nothingButton = new WButton ( "Do nothing" ) ; add ( nothingButton ) ; nothingButton . setClientCommandOnly ( true ) ; nothingButton = new WButton ( "Do nothing link" ) ; add ( nothingButton ) ; nothingButton . setRenderAsLink ( true ) ; nothingButton . setClientCommandOnly ( true ) ; HelloButton helloButton = new HelloButton ( "Hello" ) ; add ( helloButton ) ; helloButton = new HelloButton ( "Hello link" ) ; helloButton . setRenderAsLink ( true ) ; add ( helloButton ) ; } | Examples showing use of client only buttons . |
18,769 | private void addDefaultSubmitButtonExample ( ) { add ( new WHeading ( HeadingLevel . H3 , "Default submit button" ) ) ; add ( new ExplanatoryText ( "This example shows how to use an image as the only content of a WButton. " + "In addition this text field submits the entire screen using the image button to the right of the field." ) ) ; WFieldLayout imageButtonFieldLayout = new WFieldLayout ( ) ; imageButtonFieldLayout . setLabelWidth ( 25 ) ; add ( imageButtonFieldLayout ) ; WTextField textFld = new WTextField ( ) ; WButton button = new WButton ( "Flag this record for follow-up" ) ; button . setImage ( "/image/flag.png" ) ; button . getImageHolder ( ) . setCacheKey ( "eg-button-flag" ) ; button . setActionObject ( button ) ; button . setAction ( new ExampleButtonAction ( ) ) ; textFld . setDefaultSubmitButton ( button ) ; WContainer imageButtonFieldContainer = new WContainer ( ) ; imageButtonFieldContainer . add ( textFld ) ; imageButtonFieldContainer . add ( new WText ( "\u2002" ) ) ; imageButtonFieldContainer . add ( button ) ; imageButtonFieldLayout . addField ( "Enter record ID" , imageButtonFieldContainer ) ; } | Examples showing how to set a WButton as the default submit button for an input control . |
18,770 | private void addDisabledExamples ( ) { add ( new WHeading ( HeadingLevel . H2 , "Examples of disabled buttons" ) ) ; WPanel disabledButtonLayoutPanel = new WPanel ( WPanel . Type . BOX ) ; disabledButtonLayoutPanel . setLayout ( new FlowLayout ( FlowLayout . LEFT , 6 , 0 , FlowLayout . ContentAlignment . BASELINE ) ) ; add ( disabledButtonLayoutPanel ) ; WButton button = new WButton ( "Disabled button" ) ; button . setDisabled ( true ) ; disabledButtonLayoutPanel . add ( button ) ; button = new WButton ( "Disabled button as link" ) ; button . setDisabled ( true ) ; button . setRenderAsLink ( true ) ; disabledButtonLayoutPanel . add ( button ) ; add ( new WHeading ( HeadingLevel . H3 , "Examples of disabled buttons displaying only an image" ) ) ; disabledButtonLayoutPanel = new WPanel ( WPanel . Type . BOX ) ; disabledButtonLayoutPanel . setLayout ( new FlowLayout ( FlowLayout . LEFT , 6 , 0 , FlowLayout . ContentAlignment . BASELINE ) ) ; add ( disabledButtonLayoutPanel ) ; button = new WButton ( "Disabled button" ) ; button . setDisabled ( true ) ; button . setImage ( "/image/tick.png" ) ; button . setToolTip ( "Checking currently disabled" ) ; disabledButtonLayoutPanel . add ( button ) ; button = new WButton ( "Disabled button as link" ) ; button . setDisabled ( true ) ; button . setRenderAsLink ( true ) ; button . setImage ( "/image/tick.png" ) ; button . setToolTip ( "Checking currently disabled" ) ; disabledButtonLayoutPanel . add ( button ) ; add ( new WHeading ( HeadingLevel . H3 , "Examples of disabled buttons displaying an image with imagePosition EAST" ) ) ; disabledButtonLayoutPanel = new WPanel ( WPanel . Type . BOX ) ; disabledButtonLayoutPanel . setLayout ( new FlowLayout ( FlowLayout . LEFT , 6 , 0 , FlowLayout . ContentAlignment . BASELINE ) ) ; add ( disabledButtonLayoutPanel ) ; button = new WButton ( "Disabled button" ) ; button . setDisabled ( true ) ; button . setImage ( "/image/tick.png" ) ; button . setToolTip ( "Checking currently disabled" ) ; button . setImagePosition ( ImagePosition . EAST ) ; disabledButtonLayoutPanel . add ( button ) ; button = new WButton ( "Disabled button as link" ) ; button . setDisabled ( true ) ; button . setRenderAsLink ( true ) ; button . setImage ( "/image/tick.png" ) ; button . setToolTip ( "Checking currently disabled" ) ; button . setImagePosition ( ImagePosition . EAST ) ; disabledButtonLayoutPanel . add ( button ) ; } | Examples of disabled buttons in various guises . |
18,771 | private void addAntiPatternExamples ( ) { add ( new WHeading ( HeadingLevel . H2 , "WButton 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 , "WButton without a good label" ) ) ; add ( new WButton ( "\u2002" ) ) ; add ( new ExplanatoryText ( "A button without a text label is very bad" ) ) ; add ( new WHeading ( HeadingLevel . H3 , "WButton with a WImage but without a good label" ) ) ; WButton button = new WButton ( "" ) ; button . setImage ( "/image/help.png" ) ; add ( button ) ; add ( new ExplanatoryText ( "A button without a text label is very bad, even if you think the image is sufficient. The text label becomes the image alt text." ) ) ; } | Examples of what not to do when using WButton . |
18,772 | public void handleRequest ( final Request request ) { if ( plainBtn . isPressed ( ) ) { WMessages . getInstance ( this ) . info ( "Plain button pressed." ) ; } if ( linkBtn . isPressed ( ) ) { WMessages . getInstance ( this ) . info ( "Link button pressed." ) ; } } | Override handleRequest in order to perform processing specific to this example . Normally you would attach actions to a button rather than calling isPressed on each button . |
18,773 | public static boolean containsOption ( final List < ? > options , final Object findOption ) { if ( options != null ) { for ( Object option : options ) { if ( option instanceof OptionGroup ) { List < ? > groupOptions = ( ( OptionGroup ) option ) . getOptions ( ) ; if ( groupOptions != null ) { for ( Object nestedOption : groupOptions ) { if ( Util . equals ( nestedOption , findOption ) ) { return true ; } } } } else if ( Util . equals ( option , findOption ) ) { return true ; } } } return false ; } | Iterate through the options to determine if an option exists . |
18,774 | public static Object getFirstOption ( final List < ? > options ) { if ( options != null ) { for ( Object option : options ) { if ( option instanceof OptionGroup ) { List < ? > groupOptions = ( ( OptionGroup ) option ) . getOptions ( ) ; if ( groupOptions != null && ! groupOptions . isEmpty ( ) ) { return groupOptions . get ( 0 ) ; } } else { return option ; } } } return null ; } | Retrieve the first option . The first option maybe within an option group . |
18,775 | private static boolean isLegacyMatch ( final Object option , final Object data ) { String optionAsString = String . valueOf ( option ) ; String matchAsString = String . valueOf ( data ) ; boolean equal = Util . equals ( optionAsString , matchAsString ) ; return equal ; } | Check for legacy matching which supported setSelected using String representations . |
18,776 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WTemplate template = ( WTemplate ) component ; Map < String , Object > context = new HashMap < > ( ) ; context . put ( "wc" , template ) ; context . putAll ( template . getParameters ( ) ) ; String engine = template . getEngineName ( ) ; if ( Util . empty ( engine ) ) { engine = ConfigurationProperties . getDefaultRenderingEngine ( ) ; } TemplateRenderer templateRenderer = TemplateRendererFactory . newInstance ( engine ) ; if ( ! Util . empty ( template . getTemplateName ( ) ) ) { templateRenderer . renderTemplate ( template . getTemplateName ( ) , context , template . getTaggedComponents ( ) , renderContext . getWriter ( ) , template . getEngineOptions ( ) ) ; } else if ( ! Util . empty ( template . getInlineTemplate ( ) ) ) { templateRenderer . renderInline ( template . getInlineTemplate ( ) , context , template . getTaggedComponents ( ) , renderContext . getWriter ( ) , template . getEngineOptions ( ) ) ; } } | Paints the given WTemplate . |
18,777 | public void updateComponent ( final Object data ) { MyData myData = ( MyData ) data ; name . setText ( "<B>" + myData . getName ( ) + "</B>" ) ; count . setText ( String . valueOf ( myData . getCount ( ) ) ) ; } | Copies data from the Model into the View . |
18,778 | public void paint ( final RenderContext renderContext ) { if ( ! doTransform ) { super . paint ( renderContext ) ; return ; } if ( ! ( renderContext instanceof WebXmlRenderContext ) ) { LOG . warn ( "Unable to transform a " + renderContext ) ; super . paint ( renderContext ) ; return ; } LOG . debug ( "Transform XML Interceptor: Start" ) ; UIContext uic = UIContextHolder . getCurrent ( ) ; StringWriter xmlBuffer = new StringWriter ( ) ; PrintWriter xmlWriter = new PrintWriter ( xmlBuffer ) ; WebXmlRenderContext xmlContext = new WebXmlRenderContext ( xmlWriter , uic . getLocale ( ) ) ; super . paint ( xmlContext ) ; WebXmlRenderContext webRenderContext = ( WebXmlRenderContext ) renderContext ; PrintWriter writer = webRenderContext . getWriter ( ) ; Response response = getResponse ( ) ; response . setContentType ( WebUtilities . CONTENT_TYPE_HTML ) ; String xml = xmlBuffer . toString ( ) ; if ( isAllowCorruptCharacters ( ) && ! Util . empty ( xml ) ) { xml = removeCorruptCharacters ( xml ) ; } xml = WebUtilities . doubleEncodeBrackets ( xml ) ; StringWriter tempBuffer = new StringWriter ( ) ; PrintWriter tempWriter = new PrintWriter ( tempBuffer ) ; transform ( xml , uic , tempWriter ) ; String tempResp = tempBuffer . toString ( ) ; tempResp = WebUtilities . doubleDecodeBrackets ( tempResp ) ; writer . write ( tempResp ) ; LOG . debug ( "Transform XML Interceptor: Finished" ) ; } | Override paint to perform XML to HTML transformation . |
18,779 | private void transform ( final String xml , final UIContext uic , final PrintWriter writer ) { Transformer transformer = newTransformer ( ) ; Source inputXml ; try { inputXml = new StreamSource ( new ByteArrayInputStream ( xml . getBytes ( "utf-8" ) ) ) ; StreamResult result = new StreamResult ( writer ) ; if ( debugRequested ) { transformer . setParameter ( "isDebug" , 1 ) ; } transformer . transform ( inputXml , result ) ; } catch ( UnsupportedEncodingException | TransformerException ex ) { throw new SystemException ( "Could not transform xml" , ex ) ; } } | Transform the UI XML to HTML using the correct XSLT from the classpath . |
18,780 | private static Templates initTemplates ( ) { try { URL xsltURL = ThemeUtil . class . getResource ( RESOURCE_NAME ) ; if ( xsltURL != null ) { Source xsltSource = new StreamSource ( xsltURL . openStream ( ) , xsltURL . toExternalForm ( ) ) ; TransformerFactory factory = new net . sf . saxon . TransformerFactoryImpl ( ) ; Templates templates = factory . newTemplates ( xsltSource ) ; LOG . debug ( "Generated XSLT templates for: " + RESOURCE_NAME ) ; return templates ; } else { throw new IllegalStateException ( RESOURCE_NAME + " not on classpath" ) ; } } catch ( IOException | TransformerConfigurationException ex ) { throw new SystemException ( "Could not create transformer for " + RESOURCE_NAME , ex ) ; } } | Statically initialize the XSLT templates that are cached for all future transforms . |
18,781 | private static String removeCorruptCharacters ( final String input ) { if ( Util . empty ( input ) ) { return input ; } return ESCAPE_BAD_XML10 . translate ( input ) ; } | Remove bad characters in XML . |
18,782 | public int create ( Reference object , HookCreate create ) { return getResourceFactory ( ) . getApiResource ( "/hook/" + object . getType ( ) + "/" + object . getId ( ) + "/" ) . entity ( create , MediaType . APPLICATION_JSON ) . post ( HookCreateResponse . class ) . getId ( ) ; } | Create a new hook on the given object . |
18,783 | public List < Hook > get ( Reference object ) { return getResourceFactory ( ) . getApiResource ( "/hook/" + object . getType ( ) + "/" + object . getId ( ) + "/" ) . get ( new GenericType < List < Hook > > ( ) { } ) ; } | Returns the hooks on the object . |
18,784 | public void requestVerification ( int id ) { getResourceFactory ( ) . getApiResource ( "/hook/" + id + "/verify/request" ) . entity ( new Empty ( ) , MediaType . APPLICATION_JSON_TYPE ) . post ( ) ; } | Request the hook to be validated . This will cause the hook to send a request to the URL with the parameter type set to hook . verify and code set to the verification code . The endpoint must then call the validate method with the code to complete the verification . |
18,785 | public void validateVerification ( int id , String code ) { getResourceFactory ( ) . getApiResource ( "/hook/" + id + "/verify/validate" ) . entity ( new HookValidate ( code ) , MediaType . APPLICATION_JSON ) . post ( ) ; } | Validates the hook using the code received from the verify call . On successful validation the hook will become active . |
18,786 | public void handleRequest ( final Request request ) { if ( isDisabled ( ) || isReadOnly ( ) ) { return ; } RadioButtonGroup currentGroup = getGroup ( ) ; if ( ! currentGroup . isPresent ( request ) ) { return ; } if ( request . getParameter ( currentGroup . getId ( ) ) == null ) { return ; } String requestValue = currentGroup . getRequestValue ( request ) ; boolean onRequest = Util . equals ( requestValue , getValue ( ) ) ; if ( onRequest ) { boolean changed = currentGroup . handleButtonOnRequest ( request ) ; if ( changed && ( UIContextHolder . getCurrent ( ) != null ) && ( UIContextHolder . getCurrent ( ) . getFocussed ( ) == null ) && currentGroup . isCurrentAjaxTrigger ( ) ) { setFocussed ( ) ; } } } | This method will only process the request if the value for the group matches the button s value . |
18,787 | public void setSelected ( final boolean selected ) { if ( selected ) { if ( isDisabled ( ) ) { throw new IllegalStateException ( "Cannot select a disabled radio button" ) ; } getGroup ( ) . setSelectedValue ( getValue ( ) ) ; } else if ( isSelected ( ) ) { getGroup ( ) . setData ( null ) ; } } | Sets whether the radio button is selected . |
18,788 | public ApplicationResource addJsUrl ( final String url ) { if ( Util . empty ( url ) ) { throw new IllegalArgumentException ( "A URL must be provided." ) ; } ApplicationResource res = new ApplicationResource ( url ) ; addJsResource ( res ) ; return res ; } | Add custom javaScript located at the specified URL to be used by the Application . |
18,789 | public ApplicationResource addJsFile ( final String fileName ) { if ( Util . empty ( fileName ) ) { throw new IllegalArgumentException ( "A file name must be provided." ) ; } InternalResource resource = new InternalResource ( fileName , fileName ) ; ApplicationResource res = new ApplicationResource ( resource ) ; addJsResource ( res ) ; return res ; } | Add custom JavaScript held as an internal resource to be used by the application . |
18,790 | public void addJsResource ( final ApplicationResource resource ) { WApplicationModel model = getOrCreateComponentModel ( ) ; if ( model . jsResources == null ) { model . jsResources = new ArrayList < > ( ) ; } else if ( model . jsResources . contains ( resource ) ) { return ; } model . jsResources . add ( resource ) ; MemoryUtil . checkSize ( model . jsResources . size ( ) , this . getClass ( ) . getSimpleName ( ) ) ; } | Add a custom javaScript resource that is to be loaded and used by the application . |
18,791 | public void removeJsResource ( final ApplicationResource resource ) { WApplicationModel model = getOrCreateComponentModel ( ) ; if ( model . jsResources != null ) { model . jsResources . remove ( resource ) ; } } | Remove a custom JavaScript resource . |
18,792 | public ApplicationResource addCssUrl ( final String url ) { if ( Util . empty ( url ) ) { throw new IllegalArgumentException ( "A URL must be provided." ) ; } ApplicationResource res = new ApplicationResource ( url ) ; addCssResource ( res ) ; return res ; } | Add custom CSS located at the specified URL to be used by the Application . |
18,793 | public ApplicationResource addCssFile ( final String fileName ) { if ( Util . empty ( fileName ) ) { throw new IllegalArgumentException ( "A file name must be provided." ) ; } InternalResource resource = new InternalResource ( fileName , fileName ) ; ApplicationResource res = new ApplicationResource ( resource ) ; addCssResource ( res ) ; return res ; } | Add custom CSS held as an internal resource to be used by the Application . |
18,794 | public void addCssResource ( final ApplicationResource resource ) { WApplicationModel model = getOrCreateComponentModel ( ) ; if ( model . cssResources == null ) { model . cssResources = new ArrayList < > ( ) ; } else if ( model . cssResources . contains ( resource ) ) { return ; } model . cssResources . add ( resource ) ; MemoryUtil . checkSize ( model . cssResources . size ( ) , this . getClass ( ) . getSimpleName ( ) ) ; } | Add a custom CSS resource that will be loaded and used by this application . |
18,795 | public void removeCssResource ( final ApplicationResource resource ) { WApplicationModel model = getOrCreateComponentModel ( ) ; if ( model . cssResources != null ) { model . cssResources . remove ( resource ) ; } } | Remove a custom CSS resource . |
18,796 | protected void validateComponent ( final List < Diagnostic > diags ) { if ( isMandatory ( ) && isEmpty ( ) ) { diags . add ( createMandatoryDiagnostic ( ) ) ; } List < FieldValidator > validators = getComponentModel ( ) . validators ; if ( validators != null ) { for ( FieldValidator validator : validators ) { validator . validate ( diags ) ; } } } | Override WComponent s validatorComponent in order to use the validators which have been added to this input field . Subclasses may still override this method but it is suggested to call super . validateComponent to ensure that the validators are still used . |
18,797 | protected void setChangedInLastRequest ( final boolean changed ) { if ( isChangedInLastRequest ( ) != changed ) { InputModel model = getOrCreateComponentModel ( ) ; model . changedInLastRequest = changed ; } } | Set the changed flag to indicate if the component changed in the last request . |
18,798 | public void doRender ( final WComponent component , final WebXmlRenderContext renderContext ) { WHiddenComment hiddenComponent = ( WHiddenComment ) component ; XmlStringBuilder xml = renderContext . getWriter ( ) ; String hiddenText = hiddenComponent . getText ( ) ; if ( ! Util . empty ( hiddenText ) ) { xml . appendTag ( "ui:comment" ) ; xml . appendEscaped ( hiddenText ) ; xml . appendEndTag ( "ui:comment" ) ; } } | Paints the given WHiddenComment . |
18,799 | public void setComparator ( final int col , final Comparator comparator ) { synchronized ( this ) { if ( comparators == null ) { comparators = new HashMap < > ( ) ; } } if ( comparator == null ) { comparators . remove ( col ) ; } else { comparators . put ( col , comparator ) ; } } | Sets the comparator for the given column to enable sorting . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.