List of usage examples for javax.el PropertyNotFoundException PropertyNotFoundException
public PropertyNotFoundException(Throwable cause)
From source file:org.ajax4jsf.templatecompiler.el.ELCompiler.java
private boolean processingValue(AstValue node, StringBuffer sb, CompilationContext componentBean) { String lastIndexValue = "null"; String lastVariableType = null; List<String> names = new ArrayList<String>(); for (int i = 0; i < node.jjtGetNumChildren(); i++) { StringBuffer sb1 = new StringBuffer(); Node subChild = node.jjtGetChild(i); if (subChild instanceof AstIdentifier) { String variableName = subChild.getImage(); if (componentBean.containsVariable(variableName)) { lastVariableType = componentBean.getVariableType(variableName).getName(); names.add(variableName); } else { processingIdentifier((AstIdentifier) subChild, sb1, componentBean); }/*w ww . j a v a 2 s. c om*/ } else if (subChild instanceof AstDotSuffix) { String propertyName = subChild.getImage(); log.debug("Object: " + lastVariableType + ", property: " + propertyName); if (lastVariableType != null) { try { Class<?> clazz = componentBean.loadClass(lastVariableType); PropertyDescriptor propertyDescriptor = getPropertyDescriptor(clazz, propertyName, componentBean); if (propertyDescriptor == null) { throw new PropertyNotFoundException( "property: " + propertyName + " not found in class: " + lastVariableType); } log.debug("propertyObject: " + propertyDescriptor.getPropertyType().getName()); StringBuffer tmpbuf = new StringBuffer(); tmpbuf.append(propertyDescriptor.getReadMethod().getName()); tmpbuf.append("()"); names.add(tmpbuf.toString()); lastVariableType = propertyDescriptor.getPropertyType().getName(); } catch (ClassNotFoundException e) { log.error(e.getLocalizedMessage(), e); } } else { sb1.append("getProperty("); sb1.append(lastIndexValue); sb1.append(","); sb1.append("\""); sb1.append(subChild.getImage()); sb1.append("\")"); } } else if (subChild instanceof AstBracketSuffix) { String bracketSuffix = processingBracketSuffix((AstBracketSuffix) subChild, componentBean); if (lastVariableType != null) { StringBuffer tmpbuf = new StringBuffer(); if (lastVariableType.startsWith("[L")) { tmpbuf.append("["); tmpbuf.append(bracketSuffix); tmpbuf.append("]"); names.add(tmpbuf.toString()); } if ((lastVariableType.compareTo("java.util.List") == 0) || (lastVariableType.compareTo("java.util.Map") == 0)) { tmpbuf.append("get("); tmpbuf.append(bracketSuffix); tmpbuf.append(")"); names.add(tmpbuf.toString()); } } else { sb1.append("getElelmentByIndex("); sb1.append(lastIndexValue); sb1.append(","); sb1.append(bracketSuffix); sb1.append(")"); } } } if (names.size() != 0) { StringBuffer tmpbuf = new StringBuffer(); for (String element : names) { if (tmpbuf.length() != 0) { tmpbuf.append("."); } tmpbuf.append(element); } sb.append(tmpbuf.toString()); } else { sb.append(lastIndexValue); } return true; }
From source file:org.rhq.enterprise.gui.common.paging.PageControlELResolver.java
@Override public Object getValue(ELContext context, Object base, Object property) { if (context == null) { throw new NullPointerException("ELContext was null for getValue method in PageControlELResolver"); }// w w w . ja va 2 s . c om Object result = null; if (base == null) { // Resolving first two variables (e.g. ${PageControlView.something}). String propertyName = (String) property; if ("PageControl".equals(propertyName)) { result = PageControlView.class; context.setPropertyResolved(true); } } else if (PageControlView.class.equals(base)) { // Getting a specific PageControlView instance String viewName = property.toString(); result = PageControlView.valueOf(viewName); context.setPropertyResolved(true); } else if (base instanceof PageControlView) { // cast to required types PageControlView view = (PageControlView) base; String methodName = (String) property; String lowerCaseMethodName = methodName.toLowerCase(); log.debug("accessing PageControl." + methodName); // allows simple misspellings for developer productivity if ("pagesize".equals(lowerCaseMethodName)) { // find the user for this session-based operation WebUser user = EnterpriseFacesContextUtility.getWebUser(); WebUserPreferences preferences = user.getWebPreferences(); // get it PageControl pc = preferences.getPageControl(view); if (log.isDebugEnabled()) { log.debug("Getting PageControlView[" + view + "] to " + pc); } result = pc.getPageSize(); } else if ("pagenumber".equals(lowerCaseMethodName)) { // find the user for this session-based operation WebUser user = EnterpriseFacesContextUtility.getWebUser(); WebUserPreferences preferences = user.getWebPreferences(); // get it PageControl pc = preferences.getPageControl(view); if (log.isDebugEnabled()) { log.debug("Getting PageControlView[" + view + "] to " + pc); } result = pc.getPageNumber() + 1; // RF data table is 1-based, our PageControl is 0-based } else if ("unlimited".equals(lowerCaseMethodName)) { result = view.isUnlimited(); } else { throw new PropertyNotFoundException( "The " + methodName + " property of a PageControl object is not accessible"); } // don't let other resolvers touch this context.setPropertyResolved(true); } return result; }
From source file:org.rhq.enterprise.gui.common.paging.PageControlELResolver.java
@Override public void setValue(ELContext context, Object base, Object property, Object value) { if (context == null) { throw new NullPointerException("ELContext was null for setValue method in PageControlELResolver"); }//from w w w .j a va 2 s . co m if (base instanceof PageControlView) { // cast to required types PageControlView view = (PageControlView) base; String methodName = (String) property; String lowerCaseMethodName = methodName.toLowerCase(); // allows simple mispellings for developer productivity if ("pagesize".equals(lowerCaseMethodName)) { if (value != null) { // find the user for this session-based operation WebUser user = EnterpriseFacesContextUtility.getWebUser(); WebUserPreferences preferences = user.getWebPreferences(); // update it PageControl pc = preferences.getPageControl(view); int pageSize = (Integer) value; if (pc.getPageSize() == pageSize) { // nothing to do if (log.isDebugEnabled()) { log.debug("PageControlView[" + view + "] needs no changes " + pc); } } else { pc.setPageSize(pageSize); pc.setPageNumber(0); // reset the page number too if (log.isDebugEnabled()) { log.debug("Setting PageControlView[" + view + "] to " + pc); } preferences.setPageControl(view, pc); } } // don't let other resolvers touch this context.setPropertyResolved(true); } else if ("pagenumber".equals(lowerCaseMethodName)) { if (value != null) { // find the user for this session-based operation WebUser user = EnterpriseFacesContextUtility.getWebUser(); WebUserPreferences preferences = user.getWebPreferences(); // update it PageControl pc = preferences.getPageControl(view); int pageNumber = (Integer) value; pc.setPageNumber(pageNumber - 1); // RF data table is 1-based, our PageControl is 0-based if (log.isDebugEnabled()) { log.debug("Setting PageControlView[" + view + "] to " + pc); } preferences.setPageControl(view, pc); } // don't let other resolvers touch this context.setPropertyResolved(true); } else { throw new PropertyNotFoundException( "The " + methodName + " property of a PageControl object can not be set, only pageSize"); } } }