本文整理匯總了Java中javax.faces.component.UIInput.getClientId方法的典型用法代碼示例。如果您正苦於以下問題:Java UIInput.getClientId方法的具體用法?Java UIInput.getClientId怎麽用?Java UIInput.getClientId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.component.UIInput
的用法示例。
在下文中一共展示了UIInput.getClientId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: validatePassword
import javax.faces.component.UIInput; //導入方法依賴的package包/類
public void validatePassword(ComponentSystemEvent event) {
FacesContext fc = FacesContext.getCurrentInstance();
UIComponent components = event.getComponent();
// get password
UIInput uiInputPassword = (UIInput) components.findComponent("newPassword");
String password = uiInputPassword.getLocalValue() == null ? ""
: uiInputPassword.getLocalValue().toString();
String passwordId = uiInputPassword.getClientId();
// get confirm password
UIInput uiInputConfirmPassword = (UIInput) components.findComponent("newConfirmPassword");
String confirmPassword = uiInputConfirmPassword.getLocalValue() == null ? ""
: uiInputConfirmPassword.getLocalValue().toString();
// Let required="true" do its job.
if (password.isEmpty() || confirmPassword.isEmpty()) {
return;
}
if (!password.equals(confirmPassword)) {
FacesMessage msg = new FacesMessage(bundle.getString("resetpassword.error.notmatch"));
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
fc.addMessage(passwordId, msg);
fc.renderResponse();
}
}
示例2: renderJavaScriptBinding
import javax.faces.component.UIInput; //導入方法依賴的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());
}
示例3: decode
import javax.faces.component.UIInput; //導入方法依賴的package包/類
public void decode(FacesContext context, UIComponent comp)
{
UIInput component = (UIInput) comp;
if (!component.isRendered()) return;
ExternalContext external = context.getExternalContext();
HttpServletRequest request = (HttpServletRequest) external.getRequest();
String clientId = component.getClientId(context);
String directory = (String) RendererUtil.getAttribute(context, component, "directory");
// mark that this component has had decode() called during request
// processing
request.setAttribute(clientId + ATTR_REQUEST_DECODED, "true");
// check for user errors and developer errors
boolean atDecodeTime = true;
String errorMessage = checkForErrors(context, component, clientId, atDecodeTime);
if (errorMessage != null)
{
addFacesMessage(context, clientId, errorMessage);
return;
}
// get the file item
FileItem item = getFileItem(context, component);
if (item.getName() == null || item.getName().length() == 0)
{
if (component.isRequired())
{
addFacesMessage(context, clientId, "Please specify a file.");
component.setValid(false);
}
return;
}
if (directory == null || directory.length() == 0)
{
// just passing on the FileItem as the value of the component, without persisting it.
component.setSubmittedValue(item);
}
else
{
// persisting to a permenent file in a directory.
// pass on the server-side filename as the value of the component.
File dir = new File(directory);
String filename = item.getName();
filename = filename.replace('\\','/'); // replaces Windows path seperator character "\" with "/"
filename = filename.substring(filename.lastIndexOf("/")+1);
File persistentFile = new File(dir, filename);
try
{
item.write(persistentFile);
component.setSubmittedValue(persistentFile.getPath());
}
catch (Exception ex)
{
throw new FacesException(ex);
}
}
}
示例4: writeFormRowData
import javax.faces.component.UIInput; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
protected void writeFormRowData(final FacesContext facesContext, final ResponseWriter w, final FormLayout c, final ComputedFormData formData,
final UIFormLayoutRow row, final UIInput edit, final ComputedRowData rowData) throws IOException {
newLine(w);
boolean hasError = false;
String editClientId = null;
Iterator<FacesMessage> messages = null;
if(edit != null) {
editClientId = edit.getClientId(facesContext);
messages = facesContext.getMessages(editClientId);
hasError = messages.hasNext();
}
w.startElement("div", null);
w.writeAttribute("id", row.getClientId(facesContext), null);
String labelPosition = c.getLabelPosition();
w.writeAttribute("class", "form-group" + (hasError ? " has-error" : ""), null);
if(rowData.hasLabel()) {
w.startElement("label", null);
String labelStyleClass = "control-label";
if(!"above".equalsIgnoreCase(labelPosition)) {
labelStyleClass = ExtLibUtil.concatStyleClasses(labelStyleClass, "col-sm-3");
}
w.writeAttribute("class", labelStyleClass, null);
String labelWidth = row.getLabelWidth();
if(StringUtil.isNotEmpty(labelWidth)) {
w.writeAttribute("style", labelWidth, null);
}
if(edit != null) {
w.writeAttribute("for", edit.getClientId(facesContext), null);
}
String label = row.getLabel();
if(StringUtil.isNotEmpty(label)) {
w.writeText(row.getLabel(), null);
}
w.endElement("label");
}
if(!"above".equalsIgnoreCase(labelPosition)) {
w.startElement("div", null);
w.writeAttribute("class", "col-sm-9", null);
}
writeFormRowDataField(facesContext, w, c, row, edit);
if(edit != null) {
while(messages.hasNext()) {
FacesMessage message = messages.next();
w.startElement("div", null);
w.writeAttribute("class", "help-block", null);
w.writeAttribute("for", editClientId, null);
w.writeText(message.getDetail(), null);
w.endElement("div");
}
}
if(!"above".equalsIgnoreCase(labelPosition)) {
w.endElement("div"); // field wrapper
}
w.endElement("div"); // row
}