package com.cfcc.jaf.webx.component.toolbar;
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.webapp.UIComponentTag;
/** *//**
* @author qinjinwei
*
*/
public class UIToolBarTag extends UIComponentTag ...{
private String size;
private String value;
public String getComponentType() ...{
return "com.cfcc.jaf.webx.component.toolbar.UIToolBar";
}
public String getRendererType() ...{
return null;
}
public void setProperties(UIComponent component) ...{
super.setProperties(component);
setStringProperty(component, "value", value);
setStringProperty(component, "size", size);
}
private void setStringProperty(UIComponent component, String attrName,
String attrValue) ...{
if (attrValue == null)
return;
if (isValueReference(attrValue)) ...{
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
ValueBinding binding = application.createValueBinding(attrValue);
component.setValueBinding(attrName, binding);
} else ...{
component.getAttributes().put(attrName, attrValue);
}
}
public void release() ...{
super.release();
value = null;
size = null;
}
public String getValue() ...{
return value;
}
public void setValue(String value) ...{
this.value = value;
}
public String getSize() ...{
return size;
}
public void setSize(String size) ...{
this.size = size;
}
}
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import javax.faces.webapp.UIComponentTag;
/** *//**
* @author qinjinwei
*
*/
public class UIToolBarTag extends UIComponentTag ...{
private String size;
private String value;
public String getComponentType() ...{
return "com.cfcc.jaf.webx.component.toolbar.UIToolBar";
}
public String getRendererType() ...{
return null;
}
public void setProperties(UIComponent component) ...{
super.setProperties(component);
setStringProperty(component, "value", value);
setStringProperty(component, "size", size);
}
private void setStringProperty(UIComponent component, String attrName,
String attrValue) ...{
if (attrValue == null)
return;
if (isValueReference(attrValue)) ...{
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
ValueBinding binding = application.createValueBinding(attrValue);
component.setValueBinding(attrName, binding);
} else ...{
component.getAttributes().put(attrName, attrValue);
}
}
public void release() ...{
super.release();
value = null;
size = null;
}
public String getValue() ...{
return value;
}
public void setValue(String value) ...{
this.value = value;
}
public String getSize() ...{
return size;
}
public void setSize(String size) ...{
this.size = size;
}
}
package com.cfcc.jaf.webx.component.toolbar;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.faces.component.UICommand;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.MethodBinding;
import javax.faces.event.ActionEvent;
import org.apache.myfaces.custom.navmenu.NavigationMenuUtils;
import org.apache.myfaces.renderkit.html.util.AddResource;
import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
import org.apache.myfaces.shared_tomahawk.el.SimpleActionMethodBinding;
import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
import com.cfcc.jaf.webx.faces.ToolBarItem;
/** *//**
* @author qinjinwei
*
*/
public class UIToolBar extends UICommand ...{
public static final String COMPONENT_TYPE = "com.cfcc.jaf.webx.component.toolbar.UIToolBar";
public static final String COMPONENT_FAMILY = "javax.faces.Command";
private static final String ToolBar_Index = "toolbar_index";
private static String size = null;
private static int width = 0;
private static int height = 0;
public UIToolBar() ...{
setRendererType(null);
}
public String getFamily() ...{
return COMPONENT_FAMILY;
}
public void encodeBegin(FacesContext context) throws IOException ...{
AddResource addResource = AddResourceFactory.getInstance(context);
addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN,
"js/toolbar.js");
ResponseWriter writer = context.getResponseWriter();
String clientId = getClientId(context);
FormInfo parentFormInfo = RendererUtils.findNestingForm(this, context);
String name = parentFormInfo.getFormName();
Object obj = getValue();
List list = (List) obj;
size = findSize();
if (size != null && size.indexOf(",") > -1) ...{
String[] ss = size.split(",");
width = Integer.parseInt(ss[0]);
height = Integer.parseInt(ss[1]);
}
if (list != null && list.size() > 0) ...{
writer.write("
" + clientId + "">
");
}
writer.write("");
writer.write(ToolBar_Index);
writer.write("" />");
}
public String findSize() ...{
if (size != null)
return size;
size = (String) this.getAttributes().get("size");
return size;
}
private void writeItem(ResponseWriter writer, ToolBarItem element,
String clientId, int index) throws IOException ...{
writer.write("");
writer.write("onmouseup="jump(" + "'" + clientId + "'," + index
+ ");" ");
writer.write("onmouseover="mover(this);" ");
writer.write("onmouseout="mout(this);" ");
writer.write("
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.faces.component.UICommand;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.MethodBinding;
import javax.faces.event.ActionEvent;
import org.apache.myfaces.custom.navmenu.NavigationMenuUtils;
import org.apache.myfaces.renderkit.html.util.AddResource;
import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
import org.apache.myfaces.shared_tomahawk.el.SimpleActionMethodBinding;
import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
import com.cfcc.jaf.webx.faces.ToolBarItem;
/** *//**
* @author qinjinwei
*
*/
public class UIToolBar extends UICommand ...{
public static final String COMPONENT_TYPE = "com.cfcc.jaf.webx.component.toolbar.UIToolBar";
public static final String COMPONENT_FAMILY = "javax.faces.Command";
private static final String ToolBar_Index = "toolbar_index";
private static String size = null;
private static int width = 0;
private static int height = 0;
public UIToolBar() ...{
setRendererType(null);
}
public String getFamily() ...{
return COMPONENT_FAMILY;
}
public void encodeBegin(FacesContext context) throws IOException ...{
AddResource addResource = AddResourceFactory.getInstance(context);
addResource.addJavaScriptAtPosition(context, AddResource.HEADER_BEGIN,
"js/toolbar.js");
ResponseWriter writer = context.getResponseWriter();
String clientId = getClientId(context);
FormInfo parentFormInfo = RendererUtils.findNestingForm(this, context);
String name = parentFormInfo.getFormName();
Object obj = getValue();
List list = (List) obj;
size = findSize();
if (size != null && size.indexOf(",") > -1) ...{
String[] ss = size.split(",");
width = Integer.parseInt(ss[0]);
height = Integer.parseInt(ss[1]);
}
if (list != null && list.size() > 0) ...{
writer.write("
}
writer.write("");
writer.write(ToolBar_Index);
writer.write("" />");
}
public String findSize() ...{
if (size != null)
return size;
size = (String) this.getAttributes().get("size");
return size;
}
private void writeItem(ResponseWriter writer, ToolBarItem element,
String clientId, int index) throws IOException ...{
writer.write("
writer.write("onmouseup="jump(" + "'" + clientId + "'," + index
+ ");" ");
writer.write("onmouseover="mover(this);" ");
writer.write("onmouseout="mout(this);" ");
writer.write("