Package org.primefaces.component.poll

Source Code of org.primefaces.component.poll.Poll

/*
* 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.component.poll;

import javax.faces.component.UICommand;
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.resource.ResourceHolder;
import org.primefaces.renderkit.PartialRenderer;

public class Poll extends UICommand {


  public static final String COMPONENT_TYPE = "org.primefaces.component.Poll";
  public static final String COMPONENT_FAMILY = "org.primefaces.component";
  private static final String DEFAULT_RENDERER = "org.primefaces.component.PollRenderer";

  private java.lang.String _widgetVar;
  private java.lang.Integer _interval;
  private java.lang.String _update;
  private java.lang.Boolean _partialSubmit;
  private java.lang.String _onstart;
  private java.lang.String _oncomplete;

  public Poll() {
    setRendererType(DEFAULT_RENDERER);
    ResourceHolder resourceHolder = getResourceHolder();
    if(resourceHolder != null) {
      resourceHolder.addResource("/jquery/jquery.js");
      resourceHolder.addResource("/primefaces/ajax/ajax.js");
      resourceHolder.addResource("/primefaces/poll/poll.js");
    }
  }

  public String getFamily() {
    return COMPONENT_FAMILY;
  }

  public java.lang.String getWidgetVar() {
    if(_widgetVar != null )
      return _widgetVar;

    ValueExpression ve = getValueExpression("widgetVar");
    return ve != null ? (java.lang.String) ve.getValue(getFacesContext().getELContext())  : null;
  }
  public void setWidgetVar(java.lang.String _widgetVar) {
    this._widgetVar = _widgetVar;
  }

  public int getInterval() {
    if(_interval != null )
      return _interval;

    ValueExpression ve = getValueExpression("interval");
    return ve != null ? (java.lang.Integer) ve.getValue(getFacesContext().getELContext())  : 2;
  }
  public void setInterval(int _interval) {
    this._interval = _interval;
  }

  public java.lang.String getUpdate() {
    if(_update != null )
      return _update;

    ValueExpression ve = getValueExpression("update");
    return ve != null ? (java.lang.String) ve.getValue(getFacesContext().getELContext())  : null;
  }
  public void setUpdate(java.lang.String _update) {
    this._update = _update;
  }

  public boolean isPartialSubmit() {
    if(_partialSubmit != null )
      return _partialSubmit;

    ValueExpression ve = getValueExpression("partialSubmit");
    return ve != null ? (java.lang.Boolean) ve.getValue(getFacesContext().getELContext())  : false;
  }
  public void setPartialSubmit(boolean _partialSubmit) {
    this._partialSubmit = _partialSubmit;
  }

  public java.lang.String getOnstart() {
    if(_onstart != null )
      return _onstart;

    ValueExpression ve = getValueExpression("onstart");
    return ve != null ? (java.lang.String) ve.getValue(getFacesContext().getELContext())  : null;
  }
  public void setOnstart(java.lang.String _onstart) {
    this._onstart = _onstart;
  }

  public java.lang.String getOncomplete() {
    if(_oncomplete != null )
      return _oncomplete;

    ValueExpression ve = getValueExpression("oncomplete");
    return ve != null ? (java.lang.String) ve.getValue(getFacesContext().getELContext())  : null;
  }
  public void setOncomplete(java.lang.String _oncomplete) {
    this._oncomplete = _oncomplete;
  }

  public Object saveState(FacesContext context) {
    Object values[] = new Object[7];
    values[0] = super.saveState(context);
    values[1] = _widgetVar;
    values[2] = _interval;
    values[3] = _update;
    values[4] = _partialSubmit;
    values[5] = _onstart;
    values[6] = _oncomplete;
    return ((Object) values);
  }
  public void restoreState(FacesContext context, Object state) {
    Object values[] = (Object[]) state;
    super.restoreState(context, values[0]);
    _widgetVar = (String) values[1];
    _interval = (Integer) values[2];
    _update = (String) values[3];
    _partialSubmit = (Boolean) values[4];
    _onstart = (String) values[5];
    _oncomplete = (String) values[6];
  }

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

  protected ResourceHolder getResourceHolder() {
    FacesContext facesContext = getFacesContext();
    if(facesContext == null)
      return null;

    ValueExpression ve = facesContext.getApplication().getExpressionFactory().createValueExpression(facesContext.getELContext(), "#{primeFacesResourceHolder}", ResourceHolder.class);

    return (ResourceHolder) ve.getValue(facesContext.getELContext());
  }
}
TOP

Related Classes of org.primefaces.component.poll.Poll

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.