Package org.primefaces.touch.component.rowgroup

Source Code of org.primefaces.touch.component.rowgroup.RowGroup

/*
* Copyright 2009 Prime Technology.
*
* 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 org.primefaces.touch.component.rowgroup;

import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.el.ValueExpression;
import javax.el.MethodExpression;
import javax.faces.render.Renderer;
import java.io.IOException;
import org.primefaces.renderkit.PartialRenderer;
import org.primefaces.component.resource.Resource;
import javax.faces.component.UIComponent;
import javax.faces.event.ListenerFor;
import javax.faces.event.PostAddToViewEvent;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.event.AbortProcessingException;
import java.util.List;
import java.util.ArrayList;

@ListenerFor(systemEventClass = PostAddToViewEvent.class)
public class RowGroup extends UIComponentBase {


  public static final String COMPONENT_TYPE = "org.primefaces.touch.RowGroup";
  public static final String COMPONENT_FAMILY = "org.primefaces.touch";
  private static final String DEFAULT_RENDERER = "org.primefaces.touch.component.RowGroupRenderer";
  private static final String OPTIMIZED_PACKAGE = "org.primefaces.component.";

  protected enum PropertyKeys {

    title
    ,display;

    String toString;

    PropertyKeys(String toString) {
      this.toString = toString;
    }

    PropertyKeys() {}

    public String toString() {
      return ((this.toString != null) ? this.toString : super.toString());
}
  }

  public RowGroup() {
    setRendererType(DEFAULT_RENDERER);
  }

  public String getFamily() {
    return COMPONENT_FAMILY;
  }

  public java.lang.String getTitle() {
    return (java.lang.String) getStateHelper().eval(PropertyKeys.title, null);
  }
  public void setTitle(java.lang.String _title) {
    getStateHelper().put(PropertyKeys.title, _title);
    handleAttribute("title", _title);
  }

  public java.lang.String getDisplay() {
    return (java.lang.String) getStateHelper().eval(PropertyKeys.display, "rounded");
  }
  public void setDisplay(java.lang.String _display) {
    getStateHelper().put(PropertyKeys.display, _display);
    handleAttribute("display", _display);
  }


  protected FacesContext getFacesContext() {
    return FacesContext.getCurrentInstance();
  }

  public boolean resourceExists(FacesContext facesContext, String name) {
    java.util.List<UIComponent> resources = facesContext.getViewRoot().getComponentResources(facesContext, "head");
    for(UIComponent component : resources) {
      String value = component.toString();
      if(value != null && value.equals(name))
        return true;
    }
    return false;
  }

  public void handleAttribute(String name, Object value) {
    List<String> setAttributes = (List<String>) this.getAttributes().get("javax.faces.component.UIComponentBase.attributesThatAreSet");
    if(setAttributes == null) {
      String cname = this.getClass().getName();
      if(cname != null && cname.startsWith(OPTIMIZED_PACKAGE)) {
        setAttributes = new ArrayList<String>(6);
        this.getAttributes().put("javax.faces.component.UIComponentBase.attributesThatAreSet", setAttributes);
      }
    }
    if(setAttributes != null) {
      if(value == null) {
        ValueExpression ve = getValueExpression(name);
        if(ve == null) {
          setAttributes.remove(name);
        } else if(!setAttributes.contains(name)) {
          setAttributes.add(name);
        }
      }
    }
  }
}
TOP

Related Classes of org.primefaces.touch.component.rowgroup.RowGroup

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.