Package com.adaptrex.core.ext.jsf

Source Code of com.adaptrex.core.ext.jsf.BootstrapComponent

/*
* Copyright 2012 Adaptrex, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.adaptrex.core.ext.jsf;

import com.adaptrex.core.Adaptrex;
import com.adaptrex.core.config.AdaptrexConfig;
import java.io.IOException;
import java.util.Map;
import javax.faces.component.FacesComponent;
import javax.faces.context.FacesContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@FacesComponent("ext.data.Bootstrap")
public class BootstrapComponent extends ExtComponentBase {

  private static Logger log = LoggerFactory.getLogger(BootstrapComponent.class);
 
  @Override
  public String getFamily() {
    return "ext.data.Bootstrap";
  }

  @Override
    public void encodeBegin(FacesContext context) throws IOException {
      try {
      Adaptrex adaptrex = Adaptrex.getAdaptrex();
     
      AdaptrexConfig config = adaptrex.getConfig();
          Map<String,Object> tagAttr = getAttributes();
     
          /*
           * Read ext build configuration
           */
      String extBuild = (String) tagAttr.get(AdaptrexConfig.EXT_BUILD);
      if (extBuild == null) extBuild = config.get(AdaptrexConfig.EXT_BUILD, "production");     
     
      write("<script type='text/javascript' src='app" + (extBuild.equals("production") ? "-all" : "") + ".js'></script>");
     
      } catch (Exception e) {
        log.warn("Error", e);
      }
    }
}
TOP

Related Classes of com.adaptrex.core.ext.jsf.BootstrapComponent

TOP
Copyright © 2018 www.massapi.com. 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.