本文整理汇总了Java中com.ibm.xsp.util.JavaScriptUtil.addString方法的典型用法代码示例。如果您正苦于以下问题:Java JavaScriptUtil.addString方法的具体用法?Java JavaScriptUtil.addString怎么用?Java JavaScriptUtil.addString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.xsp.util.JavaScriptUtil
的用法示例。
在下文中一共展示了JavaScriptUtil.addString方法的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: 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());
}
示例8: 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$
}
示例9: 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());
}
示例10: 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();
}
示例11: generateClientScript
import com.ibm.xsp.util.JavaScriptUtil; //导入方法依赖的package包/类
public String generateClientScript() {
FacesContext context = FacesContext.getCurrentInstance();
StringBuilder b = new StringBuilder();
// TabContainer.js has:
// _removeTab: function(id,refreshId,params)
b.append("dijit.byId("); // $NON-NLS-1$
JavaScriptUtil.addString(b, container.getClientId(context));
b.append(")._removeTab("); // $NON-NLS-1$
JavaScriptUtil.addString(b, pane.getClientId(context));
String rid=ExtLibUtil.getClientId(context,container,refreshId,true);
if(StringUtil.isNotEmpty(rid)) {
b.append(",");
JavaScriptUtil.addString(b, rid);
Object params = refreshParams;
if(params!=null) {
b.append(",{");
try {
String json = JsonGenerator.toJson(JsonJavaFactory.instance,params,true);
b.append(json);
} catch(Exception ex) {
throw new FacesExceptionEx(ex);
}
b.append("}");
}
}
b.append(");");
if(b.length()>0) {
String script = b.toString();
return script;
}
return null;
}
示例12: encodeEnd
import com.ibm.xsp.util.JavaScriptUtil; //导入方法依赖的package包/类
@Override
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
super.encodeEnd(context, component);
if (context == null || component == null){
throw new IOException();
}
if (!component.isRendered()){
return;
}
UIComponent columnHeader = component.getParent();
if (columnHeader == null){
return;
}
UIComponent column = columnHeader.getParent();
if (column == null){
return;
}
UIComponent columnCheckbox = findInternalColumnCheckbox(column);
if (columnCheckbox == null){
return;
}
String viewPanelId = column.getParent().getClientId(context);
String columnAndCheckBoxId = columnCheckbox.getClientId(context);
columnAndCheckBoxId = columnAndCheckBoxId.substring(viewPanelId.length() + 1);
//XSP.attachViewColumnCheckboxToggler("view:form1:viewPanel1", "view:form1:viewPanel1:_id1:_hdrcbox", "_id1:_id2");
//args: ("viewPanelID", "viewColumnHeaderCheckboxID", "columnID + checkboxID");
StringBuilder js = new StringBuilder(256); //$NON-NLS-1$
js.append("XSP.attachViewColumnCheckboxToggler("); //$NON-NLS-1$
JavaScriptUtil.addString(js, viewPanelId);
js.append(", "); //$NON-NLS-1$
JavaScriptUtil.addString(js, column.getClientId(context));
js.append("); "); //$NON-NLS-1$
JavaScriptUtil.addScriptOnLoad(js.toString());
}
示例13: writeErrorSummaryButton
import com.ibm.xsp.util.JavaScriptUtil; //导入方法依赖的package包/类
protected void writeErrorSummaryButton(FacesContext context, ResponseWriter w, FormLayout c, String id, String shadeId) throws IOException {
w.startElement("input", c); // $NON-NLS-1$
w.writeAttribute("type", "button", null); // $NON-NLS-1$ $NON-NLS-2$
w.writeAttribute("value", "OK", null); //$NON-NLS-1$ $NLS-MobileFormTableRenderer_iphone.OK-2$
StringBuilder b = new StringBuilder();
b.append("XSP.hideMobileFormTableError("); // $NON-NLS-1$
JavaScriptUtil.addString(b, id);
b.append(","); // $NON-NLS-1$
JavaScriptUtil.addString(b, shadeId);
b.append(");"); // $NON-NLS-1$
w.writeAttribute("onclick", b, null); // $NON-NLS-1$
w.endElement("input"); // $NON-NLS-1$
}
示例14: calculateFormLabelWidth
import com.ibm.xsp.util.JavaScriptUtil; //导入方法依赖的package包/类
protected void calculateFormLabelWidth(FacesContext context, UIComponent component) {
StringBuilder script = new StringBuilder();
script.append("XSP.addOnLoad(function(){XSP.resizeForm("); //$NON-NLS-1$
JavaScriptUtil.addString(script, component.getClientId(context));
script.append(")});"); //$NON-NLS-1$
ExtLibUtil.addScript(context, script.toString());
}
示例15: preRenderTree
import com.ibm.xsp.util.JavaScriptUtil; //导入方法依赖的package包/类
@Override
protected void preRenderTree(FacesContext context, ResponseWriter writer, TreeContextImpl tree) throws IOException {
UIViewRootEx rootEx = (UIViewRootEx) context.getViewRoot();
rootEx.setDojoTheme(true);
ExtLibResources.addEncodeResource(rootEx, ExtLibResources.extlibMenu);
String mid = ExtLibUtil.encodeJSFunctionName(getMenuId(context,tree));
this.script = new StringBuilder();
this.menuCtorName = mid+"_ctor"; // $NON-NLS-1$
this.menuEventName = mid+"_event"; // $NON-NLS-1$
this.varName = "m";
script.append("function "); // $NON-NLS-1$
script.append(menuCtorName);
script.append("(){\n"); // $NON-NLS-1$
script.append("var "); // $NON-NLS-1$
script.append(varName);
script.append("=new "); // $NON-NLS-1$
script.append(getMenuType());
// ({"title":"Drop Down Menu"
script.append("({"); // $NON-NLS-1$
JavaScriptUtil.addString(script, "title"); // $NON-NLS-1$
script.append(":"); // $NON-NLS-1$
String menuTitle = "Drop Down Menu"; // $NLS-DojoMenuRenderer.DropDownMenu-1$
JavaScriptUtil.addString(script, menuTitle);
if(component!=null) {
boolean hasp = true;
String style = (String)component.getAttributes().get("style"); // $NON-NLS-1$
if(StringUtil.isNotEmpty(style)) {
if(hasp) script.append(","); else hasp=true;
script.append("style:"); // $NON-NLS-1$
JavaScriptUtil.addString(script, style);
}
String styleClass = (String)component.getAttributes().get("styleClass"); // $NON-NLS-1$
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$
}