本文整理汇总了Java中com.ibm.xsp.util.JavaScriptUtil.addScriptOnLoad方法的典型用法代码示例。如果您正苦于以下问题:Java JavaScriptUtil.addScriptOnLoad方法的具体用法?Java JavaScriptUtil.addScriptOnLoad怎么用?Java JavaScriptUtil.addScriptOnLoad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.xsp.util.JavaScriptUtil
的用法示例。
在下文中一共展示了JavaScriptUtil.addScriptOnLoad方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
}
示例2: 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
}
示例3: 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());
}
}
}
示例4: 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);
}
示例5: 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$
}
示例6: 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());
}
}
示例7: 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());
}
}
示例8: 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());
}
示例9: setupSubmitOnClick
import com.ibm.xsp.util.JavaScriptUtil; //导入方法依赖的package包/类
private void setupSubmitOnClick(final FacesContext context, final XspPager component, final UIPager.PagerState st, final String clientId, final String sourceId) {
boolean immediate = false;
UIComponent subTree = ((FacesContextEx) context).getSubTreeComponent();
boolean partialExec = component.isPartialExecute();
String execId = null;
if (partialExec) {
execId = component.getClientId(context);
immediate = true;
} else {
if (subTree != null) {
partialExec = true;
execId = subTree.getClientId(context);
immediate = true;
}
}
boolean partialRefresh = component.isPartialRefresh();
String refreshId = null;
if (partialRefresh) {
UIComponent refreshComponent = component.findSharedDataPagerParent();
if (null == refreshComponent) {
refreshComponent = (UIComponent) st.getDataIterator();
}
refreshId = AjaxUtilEx.getRefreshId(context, refreshComponent);
} else {
if (subTree != null) {
partialRefresh = true;
refreshId = subTree.getClientId(context);
}
}
// call some JavaScript in xspClient.js
final String event = "onclick"; // $NON-NLS-1$
// Note, the onClick event is also triggered if the user tabs to the
// image\link and presses enter (Not just when clicked with a
// mouse).
// When the source is clicked, put its id in the hidden field and
// submit the form.
StringBuilder buff = new StringBuilder();
if (partialRefresh) {
JavaScriptUtil.appendAttachPartialRefreshEvent(buff, clientId, sourceId, execId, event,
/* clientSideScriptName */null, immediate ? JavaScriptUtil.VALIDATION_NONE : JavaScriptUtil.VALIDATION_FULL,
/* refreshId */refreshId,
/* onstart */getOnStart(component),
/* oncomplete */getOnComplete(component),
/* onerror */getOnError(component));
} else {
JavaScriptUtil.appendAttachEvent(buff, clientId, sourceId, execId, event,
/* clientSideScriptName */null,
/* submit */true, immediate ? JavaScriptUtil.VALIDATION_NONE : JavaScriptUtil.VALIDATION_FULL);
}
String script = buff.toString();
// Add the script block we just generated.
JavaScriptUtil.addScriptOnLoad(script);
}
示例10: setupSubmitOnClick
import com.ibm.xsp.util.JavaScriptUtil; //导入方法依赖的package包/类
protected void setupSubmitOnClick(FacesContext context, ResponseWriter w,
AbstractPager pager, FacesDataIterator dataIterator, String clientId, String sourceId) throws IOException {
boolean immediate = false;
UIComponent subTree = ((FacesContextEx)context).getSubTreeComponent();
boolean partialExec = pager.isPartialExecute();
String execId = null;
if (partialExec) {
execId = pager.getClientId(context);
immediate = true;
} else {
if(subTree!=null) {
partialExec = true;
execId = subTree.getClientId(context);
immediate = true;
}
}
boolean partialRefresh = pager.isPartialRefresh();
String refreshId = null;
if(partialRefresh) {
UIComponent refreshComponent = pager.findSharedDataPagerParent();
if (null == refreshComponent) {
refreshComponent = (UIComponent) pager.findDataIterator();
}
refreshId = AjaxUtilEx.getRefreshId(context, refreshComponent);
} else {
if(subTree!=null) {
partialRefresh = true;
refreshId = subTree.getClientId(context);
}
}
// call some JavaScript in xspClient.js
final String event = "onclick"; // $NON-NLS-1$
// Note, the onClick event is also triggered if the user tabs to the
// image\link and presses enter (Not just when clicked with a
// mouse).
// When the source is clicked, put its id in the hidden field and
// submit the form.
StringBuilder buff = new StringBuilder();
if (partialRefresh) {
JavaScriptUtil.appendAttachPartialRefreshEvent(buff, sourceId,
sourceId, execId, event,
/* clientSideScriptName */null,
immediate ? JavaScriptUtil.VALIDATION_NONE
: JavaScriptUtil.VALIDATION_FULL,
/* refreshId */refreshId,
/* onstart */getOnStart(pager),
/* oncomplete */getOnComplete(pager),
/* onerror */getOnError(pager));
} else {
JavaScriptUtil.appendAttachEvent(buff, sourceId, sourceId, execId,
event,
/* clientSideScriptName */null,
/* submit */true,
immediate ? JavaScriptUtil.VALIDATION_NONE
: JavaScriptUtil.VALIDATION_FULL);
}
String script = buff.toString();
// Add the script block we just generated.
JavaScriptUtil.addScriptOnLoad(script);
}
示例11: setupSubmitOnClick
import com.ibm.xsp.util.JavaScriptUtil; //导入方法依赖的package包/类
protected void setupSubmitOnClick(FacesContext context, UIDataSourceIterator component, String clientId, String targetId, String refreshId) {
boolean immediate = false;
UIComponent subTree = ((FacesContextEx)context).getSubTreeComponent();
boolean partialExec = component.isPartialExecute();
String execId = null;
if(partialExec) {
// The exec ID must be the actual table id, as there is not sub component for
// handling collapse/expand. Moreover, because this method is called per row
// the table client id has a trailing row number that should be removed.
// Also, because there isn't a sub component, processDecode() is called on the
// table, which implies that all the rows are decoded. But the other phases
// are skipped.
execId = component.getClientId(context);
execId = execId.substring(0,execId.lastIndexOf(':'));
immediate = true;
} else {
if(subTree!=null) {
partialExec = true;
execId = subTree.getClientId(context);
immediate = true;
}
}
boolean partialRefresh = component.isPartialRefresh();
if(partialRefresh) {
if(StringUtil.isEmpty(refreshId)) {
refreshId = component.getRefreshId();
if (StringUtil.isEmpty(refreshId)) {
refreshId = AjaxUtilEx.getRefreshId(context, component);
}
}
} else {
if(subTree!=null) {
partialRefresh = true;
refreshId = subTree.getClientId(context);
}
}
/// call some javascript in xspClient.js
final String event = "onclick"; // $NON-NLS-1$
// Note, the onclick event is also triggered if the user tabs to the
// image and presses enter. (Not just when clicked with a mouse.)
// when the span is clicked, put its id in the hidden field and submit the form.
StringBuilder buff = new StringBuilder();
if (partialRefresh) {
JavaScriptUtil.appendAttachPartialRefreshEvent(
buff,
clientId,
targetId,
execId,
event,
/* clientSideScriptName */null,
immediate?JavaScriptUtil.VALIDATION_NONE:JavaScriptUtil.VALIDATION_FULL,
/*refreshId*/refreshId,
/*onstart*/null,
/*oncomplete*/null,
/*onerror*/null
);
}
else {
JavaScriptUtil.appendAttachEvent(
buff,
clientId,
targetId,
execId,
event,
/* clientSideScriptName */null,
/*submit*/true,
immediate?JavaScriptUtil.VALIDATION_NONE:JavaScriptUtil.VALIDATION_FULL);
}
String script = buff.toString();
// then add the script block we just generated.
JavaScriptUtil.addScriptOnLoad(script);
}
示例12: setupSubmitOnClick
import com.ibm.xsp.util.JavaScriptUtil; //导入方法依赖的package包/类
protected void setupSubmitOnClick(FacesContext context, XspPager component, UIPager.PagerState st, String clientId, String sourceId) {
boolean immediate = false;
UIComponent subTree = ((FacesContextEx) context).getSubTreeComponent();
boolean partialExec = component.isPartialExecute();
String execId = null;
if (partialExec) {
execId = component.getClientId(context);
immediate = true;
} else {
if (subTree != null) {
partialExec = true;
execId = subTree.getClientId(context);
immediate = true;
}
}
boolean partialRefresh = component.isPartialRefresh();
String refreshId = null;
if (partialRefresh) {
UIComponent refreshComponent = component.findSharedDataPagerParent();
if (null == refreshComponent) {
refreshComponent = (UIComponent) st.getDataIterator();
}
refreshId = AjaxUtilEx.getRefreshId(context, refreshComponent);
} else {
if (subTree != null) {
partialRefresh = true;
refreshId = subTree.getClientId(context);
}
}
// call some JavaScript in xspClient.js
final String event = "onclick"; // $NON-NLS-1$
// Note, the onClick event is also triggered if the user tabs to the
// image\link and presses enter (Not just when clicked with a
// mouse).
// When the source is clicked, put its id in the hidden field and
// submit the form.
StringBuilder buff = new StringBuilder();
if (partialRefresh) {
JavaScriptUtil.appendAttachPartialRefreshEvent(buff, clientId, sourceId, execId, event,
/* clientSideScriptName */null, immediate ? JavaScriptUtil.VALIDATION_NONE : JavaScriptUtil.VALIDATION_FULL,
/* refreshId */refreshId,
/* onstart */getOnStart(component),
/* oncomplete */getOnComplete(component),
/* onerror */getOnError(component));
} else {
JavaScriptUtil.appendAttachEvent(buff, clientId, sourceId, execId, event,
/* clientSideScriptName */null,
/* submit */true, immediate ? JavaScriptUtil.VALIDATION_NONE : JavaScriptUtil.VALIDATION_FULL);
}
String script = buff.toString();
// Add the script block we just generated.
JavaScriptUtil.addScriptOnLoad(script);
}
示例13: setupSubmitOnClick
import com.ibm.xsp.util.JavaScriptUtil; //导入方法依赖的package包/类
protected void setupSubmitOnClick(FacesContext context, ResponseWriter w, UIAgentList agentList, String clientId, String sourceId) throws IOException {
boolean immediate = false;
UIComponent subTree = ((FacesContextEx) context).getSubTreeComponent();
boolean partialExec = false;
// boolean partialExec = agentList.isPartialExecute();
String execId = null;
if (partialExec) {
execId = agentList.getClientId(context);
immediate = true;
} else {
if (subTree != null) {
partialExec = true;
execId = subTree.getClientId(context);
immediate = true;
}
}
boolean partialRefresh = false;
// boolean partialRefresh = agentList.isPartialRefresh();
String refreshId = null;
if (partialRefresh) {
// UIComponent refreshComponent = pager.findSharedDataPagerParent();
// if (null == refreshComponent) {
// refreshComponent = (UIComponent) pager.findDataIterator();
// }
// refreshId = AjaxUtilEx.getRefreshId(context, refreshComponent);
} else {
if (subTree != null) {
partialRefresh = true;
refreshId = subTree.getClientId(context);
}
}
// call some JavaScript in xspClient.js
final String event = "onclick"; // $NON-NLS-1$
// Note, the onClick event is also triggered if the user tabs to the
// image\link and presses enter (Not just when clicked with a
// mouse).
// When the source is clicked, put its id in the hidden field and
// submit the form.
StringBuilder buff = new StringBuilder();
if (partialRefresh) {
JavaScriptUtil.appendAttachPartialRefreshEvent(buff, sourceId, sourceId, execId, event,
/* clientSideScriptName */null, immediate ? JavaScriptUtil.VALIDATION_NONE : JavaScriptUtil.VALIDATION_FULL,
/* refreshId */refreshId,
/* onstart getOnStart(pager) */"",
/* oncomplete getOnComplete(pager) */"",
/* onerror getOnError(pager) */"");
} else {
JavaScriptUtil.appendAttachEvent(buff, sourceId, sourceId, execId, event,
/* clientSideScriptName */null,
/* submit */true, immediate ? JavaScriptUtil.VALIDATION_NONE : JavaScriptUtil.VALIDATION_FULL);
}
String script = buff.toString();
// Add the script block we just generated.
JavaScriptUtil.addScriptOnLoad(script);
}