Java Code Examples for javax.faces.component.UIInput#setSubmittedValue()
The following examples show how to use
javax.faces.component.UIInput#setSubmittedValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JSFUtils.java From development with Apache License 2.0 | 6 votes |
/** * Reset the values of all UIInput children. This might be necessary after a * validation error to successfully process an AJAX request. See [Bug 5449] * and http://wiki.apache.org/myfaces/ClearInputComponents * * @param uiComponent * the root component to be processed. */ public static void resetUIInputChildren(UIComponent uiComponent) { if (uiComponent != null) { List<UIComponent> children = uiComponent.getChildren(); for (UIComponent child : children) { if (child instanceof UIInput) { UIInput uiInput = (UIInput) child; uiInput.setSubmittedValue(null); uiInput.setValue(null); uiInput.setLocalValueSet(false); } else { resetUIInputChildren(child); } } } }
Example 2
Source File: InputColorRenderer.java From sakai with Educational Community License v2.0 | 6 votes |
/** * decode method * @param context * @param component */ public void decode(FacesContext context, UIComponent component) { // we haven't added these attributes--yet--defensive programming... if(RendererUtil.isDisabledOrReadonly(context, component)) { return; } String clientId = component.getClientId(context); Map requestParameterMap = context.getExternalContext() .getRequestParameterMap(); String newValue = (String) requestParameterMap.get(clientId ); UIInput comp = (UIInput) component; comp.setSubmittedValue(newValue); }
Example 3
Source File: ColorPickerRenderer.java From sakai with Educational Community License v2.0 | 6 votes |
/** * decode method * @param context * @param component */ public void decode(FacesContext context, UIComponent component) { // we haven't added these attributes--yet--defensive programming... if(RendererUtil.isDisabledOrReadonly(component)) { return; } String clientId = component.getClientId(context); Map requestParameterMap = context.getExternalContext() .getRequestParameterMap(); String newValue = (String) requestParameterMap.get(clientId ); UIInput comp = (UIInput) component; comp.setSubmittedValue(newValue); }
Example 4
Source File: FacesComponentUtility.java From oxTrust with MIT License | 6 votes |
private static void resetInputComponents(UIComponent rootUIComponent) { if ((rootUIComponent == null) || (rootUIComponent.getChildCount() == 0)) { return; } for (UIComponent comp : rootUIComponent.getChildren()) { if (comp instanceof UIInput) { UIInput uiInput = (UIInput) comp; uiInput.setSubmittedValue(null); uiInput.setValid(true); uiInput.setLocalValueSet(false); uiInput.resetValue(); } resetInputComponents(comp); } }
Example 5
Source File: InputColorRenderer.java From sakai with Educational Community License v2.0 | 6 votes |
/** * decode method * @param context * @param component */ public void decode(FacesContext context, UIComponent component) { // we haven't added these attributes--yet--defensive programming... if(RendererUtil.isDisabledOrReadonly(context, component)) { return; } String clientId = component.getClientId(context); Map requestParameterMap = context.getExternalContext() .getRequestParameterMap(); String newValue = (String) requestParameterMap.get(clientId ); UIInput comp = (UIInput) component; comp.setSubmittedValue(newValue); }
Example 6
Source File: ColorPickerRenderer.java From sakai with Educational Community License v2.0 | 6 votes |
/** * decode method * @param context * @param component */ public void decode(FacesContext context, UIComponent component) { // we haven't added these attributes--yet--defensive programming... if(RendererUtil.isDisabledOrReadonly(component)) { return; } String clientId = component.getClientId(context); Map requestParameterMap = context.getExternalContext() .getRequestParameterMap(); String newValue = (String) requestParameterMap.get(clientId ); UIInput comp = (UIInput) component; comp.setSubmittedValue(newValue); }
Example 7
Source File: InputFileUploadRenderer.java From sakai with Educational Community License v2.0 | 4 votes |
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); } } }
Example 8
Source File: InputFileUploadRenderer.java From sakai with Educational Community License v2.0 | 4 votes |
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); } } }
Example 9
Source File: InputFileUploadRenderer.java From sakai with Educational Community License v2.0 | 4 votes |
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); } } }
Example 10
Source File: InputFileUploadRenderer.java From sakai with Educational Community License v2.0 | 4 votes |
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); } } }