Java Code Examples for javax.faces.component.UIComponent#getValueBinding()
The following examples show how to use
javax.faces.component.UIComponent#getValueBinding() .
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: RendererUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Sets component attribute value - if a ValueBinding exists for that * attribute, set through the binding; otherwise, set the value directly on * the component. */ public static void setAttribute(FacesContext context, UIComponent component, String name, Object value) { ValueBinding binding = component.getValueBinding(name); if (binding != null) { try { binding.setValue(context, value); } catch (IllegalArgumentException e) { // try setting the value as a String binding.setValue(context, String.valueOf(value)); } } else { component.getAttributes().put(name, value); } }
Example 2
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Sets component attribute value - if a ValueBinding exists for that * attribute, set through the binding; otherwise, set the value directly on * the component. */ public static void setAttribute(FacesContext context, UIComponent component, String name, Object value) { ValueBinding binding = component.getValueBinding(name); if (binding != null) { try { binding.setValue(context, value); } catch (IllegalArgumentException e) { // try setting the value as a String binding.setValue(context, String.valueOf(value)); } } else { component.getAttributes().put(name, value); } }
Example 3
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Sets component attribute value - if a ValueBinding exists for that * attribute, set through the binding; otherwise, set the value directly on * the component. */ public static void setAttribute(FacesContext context, UIComponent component, String name, Object value) { ValueBinding binding = component.getValueBinding(name); if (binding != null) { try { binding.setValue(context, value); } catch (IllegalArgumentException e) { // try setting the value as a String binding.setValue(context, String.valueOf(value)); } } else { component.getAttributes().put(name, value); } }
Example 4
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Sets component attribute value - if a ValueBinding exists for that * attribute, set through the binding; otherwise, set the value directly on * the component. */ public static void setAttribute(FacesContext context, UIComponent component, String name, Object value) { ValueBinding binding = component.getValueBinding(name); if (binding != null) { try { binding.setValue(context, value); } catch (IllegalArgumentException e) { // try setting the value as a String binding.setValue(context, String.valueOf(value)); } } else { component.getAttributes().put(name, value); } }
Example 5
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Sets component attribute value - if a ValueBinding exists for that * attribute, set through the binding; otherwise, set the value directly on * the component. */ public static void setAttribute(FacesContext context, UIComponent component, String name, Object value) { ValueBinding binding = component.getValueBinding(name); if (binding != null) { try { binding.setValue(context, value); } catch (IllegalArgumentException e) { // try setting the value as a String binding.setValue(context, String.valueOf(value)); } } else { component.getAttributes().put(name, value); } }
Example 6
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Sets component attribute value - if a ValueBinding exists for that * attribute, set through the binding; otherwise, set the value directly on * the component. */ public static void setAttribute(FacesContext context, UIComponent component, String name, Object value) { ValueBinding binding = component.getValueBinding(name); if (binding != null) { try { binding.setValue(context, value); } catch (IllegalArgumentException e) { // try setting the value as a String binding.setValue(context, String.valueOf(value)); } } else { component.getAttributes().put(name, value); } }
Example 7
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Return the attribute value - handles getting the value from a * ValueBinding if necessary. This is necessary because of a difference in * the Sun JSF RI versus the MyFaces RI. The Sun RI * component.getAttributes().get(attrName) will automatically return value * bindings, whereas the MyFaces implmentation requires getting values from * ValueBinding seperately. */ public static Object getAttribute(FacesContext context, UIComponent component, String name) { // first check the attributes Object ret = component.getAttributes().get(name); if (ret != null) return ret; // next check the value bindings ValueBinding vb = component.getValueBinding(name); if (vb != null) ret = vb.getValue(context); return ret; }
Example 8
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Return the attribute value - handles getting the value from a * ValueBinding if necessary. This is necessary because of a difference in * the Sun JSF RI versus the MyFaces RI. The Sun RI * component.getAttributes().get(attrName) will automatically return value * bindings, whereas the MyFaces implmentation requires getting values from * ValueBinding seperately. */ public static Object getAttribute(FacesContext context, UIComponent component, String name) { // first check the attributes Object ret = component.getAttributes().get(name); if (ret != null) return ret; // next check the value bindings ValueBinding vb = component.getValueBinding(name); if (vb != null) ret = vb.getValue(context); return ret; }
Example 9
Source File: NavigationMapRenderer.java From sakai with Educational Community License v2.0 | 5 votes |
/** * * @param context FacesContext * @param component UIComponent * @param name String * @return Object */ private static Object get(FacesContext context, UIComponent component, String name) { ValueBinding binding = component.getValueBinding(name); if (binding != null) { return binding.getValue(context); } else { return component.getAttributes().get(name); } }
Example 10
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Return the attribute value - handles getting the value from a * ValueBinding if necessary. This is necessary because of a difference in * the Sun JSF RI versus the MyFaces RI. The Sun RI * component.getAttributes().get(attrName) will automatically return value * bindings, whereas the MyFaces implmentation requires getting values from * ValueBinding seperately. */ public static Object getAttribute(FacesContext context, UIComponent component, String name) { // first check the attributes Object ret = component.getAttributes().get(name); if (ret != null) return ret; // next check the value bindings ValueBinding vb = component.getValueBinding(name); if (vb != null) ret = vb.getValue(context); return ret; }
Example 11
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Return the attribute value - handles getting the value from a * ValueBinding if necessary. This is necessary because of a difference in * the Sun JSF RI versus the MyFaces RI. The Sun RI * component.getAttributes().get(attrName) will automatically return value * bindings, whereas the MyFaces implmentation requires getting values from * ValueBinding seperately. */ public static Object getAttribute(FacesContext context, UIComponent component, String name) { // first check the attributes Object ret = component.getAttributes().get(name); if (ret != null) return ret; // next check the value bindings ValueBinding vb = component.getValueBinding(name); if (vb != null) ret = vb.getValue(context); return ret; }
Example 12
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Return the attribute value - handles getting the value from a * ValueBinding if necessary. This is necessary because of a difference in * the Sun JSF RI versus the MyFaces RI. The Sun RI * component.getAttributes().get(attrName) will automatically return value * bindings, whereas the MyFaces implmentation requires getting values from * ValueBinding seperately. */ public static Object getAttribute(FacesContext context, UIComponent component, String name) { // first check the attributes Object ret = component.getAttributes().get(name); if (ret != null) return ret; // next check the value bindings ValueBinding vb = component.getValueBinding(name); if (vb != null) ret = vb.getValue(context); return ret; }
Example 13
Source File: NavigationMapRenderer.java From sakai with Educational Community License v2.0 | 5 votes |
/** * * @param context FacesContext * @param component UIComponent * @param name String * @return Object */ private static Object get(FacesContext context, UIComponent component, String name) { ValueBinding binding = component.getValueBinding(name); if (binding != null) { return binding.getValue(context); } else { return component.getAttributes().get(name); } }
Example 14
Source File: RendererUtil.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Return the attribute value - handles getting the value from a * ValueBinding if necessary. This is necessary because of a difference in * the Sun JSF RI versus the MyFaces RI. The Sun RI * component.getAttributes().get(attrName) will automatically return value * bindings, whereas the MyFaces implmentation requires getting values from * ValueBinding seperately. */ public static Object getAttribute(FacesContext context, UIComponent component, String name) { // first check the attributes Object ret = component.getAttributes().get(name); if (ret != null) return ret; // next check the value bindings ValueBinding vb = component.getValueBinding(name); if (vb != null) ret = vb.getValue(context); return ret; }
Example 15
Source File: UploadRenderer.java From sakai with Educational Community License v2.0 | 4 votes |
public void decode(FacesContext context, UIComponent component){ log.debug("**** decode ="); ExternalContext external = context.getExternalContext(); HttpServletRequest request = (HttpServletRequest) external.getRequest(); String clientId = component.getClientId(context); WrappedUpload item = wrapUpload(request, clientId + UPLOAD); log.debug("clientId = {}", clientId); log.debug("wrappedUpload = {}", item); ServerConfigurationService serverConfigurationService = ComponentManager.get(ServerConfigurationService.class); Long maxSize = Long.valueOf(serverConfigurationService.getString("samigo.sizeMax", "40960")); // Check if file > maxSize allowed if (item != null && item.getSize()/1000 > maxSize.intValue()){ ((ServletContext)external.getContext()).setAttribute("TEMP_FILEUPLOAD_SIZE", Long.valueOf(item.getSize()/1000)); ((EditableValueHolder) component).setSubmittedValue("SizeTooBig:" + item.getName()); return; } Object target; ValueBinding binding = component.getValueBinding("target"); if (binding != null) target = binding.getValue(context); else target = component.getAttributes().get("target"); String repositoryPath = serverConfigurationService.getString("samigo.answerUploadRepositoryPath", "${sakai.home}/samigo/answerUploadRepositoryPath/"); log.debug("****{}", repositoryPath); if (target != null){ File dir = new File(repositoryPath+target.toString()); //directory where file would be saved if (!dir.exists()) dir.mkdirs(); if (item != null && !("").equals(item.getName())){ String fullname = item.getName(); fullname = fullname.replace('\\','/'); // replace c:\fullname to c:/fullname fullname = fullname.substring(fullname.lastIndexOf("/")+1); int dot_index = fullname.lastIndexOf("."); String filename = ""; if (dot_index < 0) { filename = fullname + "_" + (new Date()).getTime(); } else { filename = fullname.substring(0, dot_index) + "_" + (new Date()).getTime() + fullname.substring(dot_index); } String filePath = dir.getPath()+"/"+filename; log.debug("**1. filename= {}", filePath); try { //if (mediaIsValid) item.write(file); item.write(filePath); // change value so we can evoke the listener ((EditableValueHolder) component).setSubmittedValue(filePath); } catch (Exception ex){ throw new FacesException(ex); } } } }
Example 16
Source File: UploadRenderer.java From sakai with Educational Community License v2.0 | 4 votes |
public void decode(FacesContext context, UIComponent component){ log.debug("**** decode ="); ExternalContext external = context.getExternalContext(); HttpServletRequest request = (HttpServletRequest) external.getRequest(); String clientId = component.getClientId(context); WrappedUpload item = wrapUpload(request, clientId + UPLOAD); log.debug("clientId = {}", clientId); log.debug("wrappedUpload = {}", item); ServerConfigurationService serverConfigurationService = ComponentManager.get(ServerConfigurationService.class); Long maxSize = Long.valueOf(serverConfigurationService.getString("samigo.sizeMax", "40960")); // Check if file > maxSize allowed if (item != null && item.getSize()/1000 > maxSize.intValue()){ ((ServletContext)external.getContext()).setAttribute("TEMP_FILEUPLOAD_SIZE", Long.valueOf(item.getSize()/1000)); ((EditableValueHolder) component).setSubmittedValue("SizeTooBig:" + item.getName()); return; } Object target; ValueBinding binding = component.getValueBinding("target"); if (binding != null) target = binding.getValue(context); else target = component.getAttributes().get("target"); String repositoryPath = serverConfigurationService.getString("samigo.answerUploadRepositoryPath", "${sakai.home}/samigo/answerUploadRepositoryPath/"); log.debug("****{}", repositoryPath); if (target != null){ File dir = new File(repositoryPath+target.toString()); //directory where file would be saved if (!dir.exists()) dir.mkdirs(); if (item != null && !("").equals(item.getName())){ String fullname = item.getName(); fullname = fullname.replace('\\','/'); // replace c:\fullname to c:/fullname fullname = fullname.substring(fullname.lastIndexOf("/")+1); int dot_index = fullname.lastIndexOf("."); String filename = ""; if (dot_index < 0) { filename = fullname + "_" + (new Date()).getTime(); } else { filename = fullname.substring(0, dot_index) + "_" + (new Date()).getTime() + fullname.substring(dot_index); } String filePath = dir.getPath()+"/"+filename; log.debug("**1. filename= {}", filePath); try { //if (mediaIsValid) item.write(file); item.write(filePath); // change value so we can evoke the listener ((EditableValueHolder) component).setSubmittedValue(filePath); } catch (Exception ex){ throw new FacesException(ex); } } } }