Esempio n. 1
0
 /**
  * * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
  * javax.faces.component.UIComponent)
  */
 public void apply(FaceletContext ctx, UIComponent parent)
     throws IOException, FacesException, FaceletException, ELException {
   VariableMapper origVarMap = ctx.getVariableMapper();
   try {
     VariableMapperWrapper variableMap = new VariableMapperWrapper(origVarMap);
     ctx.setVariableMapper(variableMap);
     if (methodBindings != null) {
       String value = (String) methodBindings.getValue(ctx);
       Matcher match = METHOD_PATTERN.matcher(value);
       while (match.find()) {
         String var = match.group(1);
         ValueExpression currentExpression = origVarMap.resolveVariable(var);
         if (currentExpression != null) {
           try {
             FunctionMethodData methodData =
                 new FunctionMethodData(var, match.group(2).split("\\s+"));
             MethodExpression mexpr =
                 buildMethodExpression(ctx, currentExpression.getExpressionString(), methodData);
             variableMap.setVariable(var, new MethodValueExpression(currentExpression, mexpr));
           } catch (Exception ex) {
             throw new FacesException(ex);
           }
         }
       }
     }
     componentHandler.apply(ctx, parent);
   } finally {
     ctx.setVariableMapper(origVarMap);
   }
 }
Esempio n. 2
0
 private MethodExpression buildMethodExpression(
     FaceletContext ctx, String expression, FunctionMethodData methodData)
     throws NoSuchMethodException, ClassNotFoundException {
   return ctx.getExpressionFactory()
       .createMethodExpression(
           ctx, expression, methodData.getReturnType(), methodData.getArguments());
 }
Esempio n. 3
0
 /** Returns a id unique within the facelet context. */
 public String generateUniqueId() {
   String id;
   TagAttribute idAttr = tagConfig.getTag().getAttributes().get("id");
   if (idAttr != null) {
     id = idAttr.getValue(context);
   } else {
     id = context.getFacesContext().getViewRoot().createUniqueId();
   }
   return generateUniqueId(id);
 }
Esempio n. 4
0
 @Override
 public void apply(FaceletContext ctx, UIComponent parent)
     throws IOException, FacesException, ELException {
   boolean b = this.test.getBoolean(ctx);
   if (this.var != null) {
     ctx.setAttribute(var.getValue(ctx), new Boolean(b));
   }
   if (b) {
     this.nextHandler.apply(ctx, parent);
   }
 }
Esempio n. 5
0
 /** Returns a id unique within the facelet context using given id as base. */
 @SuppressWarnings({"unchecked", "rawtypes"})
 public String generateUniqueId(String base) {
   Map<String, Object> requestMap = context.getFacesContext().getExternalContext().getRequestMap();
   Map<String, Integer> counters = (Map) requestMap.get(LAYOUT_ID_COUNTERS);
   if (counters == null) {
     counters = new HashMap<String, Integer>();
   }
   String generatedId;
   Integer cnt = counters.get(base);
   if (cnt == null) {
     counters.put(base, new Integer(0));
     generatedId = base;
   } else {
     int i = cnt.intValue() + 1;
     counters.put(base, new Integer(i));
     generatedId = base + "_" + i;
   }
   requestMap.put(LAYOUT_ID_COUNTERS, counters);
   return generatedId;
 }
 protected Validator createValidator(FaceletContext faceletsContext) {
   FacesContext facesContext = faceletsContext.getFacesContext();
   Application application = facesContext.getApplication();
   return application.createValidator(getValidatorId());
 }