本文整理汇总了Java中com.ibm.xsp.extlib.component.layout.impl.SearchBar.getQueryParam方法的典型用法代码示例。如果您正苦于以下问题:Java SearchBar.getQueryParam方法的具体用法?Java SearchBar.getQueryParam怎么用?Java SearchBar.getQueryParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.xsp.extlib.component.layout.impl.SearchBar
的用法示例。
在下文中一共展示了SearchBar.getQueryParam方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeSearchScript
import com.ibm.xsp.extlib.component.layout.impl.SearchBar; //导入方法依赖的package包/类
protected void writeSearchScript(FacesContext context, ResponseWriter w, UIApplicationLayout c, SimpleResponsiveApplicationConfiguration configuration, SearchBar searchBar, ITree tree, boolean options) throws IOException {
String cid = c.getClientId(context) + "_search"; // $NON-NLS-1$
String submitSearch = "_xspAppSearchSubmit"; // $NON-NLS-1$
// "/search.xsp"
String searchPageName = searchBar.getPageName();
if( StringUtil.isEmpty(searchPageName) ){
searchPageName = "/";
}else{
// append .xsp if needed
searchPageName = ExtLibUtil.getPageXspUrl(searchPageName);
}
// "/apps/XPagesExt.nsf/search.xsp"
String path = context.getApplication().getViewHandler().getResourceURL(context, searchPageName);
path = context.getExternalContext().encodeActionURL(path);
// Compose the script function
w.startElement("script",c); // $NON-NLS-1$
if(DEBUG) { newLine(w); }
StringBuilder sb = new StringBuilder();
sb.append("function "); // $NON-NLS-1$
sb.append(submitSearch);
sb.append("(){");
if(DEBUG) { sb.append('\n'); }
//sb.append("var val=XSP.getElementById('"); sb.append(cid); sb.append("').value;");
sb.append("var val=XSP.getFieldValue(XSP.getElementById('"); sb.append(cid); sb.append("'));"); // $NON-NLS-1$
if(DEBUG) { sb.append('\n'); }
if(options) {
String oid = c.getClientId(context)+"_searchopt"; // $NON-NLS-1$
sb.append("var opt=XSP.getFieldValue(XSP.getElementById('"); sb.append(oid); sb.append("'));"); // $NON-NLS-1$
if(DEBUG) { sb.append('\n'); }
}
sb.append("if(val){var loc='"); // $NON-NLS-1$
JSUtil.appendJavaScriptString(sb, path);
sb.append("?");
String queryParam = searchBar.getQueryParam();
if(StringUtil.isEmpty(queryParam)) {
queryParam = "search"; // $NON-NLS-1$
}
JSUtil.appendJavaScriptString(sb, queryParam);
sb.append("='+encodeURIComponent(val)"); // $NON-NLS-1$
if(options) {
sb.append("+'&");
String optionsParam = searchBar.getOptionsParam();
if(StringUtil.isEmpty(optionsParam)) {
optionsParam = "option"; // $NON-NLS-1$
}
JSUtil.appendJavaScriptString(sb, optionsParam);
sb.append("='+encodeURIComponent(opt)"); // $NON-NLS-1$
}
sb.append(";");
if(DEBUG) { sb.append('\n'); }
sb.append("window.location.href=loc;}}"); // $NON-NLS-1$
w.writeText(sb.toString(),null);
if(DEBUG) { newLine(w); }
w.endElement("script"); // $NON-NLS-1$
}
示例2: writeSearchScript
import com.ibm.xsp.extlib.component.layout.impl.SearchBar; //导入方法依赖的package包/类
protected void writeSearchScript(FacesContext context, ResponseWriter w, UIApplicationLayout c, BasicApplicationConfigurationImpl configuration, SearchBar searchBar, ITree tree, boolean options) throws IOException {
String cid = c.getClientId(context) + "_search"; // $NON-NLS-1$
String submitSearch = "_xspAppSearchSubmit"; // $NON-NLS-1$
// "/search.xsp"
String searchPageName = searchBar.getPageName();
if( StringUtil.isEmpty(searchPageName) ){
searchPageName = "/";
}else{
// append .xsp if needed
searchPageName = ExtLibUtil.getPageXspUrl(searchPageName);
}
// "/apps/XPagesExt.nsf/search.xsp"
String path = context.getApplication().getViewHandler().getResourceURL(context, searchPageName);
path = context.getExternalContext().encodeActionURL(path);
// Compose the script function
w.startElement("script",c); // $NON-NLS-1$
if(DEBUG) { newLine(w); }
StringBuilder sb = new StringBuilder();
sb.append("function "); // $NON-NLS-1$
sb.append(submitSearch);
sb.append("(){");
if(DEBUG) { sb.append('\n'); }
//sb.append("var val=XSP.getElementById('"); sb.append(cid); sb.append("').value;");
sb.append("var val=XSP.getFieldValue(XSP.getElementById('"); sb.append(cid); sb.append("'));"); // $NON-NLS-1$
if(DEBUG) { sb.append('\n'); }
if(options) {
String oid = c.getClientId(context)+"_searchopt"; // $NON-NLS-1$
sb.append("var opt=XSP.getFieldValue(XSP.getElementById('"); sb.append(oid); sb.append("'));"); // $NON-NLS-1$
if(DEBUG) { sb.append('\n'); }
}
sb.append("if(val){var loc='"); // $NON-NLS-1$
JSUtil.appendJavaScriptString(sb, path);
sb.append("?");
String queryParam = searchBar.getQueryParam();
if(StringUtil.isEmpty(queryParam)) {
queryParam = "search"; // $NON-NLS-1$
}
JSUtil.appendJavaScriptString(sb, queryParam);
sb.append("='+encodeURIComponent(val)"); // $NON-NLS-1$
if(options) {
sb.append("+'&");
String optionsParam = searchBar.getOptionsParam();
if(StringUtil.isEmpty(optionsParam)) {
optionsParam = "option"; // $NON-NLS-1$
}
JSUtil.appendJavaScriptString(sb, optionsParam);
sb.append("='+encodeURIComponent(opt)"); // $NON-NLS-1$
}
sb.append(";");
if(DEBUG) { sb.append('\n'); }
sb.append("window.location.href=loc;}}"); // $NON-NLS-1$
w.writeText(sb.toString(),null);
if(DEBUG) { newLine(w); }
w.endElement("script"); // $NON-NLS-1$
}