Package org.primefaces.config

Examples of org.primefaces.config.ConfigContainer


            if (event instanceof PostAddToViewEvent) {
                PostAddToViewEvent postAddToViewEvent = (PostAddToViewEvent) event;

                FacesContext context = FacesContext.getCurrentInstance();
                RequestContext requestContext = RequestContext.getCurrentInstance();
                ConfigContainer config = requestContext.getApplicationContext().getConfig();

                if (config.isTransformMetadataEnabled() && config.isBeanValidationAvailable()) {
                    BV_INPUT_METADATA_TRANSFORMER.transform(context, requestContext, postAddToViewEvent.getComponent());
                }

                if (METADATA_TRANSFORMERS.size() > 0) {
                    for (int i = 0; i < METADATA_TRANSFORMERS.size(); i++) {
View Full Code Here


        }

        FileUpload fileUpload = (FileUpload) component;

        if(!fileUpload.isDisabled()) {
            ConfigContainer cc = RequestContext.getCurrentInstance().getApplicationContext().getConfig();
            String uploader = cc.getUploader();
            boolean isAtLeastJSF22 = cc.isAtLeastJSF22();

            if(uploader.equals("auto")) {
                if(isAtLeastJSF22)
                    NativeFileUploadDecoder.decode(context, fileUpload);
                else
View Full Code Here

        return true;
    }

    public void processEvent(SystemEvent event) throws AbortProcessingException {
      // temp manually instantiate startup config as the default config is not available yet
      ConfigContainer config = new StartupConfigContainer(FacesContext.getCurrentInstance());
     
        logger.log(Level.INFO,
            "Running on PrimeFaces {0}",
            config.getBuildVersion());
    }
View Full Code Here

       
        return this;
    }

    public AjaxRequestBuilder partialSubmit(boolean value, boolean partialSubmitSet, String partialSubmitFilter) {
        ConfigContainer config = RequestContext.getCurrentInstance().getApplicationContext().getConfig();
     
      //component can override global setting
        boolean partialSubmit = partialSubmitSet ? value : config.isPartialSubmitEnabled();
       
        if(partialSubmit) {
            buffer.append(",ps:true");
           
            if(partialSubmitFilter != null) {
View Full Code Here

       
        return this;
    }
   
    public AjaxRequestBuilder resetValues(boolean value, boolean resetValuesSet) {
        ConfigContainer config = RequestContext.getCurrentInstance().getApplicationContext().getConfig();
     
      //component can override global setting
        boolean resetValues = resetValuesSet ? value : config.isResetValuesEnabled();
       
        if(resetValues) {
            buffer.append(",rv:true");
        }
       
View Full Code Here

        if(component instanceof ValueHolder) {

            if(component instanceof EditableValueHolder) {
                EditableValueHolder input = (EditableValueHolder) component;
                Object submittedValue = input.getSubmittedValue();
                ConfigContainer config = RequestContext.getCurrentInstance().getApplicationContext().getConfig();

                if(config.isInterpretEmptyStringAsNull() && submittedValue == null && context.isValidationFailed() && !input.isValid()) {
                    return null;
                }
                else if(submittedValue != null) {
                    return submittedValue.toString();
                }
View Full Code Here

public class HeadRenderer extends Renderer {

    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        ConfigContainer cc = RequestContext.getCurrentInstance().getApplicationContext().getConfig();
        ProjectStage projectStage = context.getApplication().getProjectStage();
       
        if (cc.isClientSideValidationEnabled()) {
            ResourceUtils.addComponentResource(context, "validation/validation.js");
            if (cc.isBeanValidationAvailable()) {
                ResourceUtils.addComponentResource(context, "validation/beanvalidation.js");
            }
        }
       
        writer.startElement("head", component);
       
        //First facet
        UIComponent first = component.getFacet("first");
        if (first != null) {
            first.encodeAll(context);
        }
       
        //Theme
        String theme;
        String themeParamValue = RequestContext.getCurrentInstance().getApplicationContext().getConfig().getTheme();

        if (themeParamValue != null) {
            ELContext elContext = context.getELContext();
            ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
            ValueExpression ve = expressionFactory.createValueExpression(elContext, themeParamValue, String.class);

            theme = (String) ve.getValue(elContext);
        }
        else {
            theme = "aristo";   //default
        }

        if (theme != null && !theme.equals("none")) {
            encodeCSS(context, "primefaces-" + theme, "theme.css");
        }
       
        if (cc.isFontAwesomeEnabled()) {
            encodeCSS(context, "primefaces", "fa/font-awesome.css");
        }
       
        //Middle facet
        UIComponent middle = component.getFacet("middle");
        if (middle != null) {
            middle.encodeAll(context);
        }
               
        //Registered Resources
        UIViewRoot viewRoot = context.getViewRoot();
        for (UIComponent resource : viewRoot.getComponentResources(context, "head")) {
            resource.encodeAll(context);
        }

        writer.startElement("script", null);
        writer.writeAttribute("type", "text/javascript", null);
        writer.write("if(window.PrimeFaces){");

        if (cc.isClientSideValidationEnabled()) {
            writer.write("PrimeFaces.settings.locale='" + context.getViewRoot().getLocale() + "';");
            writer.write("PrimeFaces.settings.validateEmptyFields=" + cc.isValidateEmptyFields() + ";");
            writer.write("PrimeFaces.settings.considerEmptyStringNull=" + cc.isInterpretEmptyStringAsNull() + ";");
        }
       
        if (cc.isLegacyWidgetNamespace()) {
            writer.write("PrimeFaces.settings.legacyWidgetNamespace=true;");
        }
       
        if (cc.isParameterNamespacingEnabled()) {
            writer.write("PrimeFaces.settings.namespaceParameters=true;");
        }
       
        if (!projectStage.equals(ProjectStage.Production)) {
            writer.write("PrimeFaces.settings.projectStage='" + projectStage.toString() + "';");
View Full Code Here

        return this;
    }

    @Deprecated
    public AjaxRequestBuilder partialSubmit(boolean value, boolean partialSubmitSet) {
        ConfigContainer config = RequestContext.getCurrentInstance().getApplicationContext().getConfig();
     
      //component can override global setting
        boolean partialSubmit = partialSubmitSet ? value : config.isPartialSubmitEnabled();
       
        if(partialSubmit) {
            buffer.append(",ps:true");
        }
       
View Full Code Here

  private ConfigContainer config;
  private ValidatorFactory validatorFactory;
    private CacheProvider cacheProvider;

    public DefaultApplicationContext(FacesContext context) {
      this.config = new ConfigContainer(context);
     
      if (this.config.isBeanValidationAvailable()) {
          this.validatorFactory = Validation.buildDefaultValidatorFactory();
      }
    }
View Full Code Here

public class HeadRenderer extends Renderer {
   
    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        ConfigContainer cc = RequestContext.getCurrentInstance().getApplicationContext().getConfig();
        ProjectStage projectStage = context.getApplication().getProjectStage();
        writer.startElement("head", component);
       
        //First facet
        UIComponent first = component.getFacet("first");
        if(first != null) {
            first.encodeAll(context);
        }
               
        writer.write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>");
       
        String theme = resolveTheme(context);
        if(theme == null) {
            renderCSS(context, "mobile/jquery-mobile.css", "primefaces");
        }
        else {           
            renderCSS(context, "theme.css", "primefaces-" + theme);
            renderCSS(context, "mobile/jquery-mobile-icons.css", "primefaces");
            renderCSS(context, "mobile/jquery-mobile-structure.css", "primefaces");
        }
       
        renderCSS(context, "mobile/primefaces-mobile.css", "primefaces");
       
        if(cc.isFontAwesomeEnabled()) {
            renderCSS(context, "fa/font-awesome.css", "primefaces");
        }
       
        renderJS(context, "jquery/jquery.js", "primefaces");
       
        writer.startElement("script", null);
        writer.writeAttribute("type", "text/javascript", null);
        writer.write("$(document).on('mobileinit', function(){");
        writer.write("$.mobile.ajaxEnabled = false;");              
        writer.write("$.mobile.pushStateEnabled = false;");       
        writer.write("$.mobile.page.prototype.options.domCache = true;");
       
        UIComponent init = component.getFacet("init");
        if(init != null) {
            init.encodeAll(context);
        }
       
        writer.write("});");       
        writer.endElement("script");
       
        renderJS(context, "mobile/jquery-mobile.js", "primefaces");
        renderJS(context, "primefaces-mobile.js", "primefaces");
       
        //Registered Resources
        UIViewRoot viewRoot = context.getViewRoot();
        for(UIComponent resource : viewRoot.getComponentResources(context, "head")) {
            boolean shouldRender = true;
            Map<String,Object> attrs = resource.getAttributes();
            String library = (String) attrs.get("library");
           
            if(library != null && library.equals("primefaces")) {
                String resourceName = (String) attrs.get("name");
                if(resourceName.startsWith("jquery")||resourceName.startsWith("primefaces")) {
                    shouldRender = false;
                }
            }
           
            if(shouldRender) {
                resource.encodeAll(context);
            }
        }
       
        if(cc.isLegacyWidgetNamespace()) {
            writer.startElement("script", null);
            writer.writeAttribute("type", "text/javascript", null);
            writer.write("PrimeFaces.settings.legacyWidgetNamespace = true;");
            writer.endElement("script");
        }
View Full Code Here

TOP

Related Classes of org.primefaces.config.ConfigContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.