/*
* 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.linkbutton;
import javax.faces.component.UIOutput;
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 LinkButton extends UIOutput {
public static final String COMPONENT_TYPE = "org.primefaces.component.LinkButton";
public static final String COMPONENT_FAMILY = "org.primefaces.component";
private static final String DEFAULT_RENDERER = "org.primefaces.component.LinkButtonRenderer";
private java.lang.String _widgetVar;
private java.lang.String _href;
private java.lang.String _target;
private java.lang.String _style;
private java.lang.String _styleClass;
public LinkButton() {
setRendererType(DEFAULT_RENDERER);
ResourceHolder resourceHolder = getResourceHolder();
if(resourceHolder != null) {
resourceHolder.addResource("/yui/button/assets/skins/sam/button.css");
resourceHolder.addResource("/yui/utilities/utilities.js");
resourceHolder.addResource("/yui/button/button-min.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 java.lang.String getHref() {
if(_href != null )
return _href;
ValueExpression ve = getValueExpression("href");
return ve != null ? (java.lang.String) ve.getValue(getFacesContext().getELContext()) : null;
}
public void setHref(java.lang.String _href) {
this._href = _href;
}
public java.lang.String getTarget() {
if(_target != null )
return _target;
ValueExpression ve = getValueExpression("target");
return ve != null ? (java.lang.String) ve.getValue(getFacesContext().getELContext()) : null;
}
public void setTarget(java.lang.String _target) {
this._target = _target;
}
public java.lang.String getStyle() {
if(_style != null )
return _style;
ValueExpression ve = getValueExpression("style");
return ve != null ? (java.lang.String) ve.getValue(getFacesContext().getELContext()) : null;
}
public void setStyle(java.lang.String _style) {
this._style = _style;
}
public java.lang.String getStyleClass() {
if(_styleClass != null )
return _styleClass;
ValueExpression ve = getValueExpression("styleClass");
return ve != null ? (java.lang.String) ve.getValue(getFacesContext().getELContext()) : null;
}
public void setStyleClass(java.lang.String _styleClass) {
this._styleClass = _styleClass;
}
public Object saveState(FacesContext context) {
Object values[] = new Object[6];
values[0] = super.saveState(context);
values[1] = _widgetVar;
values[2] = _href;
values[3] = _target;
values[4] = _style;
values[5] = _styleClass;
return ((Object) values);
}
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
_widgetVar = (String) values[1];
_href = (String) values[2];
_target = (String) values[3];
_style = (String) values[4];
_styleClass = (String) values[5];
}
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());
}
}