本文整理汇总了Java中javax.faces.component.UIForm.getClientId方法的典型用法代码示例。如果您正苦于以下问题:Java UIForm.getClientId方法的具体用法?Java UIForm.getClientId怎么用?Java UIForm.getClientId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.component.UIForm
的用法示例。
在下文中一共展示了UIForm.getClientId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateFormSubmit
import javax.faces.component.UIForm; //导入方法依赖的package包/类
/**
* Generate the JavaScript to submit the parent Form.
*
* @param context FacesContext
* @param component UIComponent to generate JavaScript for
*
* @return JavaScript event code
*/
public static String generateFormSubmit(FacesContext context, UIComponent component)
{
UIForm form = Utils.getParentForm(context, component);
if (form == null)
{
throw new IllegalStateException("Must nest components inside UIForm to generate form submit!");
}
String formClientId = form.getClientId(context);
StringBuilder buf = new StringBuilder(48);
buf.append("document.forms['");
buf.append(formClientId);
buf.append("'].submit()");
buf.append(";return false;");
return buf.toString();
}
示例2: encodeFormSubmit
import javax.faces.component.UIForm; //导入方法依赖的package包/类
private static void encodeFormSubmit(UIComponent component, ResponseWriter rw, boolean evenWithoutParameters)
throws IOException {
String parameterList = "";
List<UIComponent> children = component.getChildren();
for (UIComponent parameter : children) {
if (parameter instanceof UIParameter) {
String value = String.valueOf(((UIParameter) parameter).getValue());
String name = ((UIParameter) parameter).getName();
if (null != value) {
parameterList += ",'" + name + "':'" + value + "'";
}
}
}
if (evenWithoutParameters || parameterList.length() > 0) {
UIForm currentForm = getSurroundingForm((UIComponent) component, false);
parameterList = "'" + currentForm.getClientId() + "',{'" + component.getClientId() + "':'"
+ component.getClientId() + "'" + parameterList + "}";
rw.writeAttribute("onclick",
encodeClick((UIComponent) component) + "BsF.submitForm(" + parameterList + ");return false;", null);
}
}
示例3: addEventHandlingHiddenFieldsIfNotExists
import javax.faces.component.UIForm; //导入方法依赖的package包/类
public static void addEventHandlingHiddenFieldsIfNotExists(FacesContext context, UIComponent component) throws IOException {
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
UIForm parentForm = findForm(component);
String parentFormClientId = parentForm.getClientId(context);
String eventSenderHiddenFieldFinalId = getEventSenderHiddenFieldId(parentFormClientId);
String eventSenderHiddenFieldRenderedAttribute = getEventSenderHiddenFieldRenderedAttributeName(parentFormClientId);
String eventArgumentHiddenFieldFinalId = getEventArgumentHiddenFieldId(parentFormClientId);
String eventArgumentHiddenFieldRenderedAttribute = getEventArgumentHiddenFieldRenderedAttributeName(parentFormClientId);
ResponseWriter writer = context.getResponseWriter();
if (request.getAttribute(eventSenderHiddenFieldRenderedAttribute) == null) {
renderEmptyHiddenField(eventSenderHiddenFieldFinalId, writer);
request.setAttribute(eventSenderHiddenFieldRenderedAttribute, true);
}
if (request.getAttribute(eventArgumentHiddenFieldRenderedAttribute) == null) {
renderEmptyHiddenField(eventArgumentHiddenFieldFinalId, writer);
request.setAttribute(eventArgumentHiddenFieldRenderedAttribute, true);
}
}
示例4: getSubmitJavaScriptWithArgument
import javax.faces.component.UIForm; //导入方法依赖的package包/类
public static String getSubmitJavaScriptWithArgument(FacesContext context, UIComponent component, String eventArgument) {
UIForm parentForm = findForm(component);
String parentFormClientId = parentForm.getClientId(context);
String componentClientId = component.getClientId(context);
String eventSenderHiddenFieldId = getEventSenderHiddenFieldId(parentFormClientId);
String eventArgumentHiddenFieldId = getEventArgumentHiddenFieldId(parentFormClientId);
StringBuilder onClickEvent = new StringBuilder();
onClickEvent.append("document.forms['").append(parentFormClientId).append("'].elements['");
onClickEvent.append(eventSenderHiddenFieldId).append("'].value='").append(componentClientId).append("';");
onClickEvent.append("document.forms['").append(parentFormClientId).append("'].elements['");
onClickEvent.append(eventArgumentHiddenFieldId).append("'].value='").append(eventArgument).append("';");
onClickEvent.append("document.forms['").append(parentFormClientId).append("'].submit();");
return onClickEvent.toString();
}
示例5: getSubmitJavaScriptWithParameters
import javax.faces.component.UIForm; //导入方法依赖的package包/类
/**
*
* @param context
* @param component
* @param uiParameterList
* @return
*/
public static String getSubmitJavaScriptWithParameters(FacesContext context, UIComponent component,
List<UIParameter> uiParameterList) {
UIForm parentForm = findForm(component);
String parentFormClientId = parentForm.getClientId(context);
String componentClientId = component.getClientId(context);
String eventSenderHiddenFieldId = getEventSenderHiddenFieldId(parentFormClientId);
StringBuilder setParametersJavaScript = new StringBuilder();
for (int i = 0; i < uiParameterList.size(); i++) {
UIParameter parameter = uiParameterList.get(i);
setParametersJavaScript.append("document.forms['").append(parentFormClientId).append("'].elements['")
.append(parameter.getName()).append("'].value='").append(parameter.getValue()).append("';");
}
StringBuilder onClickEvent = new StringBuilder();
onClickEvent.append("document.forms['").append(parentFormClientId).append("'].elements['");
onClickEvent.append(eventSenderHiddenFieldId).append("'].value='").append(componentClientId).append("';");
onClickEvent.append(setParametersJavaScript.toString());
onClickEvent.append("document.forms['").append(parentFormClientId).append("'].submit();");
return onClickEvent.toString();
}
示例6: decode
import javax.faces.component.UIForm; //导入方法依赖的package包/类
@Override
public void decode(FacesContext context) {
Map paramMap = context.getExternalContext().getRequestParameterMap();
UIForm parentForm = JsfRenderUtils.findForm(this);
String parentFormClientId = parentForm.getClientId(context);
String eventSenderHiddenFieldId = JsfRenderUtils.getEventSenderHiddenFieldId(parentFormClientId);
String eventSenderId = (String) paramMap.get(eventSenderHiddenFieldId);
boolean isReset = false;
if (this.getType() != null && this.getType().equalsIgnoreCase(INPUT_RESET_TYPE)) {
isReset = true;
}
if (!isReset && (eventSenderId != null) && eventSenderId.equals(this.getClientId(context))) {
this.queueEvent(new ActionEvent(this));
}
}
示例7: encodeEnd
import javax.faces.component.UIForm; //导入方法依赖的package包/类
@Override
public void encodeEnd(FacesContext context) throws IOException {
if (!isRendered()) {
return;
}
Map<String, Object> attrs = getAttributes();
final UIForm form = BsfUtils.getClosestForm(this);
if (form == null) {
throw new FacesException("The default command component must be inside a form", null);
} else {
String target = (String)attrs.get("target");
if(BsfUtils.isStringValued(target)) {
ResponseWriter rw = context.getResponseWriter();
String formId = form.getClientId();
String actionCommandId = ExpressionResolver.getComponentIDs(context, this, target);
rw.startElement("script", this);
rw.writeText("" + "$(function() { " + " $('form#"
+ BsfUtils.escapeJQuerySpecialCharsInSelector(formId) + " input').keypress(function (e) { "
+ " if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) { "
+ " document.getElementById('" + actionCommandId + "').click();return false; "
+ " } else { " + " console.log('keycode not 13'); " + " return true; "
+ " } " + " }); " + "});", null);
rw.writeText("" + "$(function() { " + " $('form#"
+ BsfUtils.escapeJQuerySpecialCharsInSelector(formId) + " textarea').keypress(function (e) { "
+ " if ((e.ctrlKey && e.which && e.which == 13) || (e.ctrlKey && e.keyCode && e.keyCode == 13)) { "
+ " document.getElementById('" + actionCommandId + "').click();return false; "
+ " } else { " + " console.log('keycode not 13 or ctrl not pressed'); " + " return true; "
+ " } " + " }); " + "});", null);
rw.endElement("script");
} else {
throw new FacesException("The default command component needs a defined target ID", null);
}
}
}
示例8: decode
import javax.faces.component.UIForm; //导入方法依赖的package包/类
@Override
public void decode(FacesContext context) {
Map paramMap = context.getExternalContext().getRequestParameterMap();
UIForm parentForm = JsfRenderUtils.findForm(this);
String parentFormClientId = parentForm.getClientId(context);
String eventSenderHiddenFieldId = JsfRenderUtils.getEventSenderHiddenFieldId(parentFormClientId);
String eventSenderId = (String) paramMap.get(eventSenderHiddenFieldId);
if (eventSenderId != null && eventSenderId.equals(this.getClientId(context))) {
this.queueEvent(new ActionEvent(this));
}
}
示例9: getSubmitJavaScript
import javax.faces.component.UIForm; //导入方法依赖的package包/类
public static String getSubmitJavaScript(FacesContext context, UIComponent component) {
UIForm parentForm = findForm(component);
String parentFormClientId = parentForm.getClientId(context);
String componentClientId = component.getClientId(context);
String eventSenderHiddenFieldId = getEventSenderHiddenFieldId(parentFormClientId);
StringBuilder onClickEvent = new StringBuilder();
onClickEvent.append("document.forms['").append(parentFormClientId).append("'].elements['");
onClickEvent.append(eventSenderHiddenFieldId).append("'].value='").append(componentClientId);
onClickEvent.append("';document.forms['").append(parentFormClientId).append("'].submit();");
return onClickEvent.toString();
}
示例10: addHiddenFieldsForParametersIfNotExists
import javax.faces.component.UIForm; //导入方法依赖的package包/类
public static void addHiddenFieldsForParametersIfNotExists(FacesContext context, UIComponent parentComponent,
List<UIParameter> uiParameters) throws IOException {
UIForm parentForm = findForm(parentComponent);
String parentFormClientId = parentForm.getClientId(context);
ResponseWriter writer = context.getResponseWriter();
HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
for (int i = 0; i < uiParameters.size(); i++) {
UIParameter parameter = uiParameters.get(i);
addHiddenFieldForParameterIfNotExists(parentFormClientId, request, writer, parameter.getName());
}
}
示例11: getFormClientId
import javax.faces.component.UIForm; //导入方法依赖的package包/类
public static String getFormClientId(UIComponent component, FacesContext context) {
final UIForm form = getForm(component);
return form != null ? form.getClientId(context) : null;
}
示例12: getClearEventSenderFieldJavaScript
import javax.faces.component.UIForm; //导入方法依赖的package包/类
public static String getClearEventSenderFieldJavaScript(FacesContext context, UIComponent component) {
UIForm parentForm = findForm(component);
String parentFormClientId = parentForm.getClientId(context);
String eventSenderHiddenFieldId = getEventSenderHiddenFieldId(parentFormClientId);
StringBuilder clearEventSenderFieldJavaScript = new StringBuilder();
clearEventSenderFieldJavaScript.append("document.forms['").append(parentFormClientId).append("'].elements['")
.append(eventSenderHiddenFieldId).append("'].value='';");
return clearEventSenderFieldJavaScript.toString();
}
示例13: getHiddenFieldName
import javax.faces.component.UIForm; //导入方法依赖的package包/类
/**
* We use a hidden field name based on the parent form component Id and
* the string "modelist" to give a hidden field name that can be shared by all
* ModeList components within a single UIForm component.
*
* @return hidden field name
*/
private static String getHiddenFieldName(FacesContext context, UIComponent component)
{
UIForm form = Utils.getParentForm(context, component);
return form.getClientId(context) + NamingContainer.SEPARATOR_CHAR + "modelist";
}
示例14: getHiddenFieldName
import javax.faces.component.UIForm; //导入方法依赖的package包/类
/**
* We use a hidden field name based on the parent form component Id and
* the string "panel" to give a hidden field name that can be shared by all panels
* within a single UIForm component.
*
* @return hidden field name
*/
private String getHiddenFieldName(FacesContext fc)
{
UIForm form = Utils.getParentForm(fc, this);
return form.getClientId(fc) + NamingContainer.SEPARATOR_CHAR + "panel";
}
示例15: getHiddenFieldName
import javax.faces.component.UIForm; //导入方法依赖的package包/类
/**
* We use a hidden field name based on the parent form component Id and
* the string "selectlist" to give a hidden field name that can be shared by all
* SelectList components within a single UIForm component.
*
* @return hidden field name
*/
private static String getHiddenFieldName(FacesContext context, UIComponent component)
{
UIForm form = Utils.getParentForm(context, component);
return form.getClientId(context) + NamingContainer.SEPARATOR_CHAR + "selectlist";
}