idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
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 . r...
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 = pr...
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 deco...
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 . getCo...
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 ) { lastNameFilterMe...
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 ( clearAl...
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 filter...
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 . appen...
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 ...
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 extra...
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 . app...
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...
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_...
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 , cbRe...
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...
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 . i...
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" , compo...
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 ( deleg...
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:radiobut...
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 . ...
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 = ...
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 . render...
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_...
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 { templateRender...
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 ( render...
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 ...
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 ....
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 ) ...
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 servic...
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 ...
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 = AbstractWComponen...
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 ) { ...
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 ...
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 ( OBJRE...
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" )...
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 ) { ...
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 . setClientCommandOnl...
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 ...
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 ) ) ;...
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 WHeadin...
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 ...
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 ....
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 . getEng...
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 In...
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 ( debugRe...
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 ( ) ...
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 = curre...
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 ) ; addJs...
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 ) ; ...
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 ) ; addC...
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...
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...
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 . appendTa...
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 .