本文整理汇总了Java中com.ibm.xsp.util.JavaScriptUtil类的典型用法代码示例。如果您正苦于以下问题:Java JavaScriptUtil类的具体用法?Java JavaScriptUtil怎么用?Java JavaScriptUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JavaScriptUtil类属于com.ibm.xsp.util包,在下文中一共展示了JavaScriptUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderSeparator
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
protected void renderSeparator(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
script.append(varName);
script.append(".addChild(new "); // $NON-NLS-1$
script.append(getSeparatorType());
script.append("({");
boolean hasp = false;
String style = tree.getNode().getStyle();
if(StringUtil.isNotEmpty(style)) {
if(hasp) script.append(","); else hasp=true;
script.append("style:"); // $NON-NLS-1$
JavaScriptUtil.addString(script, style);
}
String styleClass = tree.getNode().getStyleClass();
if(StringUtil.isNotEmpty(styleClass)) {
if(hasp) script.append(","); else hasp=true;
JavaScriptUtil.addString(script, "class"); // $NON-NLS-1$
script.append(":"); // $NON-NLS-1$
JavaScriptUtil.addString(script, styleClass);
}
script.append("}));\n"); // $NON-NLS-1$
}
示例2: encodeBegin
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
@Override
public void encodeBegin(FacesContext context, UIComponent component)
throws IOException {
ResponseWriter w = context.getResponseWriter();
if(!component.isRendered()) {
return;
}
AbstractPager pager = (AbstractPager)component;
FacesDataIterator dataIterator = pager.findDataIterator();
if(dataIterator!=null) {
writeMain(context, w, pager, dataIterator);
}
//>tmg:a11y
String _pagerClientId = (String)HtmlUtil.readEncodeParameter(context, pager, AbstractPager.PAGER_CLIENT_ID, /*remove*/ true);
if(null != _pagerClientId){
StringBuilder js = new StringBuilder();
js.append("XSP.setFocus("); //$NON-NLS-1$
JavaScriptUtil.addString(js, _pagerClientId); // $NON-NLS-1$
js.append(");\n"); //$NON-NLS-1$
JavaScriptUtil.addScriptOnLoad(js.toString());
}
//<tmg:a11y
}
示例3: encodeEnd
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
//>tmg:a11y
super.encodeEnd(context, component);
// the regular expand/collapse actionevent and the column sort action event work in here...
String _toggleActionClientId = (String)HtmlUtil.readEncodeParameter(context, component, UIDataSourceIterator.TOGGLE_ACTION_CLIENT_ID, /*remove*/ true);
if(null != _toggleActionClientId){
// for the expand/collapse action event, flip the client id... expand/collapse vs collapse/expand...
if(_toggleActionClientId.contains(SHRINK_DELIMITER)){
_toggleActionClientId = _toggleActionClientId.replaceAll(SHRINK_DELIMITER, EXPAND_DELIMITER);
}else if(_toggleActionClientId.contains(EXPAND_DELIMITER)){
_toggleActionClientId = _toggleActionClientId.replaceAll(EXPAND_DELIMITER, SHRINK_DELIMITER);
}
StringBuilder js = new StringBuilder();
js.append("XSP.setFocus("); //$NON-NLS-1$
JavaScriptUtil.addString(js, _toggleActionClientId);
js.append(");\n"); //$NON-NLS-1$
JavaScriptUtil.addScriptOnLoad(js.toString());
}
//<tmg:a11y
}
示例4: encodeEnd
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
super.encodeEnd(context, component);
// only working with the actual source row of the action event in here...
if(component instanceof AbstractDataView.RowComponent) {
AbstractDataView c = (AbstractDataView)component.getParent();
String _toggleActionClientId = (String)HtmlUtil.readEncodeParameter(context, c, UIDataSourceIterator.TOGGLE_ACTION_CLIENT_ID, /*remove*/ true);
if(null != _toggleActionClientId){
// flip the event client id... show vs hide... hide vs show...
if(_toggleActionClientId.contains(HIDE_DELIMITER)){
_toggleActionClientId = _toggleActionClientId.replaceAll(HIDE_DELIMITER, SHOW_DELIMITER);
}else if(_toggleActionClientId.contains(SHOW_DELIMITER)){
_toggleActionClientId = _toggleActionClientId.replaceAll(SHOW_DELIMITER, HIDE_DELIMITER);
}
StringBuilder js = new StringBuilder();
js.append("XSP.setFocus("); //$NON-NLS-1$
JavaScriptUtil.addString(js, _toggleActionClientId);
js.append(");\n"); //$NON-NLS-1$
JavaScriptUtil.addScriptOnLoad(js.toString());
}
}
}
示例5: generateAnimation
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
public void generateAnimation(FacesContext context, StringBuilder b, JsonJavaObject o) {
String id = getNodeClientId(context,getNode());
b.append("var _id=dojo.byId("); //$NON-NLS-1$
JavaScriptUtil.addString(b, id);
b.append(");\n"); //$NON-NLS-1$
o.put("node", new JsonReference("_id")); //$NON-NLS-1$ //$NON-NLS-2$
// Add the dynamic attribute
List<Parameter> lp = getAttributes();
if(lp!=null) {
for( Parameter p: lp) {
String name = p.getName();
if(StringUtil.isNotEmpty(name)) {
String value = p.getValue();
o.put(name, new JsonReference(value));
}
}
}
}
示例6: getEventScript
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
/**
* Get the script for a component event.
* @param component
* @param eventName
* @param submitValue
* @return
*/
public static String getEventScript(FacesContext context, XspEventHandler handler, String submitValue) {
// If none, look for an event handler
if(handler!=null) {
if(StringUtil.isNotEmpty(submitValue)) {
StringBuilder b = new StringBuilder();
b.append("XSP.setSubmitValue("); // $NON-NLS-1$
JavaScriptUtil.addString(b, submitValue);
b.append(");"); // $NON-NLS-1$
String s = EventHandlerRenderer.getFireEventFunction(context,handler);
b.append(s);
return b.toString();
} else {
return EventHandlerRenderer.getFireEventFunction(context,handler);
}
}
return null;
}
示例7: writeCollapsedLink
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
protected void writeCollapsedLink(FacesContext context, ResponseWriter w, UINavbar c) throws IOException {
String dataTargetClass = "." + JavaScriptUtil.encodeFunctionName(context, c, "collapse-target"); //$NON-NLS-1$ $NON-NLS-2$
w.startElement("button", c); // $NON-NLS-1$
w.writeAttribute("type", "button", null); // $NON-NLS-1$ $NON-NLS-2$
w.writeAttribute("aria-label", (String)getProperty(PROP_NAVBARCOLLAPSEBUTTON_ARIALABEL), null); // $NON-NLS-1$
w.writeAttribute("class", (String)getProperty(PROP_NAVBARCOLLAPSEBUTTON_CLASS), null); // $NON-NLS-1$
w.writeAttribute("data-toggle", "collapse", null); // $NON-NLS-1$ $NON-NLS-2$
w.writeAttribute("data-target", dataTargetClass, null); // $NON-NLS-1$
w.startElement("span", c); // $NON-NLS-1$
w.writeAttribute("class", "sr-only", null); // $NON-NLS-1$ $NON-NLS-2$
w.writeText((String)getProperty(PROP_NAVBARCOLLAPSEBUTTON_ARIALABEL), null);
w.endElement("span"); // $NON-NLS-1$
w.startElement("span", c); // $NON-NLS-1$
w.writeAttribute("class", "icon-bar", null); // $NON-NLS-1$ $NON-NLS-2$
w.endElement("span"); // $NON-NLS-1$
w.startElement("span", c); // $NON-NLS-1$
w.writeAttribute("class", "icon-bar", null); // $NON-NLS-1$ $NON-NLS-2$
w.endElement("span"); // $NON-NLS-1$
w.startElement("span", c); // $NON-NLS-1$
w.writeAttribute("class", "icon-bar", null); // $NON-NLS-1$ $NON-NLS-2$
w.endElement("span"); // $NON-NLS-1$
w.endElement("button"); // $NON-NLS-1$
}
示例8: writeHeading
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
protected void writeHeading(FacesContext context, ResponseWriter w, UINavbar c, boolean linksExist) throws IOException {
if(linksExist) {
writeCollapsedLink(context, w, c);
}
// start collapse container div
w.startElement("div", c); // $NON-NLS-1$
// SPR #BGLN9ZCMXK Custom collapse class for each navbar needed
//w.writeAttribute("class", "collapse navbar-collapse " + JavaScriptUtil.encodeFunctionName(context, component, "collapse-target"), null); // $NON-NLS-1$ $NON-NLS-2$ //$NON-NLS-3$
String collapseClass = (String)getProperty(PROP_NAVBARCOLLAPSE_CONTAINER);
String collapseTarget = (Boolean)getProperty(PROP_NAVBARCOLLAPSE_TARGET) ? JavaScriptUtil.encodeFunctionName(context, c, "collapse-target") : ""; // $NON-NLS-1$ $NON-NLS-2$
collapseClass = ExtLibUtil.concatStyleClasses(collapseClass, collapseTarget);
if(StringUtil.isNotEmpty(collapseClass)) {
w.writeAttribute("class", collapseClass, null); // $NON-NLS-1$
}
// write navbar brand
writeBrand(context, w, c);
}
示例9: setupSubmitOnClick
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
protected void setupSubmitOnClick( String welcomeBoxID, String sourceId) throws IOException {
String execId = null;
String refreshId = welcomeBoxID;
final String event = "onclick"; // $NON-NLS-1$
StringBuilder buff = new StringBuilder();
JavaScriptUtil.appendAttachPartialRefreshEvent(buff, sourceId, sourceId, execId, event,
/* clientSideScriptName */null,
/* immediate */JavaScriptUtil.VALIDATION_NONE,
/* refreshId */refreshId,
/* onstart getOnStart(pager) */"",
/* oncomplete getOnComplete(pager) */"",
/* onerror getOnError(pager) */"");
String script = buff.toString();
// Add the script block we just generated.
JavaScriptUtil.addScriptOnLoad(script);
}
示例10: postRenderTree
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
@Override
protected void postRenderTree(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
UIScriptCollector collector = UIScriptCollector.find();
script.append("return "); // $NON-NLS-1$
script.append(varName);
script.append(";\n"); // $NON-NLS-1$
script.append("}\n"); // $NON-NLS-1$
collector.addScript(script.toString());
script.setLength(0);
script.append("function "); // $NON-NLS-1$
script.append(menuEventName);
script.append("(thisEvent){"); // $NON-NLS-1$
script.append("XSP.openMenu(thisEvent,"); // $NON-NLS-1$
script.append(menuCtorName);
script.append(");}\n"); // $NON-NLS-1$
// Connect the menu to the id
script.append("dojo.connect(dojo.byId("); // $NON-NLS-1$
JavaScriptUtil.addString(script, getConnectId());
script.append("),");
JavaScriptUtil.addString(script, getConnectEvent());
script.append(",");
script.append(menuEventName);
script.append(");\n"); // $NON-NLS-1$
collector.addScriptOnLoad(script.toString());
}
示例11: writeHeaderCheckBoxColumn
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
protected void writeHeaderCheckBoxColumn(FacesContext context, ResponseWriter w, AbstractDataView c, ViewDefinition viewDef) throws IOException {
w.startElement("th",c); // $NON-NLS-1$
w.writeAttribute("scope", "col", null); // $NON-NLS-1$ $NON-NLS-2$
String colClazz = (String)getProperty(PROP_TABLEFIRSTCELLCLASS);
if(StringUtil.isNotEmpty(colClazz)) {
w.writeAttribute("class",colClazz,null); // $NON-NLS-1$
}
if(viewDef.hasHeaderCheckBoxColumn) {
String fldName = c.getClientId(context)+":_hdrcbox"; // $NON-NLS-1$
w.startElement("input",c); // $NON-NLS-1$
w.writeAttribute("type","checkbox",null); // $NON-NLS-1$ $NON-NLS-2$
w.writeAttribute("name",fldName,null); // $NON-NLS-1$
w.writeAttribute("id",fldName,null); // $NON-NLS-1$
// Specify title attribute for accessibility
String title = "Select all rows"; // $NLS-DataViewRenderer_HeaderCheckboxTitle-1$
w.writeAttribute("title",title,null); // $NON-NLS-1$
w.writeAttribute("role", "checkbox", null);// $NON-NLS-1$ // $NON-NLS-2$
//Add JS onclick code to handle toggling aria-checked attribute
writeHeaderCheckboxAccessibilityAttributes(context, w, c.getClientId(context), fldName);
StringBuilder sBuf = new StringBuilder(256); //$NON-NLS-1$
sBuf.append("XSP.attachViewColumnCheckboxToggler("); //$NON-NLS-1$
JavaScriptUtil.addString(sBuf, c.getClientId(context));
sBuf.append(", "); //$NON-NLS-1$
JavaScriptUtil.addString(sBuf, c.getClientId(context));
sBuf.append("); "); //$NON-NLS-1$
JavaScriptUtil.addScriptOnLoad(sBuf.toString());
}
w.endElement("th"); // $NON-NLS-1$
}
示例12: writeCollapsibleInput
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
protected void writeCollapsibleInput(FacesContext context, ResponseWriter w, UIWidgetContainer c) throws IOException {
if(c.isCollapsible()) {
// Add a hidden field to cary out the section state
String id = c.getClientId(context);
boolean closed = c.isClosed();
w.startElement("input",c); // this is for the uistate $NON-NLS-1$
w.writeAttribute("id",id + _INITCLOSED,null); // $NON-NLS-1$
w.writeAttribute("name",id + _INITCLOSED,null); // $NON-NLS-1$
w.writeAttribute("type","hidden",null); // $NON-NLS-1$ $NON-NLS-2$
w.writeAttribute("value",Boolean.toString(closed),null); // closed = true means section will be closed $NON-NLS-1$
w.endElement("input"); // $NON-NLS-1$
// Initialize the script for the links
StringBuilder buff = new StringBuilder();
JavaScriptUtil.appendInitSectionScript(
context,
buff,
id+_LKCLOSED,
id,
true);
JavaScriptUtil.appendInitSectionScript(
context,
buff,
id+_LKOPENED,
id,
false);
JavaScriptUtil.addScriptOnLoad(buff.toString());
}
}
示例13: renderJavaScriptBinding
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
@Override
protected void renderJavaScriptBinding(FacesContext context, ResponseWriter writer, UIInput component) {
StringBuilder sb = new StringBuilder();
String clientId = component.getClientId(context);
String name = getNameAttribute(context, component)+HIDDEN_SUFFIX;
// dijit.byId("view:_id1:djToggleButton1").setChecked(dojo.byId("view:_id1:djToggleButton1_field").value=="on");\n
sb.append("dijit.byId("); //$NON-NLS-1$
JavaScriptUtil.addString(sb,clientId);
sb.append(").setChecked(dojo.byId("); //$NON-NLS-1$
JavaScriptUtil.addString(sb,name);
sb.append(").value=="); //$NON-NLS-1$
JavaScriptUtil.addString(sb,"on"); //$NON-NLS-1$
sb.append(");\n"); //$NON-NLS-1$
// dojo.connect(dijit.byId("view:_id1:djToggleButton1"),"onClick",function(){
// dojo.byId("view:_id1:djToggleButton1_field").value=dijit.byId("view:_id1:djToggleButton1").attr("checked")?"on":""
// });
sb.append("dojo.connect(dijit.byId("); //$NON-NLS-1$
JavaScriptUtil.addString(sb,clientId);
sb.append("),"); //$NON-NLS-1$
JavaScriptUtil.addString(sb,"onClick"); //$NON-NLS-1$
sb.append(",function(){dojo.byId("); //$NON-NLS-1$
JavaScriptUtil.addString(sb,name);
sb.append(").value=dijit.byId("); //$NON-NLS-1$
JavaScriptUtil.addString(sb,clientId);
sb.append(").attr("); //$NON-NLS-1$
JavaScriptUtil.addString(sb,"checked"); //$NON-NLS-1$
sb.append(")?"); //$NON-NLS-1$
JavaScriptUtil.addString(sb,"on"); //$NON-NLS-1$
sb.append(":"); //$NON-NLS-1$
JavaScriptUtil.addString(sb,""); //$NON-NLS-1$
sb.append("});"); //$NON-NLS-1$
((UIViewRootEx)context.getViewRoot()).addScriptOnLoad(sb.toString());
}
示例14: encodeDojoEvents
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
protected static void encodeDojoEvents(FacesContext context, UIDojoWidgetBase component,
String eventName, String eventValue) throws IOException {
if(eventValue != null) {
StringBuilder buff = new StringBuilder();
String clientId = component.getClientId(context);
// if event value set
// state the function
String clientSideScriptName = JavaScriptUtil.startMethodJS(context, component, "clientSide_" + eventName, buff); // $NON-NLS-1$
// add scripts to the function block
buff.append( eventValue );
buff.append("\n"); // $NON-NLS-1$
JavaScriptUtil.endMethodJS(buff);
boolean submit = false; // clientSide script only
int validationMode = JavaScriptUtil.VALIDATION_FULL; // since not submit, not immediate
// XSP.attachEvent
JavaScriptUtil.appendAttachEvent(buff, clientId, clientId, eventName, clientSideScriptName, submit, validationMode);
buff.append("\n"); // $NON-NLS-1$
if( buff.length() == 0 ){
// no events
return;
}
// then add the script block we just generated.
// when using dojo, can't just put onload code inline into the page,
// as the dojo dom manipulation won't have happened by then.
// Have to put it into an addOnLoad method.
JavaScriptUtil.addScriptOnLoad(buff.toString());
}
}
示例15: invoke
import com.ibm.xsp.util.JavaScriptUtil; //导入依赖的package包/类
@Override
public Object invoke(FacesContext context, Object[] params) throws EvaluationException, MethodNotFoundException {
StringBuilder b = new StringBuilder(256);
String text = getText();
if(text==null) {
text = ""; //$NON-NLS-1$
}
b.append("alert("); //$NON-NLS-1$
JavaScriptUtil.addString(b, text);
b.append(");\n"); //$NON-NLS-1$
return b.toString();
}