Example #1
0
 @Override
 public void restoreState(FacesContext facesContext, Object object) {
   Object[] state = (Object[]) object;
   int i = 0;
   super.restoreState(facesContext, state[i++]);
   clientFunction = (String) UIComponentBase.restoreAttachedState(facesContext, state[i++]);
   serverFunction =
       (MethodExpression) UIComponentBase.restoreAttachedState(facesContext, state[i++]);
 }
Example #2
0
  @Override
  public Object saveState(FacesContext facesContext) {
    Object superState = super.saveState(facesContext);

    return new Object[] {
      superState,
      UIComponentBase.saveAttachedState(facesContext, clientFunction),
      UIComponentBase.saveAttachedState(facesContext, serverFunction),
    };
  }
Example #3
0
 @Override
 public void restoreState(FacesContext context, Object stateObj) {
   Object[] state = (Object[]) stateObj;
   int i = 0;
   super.restoreState(context, state[i++]);
   style = (String) state[i++];
   styleClass = (String) state[i++];
   activeLinkStyle = (String) state[i++];
   activeLinkClass = (String) state[i++];
   inactiveLinkStyle = (String) state[i++];
   inactiveLinkClass = (String) state[i++];
   currentPageLinkStyle = (String) state[i++];
   currentPageLinkClass = (String) state[i++];
   showIfOnePage = (Boolean) state[i++];
   showPageCount = (Boolean) state[i++];
   pageCountPreposition = (String) state[i++];
   pageNumberFieldStyle = (String) state[i++];
   pageNumberFieldClass = (String) state[i++];
   firstImageUrl = (String) state[i++];
   lastImageUrl = (String) state[i++];
   previousImageUrl = (String) state[i++];
   nextImageUrl = (String) state[i++];
   firstText = (String) state[i++];
   lastText = (String) state[i++];
   previousText = (String) state[i++];
   nextText = (String) state[i++];
   pageNumberPrefix = (String) state[i++];
   firstDisabledImageUrl = (String) state[i++];
   lastDisabledImageUrl = (String) state[i++];
   previousDisabledImageUrl = (String) state[i++];
   nextDisabledImageUrl = (String) state[i++];
   showDisabledImages = (Boolean) state[i++];
 }
  @Override
  public void broadcast(FacesEvent event) throws AbortProcessingException {
    super.broadcast(event);

    if (event instanceof DropEvent && (isBypassUpdates() || isImmediate())) {
      FacesContext.getCurrentInstance().renderResponse();
    }
  }
 /** 6 - Render response {@inheritDoc} */
 @Override
 public void encodeBegin(FacesContext context) throws IOException {
   log.info("***********");
   log.info("encodeBegin :");
   printMessagesAssociatedWithComponents(context);
   printMessages(context);
   log.info("***********");
   super.encodeBegin(context);
 }
 @Override
 public void decode(FacesContext context) {
   super.decode(context);
   final String paramValue =
       context.getExternalContext().getRequestParameterMap().get(getClientId(context));
   if (paramValue != null) {
     new FormChageEvent(this).queue();
   }
 }
 @Override
 public void broadcast(FacesEvent event) {
   super.broadcast(event);
   if (this.equals(event.getComponent()) && event instanceof FormChageEvent) {
     MethodExpression listener = (MethodExpression) getAttributes().get("listener");
     if (listener != null) {
       listener.invoke(FacesContext.getCurrentInstance().getELContext(), null);
     }
   }
 }
Example #8
0
  @Override
  public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
    super.processEvent(event);

    if (!(event instanceof PreRenderComponentEvent) || !getLayout().isBuildOptions()) {
      return;
    }

    setOptions(getParent());
  }
 @Override
 public void restoreState(FacesContext context, Object state) {
   Object[] stateArray = (Object[]) state;
   int i = 0;
   super.restoreState(context, stateArray[i++]);
   applicationClientValidation = ClientValidationMode.fromString((String) stateArray[i++]);
   useDefaultServerValidationPresentationForApplication = (Boolean) stateArray[i++];
   useDefaultClientValidationPresentationForApplication = (Boolean) stateArray[i++];
   defaultPresentationInstance = (UIMessage) restoreAttachedState(context, stateArray[i++]);
 }
 private static List<String> createMustacheKeysFromTemplate(
     FacesContext context, UIComponentBase component, String facetKey) throws IOException {
   final UIComponent templateFacet = component.getFacet(facetKey);
   if (templateFacet != null) {
     final String encodedTemplate =
         StringHtmlEncoder.encodeComponentWithSurroundingDiv(context, templateFacet);
     return MustacheResolver.getMustacheKeysForTreeNode(encodedTemplate);
   } else {
     return Collections.emptyList();
   }
 }
Example #11
0
 @Override
 public void restoreState(FacesContext context, Object state) {
   Object[] stateArray = (Object[]) state;
   int i = 0;
   super.restoreState(context, stateArray[i++]);
   onerror = (String) stateArray[i++];
   onsuccess = (String) stateArray[i++];
   onsessionexpired = (String) stateArray[i++];
   onajaxstart = (String) stateArray[i++];
   onajaxend = (String) stateArray[i++];
 }
  public void decode(FacesContext context) {
    super.decode(context);

    value = getValueBinding("value");

    HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
    values = (String[]) request.getParameterValues(getClientId(context) + "_multiInput");

    value.setValue(context, values);
    postMode = true;
  }
  /** 1 - Restore View {@inheritDoc} */
  @Override
  public void restoreState(FacesContext context, Object state) {

    values = (Object[]) state;
    log.info(
        "UIOtp.restoreState() "
            + ArrayUtils.toString(ArrayUtils.subarray(values, 1, values.length)));

    super.restoreState(context, values[0]);
    forComponents = (String) values[1];
  }
  @Override
  public void queueEvent(FacesEvent event) {
    if (event instanceof DropEvent) {

      if (isImmediate()) {
        event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
      } else if (isBypassUpdates()) {
        event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
      } else {
        event.setPhaseId(PhaseId.INVOKE_APPLICATION);
      }
    }
    super.queueEvent(event);
  }
Example #15
0
  // Utility for restoring bindings from state
  private static Map<String, ValueExpression> restoreBindings(FacesContext context, Object state) {

    // Note: This code is copied from UIComponentBase.  See note above
    // in saveBindings().

    if (state == null) {
      return (null);
    }
    Object values[] = (Object[]) state;
    String names[] = (String[]) values[0];
    Object states[] = (Object[]) values[1];
    Map<String, ValueExpression> bindings = new HashMap<String, ValueExpression>(names.length);
    for (int i = 0; i < names.length; i++) {
      bindings.put(
          names[i], (ValueExpression) UIComponentBase.restoreAttachedState(context, states[i]));
    }
    return (bindings);
  }
  public void broadcast(FacesEvent event) throws AbortProcessingException {
    if (event instanceof DataScrollEvent) {
      DataScrollEvent dataScrollerEvent = (DataScrollEvent) event;

      updateModel(dataScrollerEvent.getPage());

      FacesContext facesContext = getFacesContext();

      UIComponent dataTable = getDataTable();

      List<AbstractDataScroller> dataScrollers = DataScrollerUtils.findDataScrollers(dataTable);
      for (AbstractDataScroller dataScroller : dataScrollers) {
        facesContext
            .getPartialViewContext()
            .getRenderIds()
            .add(dataScroller.getClientId(facesContext));
      }

      String dataTableId = null;
      if (dataTable instanceof MetaComponentResolver
          && !(dataTable instanceof UIDataTableBase
              && ((UIDataTableBase) dataTable).hasRowChildren())) {
        dataTableId =
            ((MetaComponentResolver) dataTable).resolveClientId(facesContext, dataTable, "body");
      }

      if (dataTableId == null) {
        dataTableId = dataTable.getClientId(facesContext);
      }

      facesContext.getPartialViewContext().getRenderIds().add(dataTableId);

      // add datascroller to render
      String dataScrollerId = getClientId(facesContext);
      if (!facesContext.getPartialViewContext().getRenderIds().contains(dataScrollerId)) {
        facesContext.getPartialViewContext().getRenderIds().add(dataScrollerId);
      }
    }

    super.broadcast(event);
  }
Example #17
0
  // Utility for saving bindings state
  private static Object saveBindings(FacesContext context, Map<String, ValueExpression> bindings) {

    // Note: This code is copied from UIComponentBase.  In a future
    // version of the JSF spec, it would be useful to define a
    // attribute/property/bindings/state helper object that can be
    // shared across components/behaviors/validaters/converters.

    if (bindings == null) {
      return (null);
    }

    Object values[] = new Object[2];
    values[0] = bindings.keySet().toArray(new String[bindings.size()]);

    Object[] bindingValues = bindings.values().toArray();
    for (int i = 0; i < bindingValues.length; i++) {
      bindingValues[i] = UIComponentBase.saveAttachedState(context, bindingValues[i]);
    }

    values[1] = bindingValues;

    return (values);
  }
  @Override
  public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
    super.processEvent(event);

    if (event instanceof PostAddToViewEvent) {
      String queueId = getClientId();

      if (componentsToAssociate != null) {
        for (UIComponent componentToAssociate : componentsToAssociate) {
          immediateAssociateWith(componentToAssociate, queueId);
        }

        componentsToAssociate = null;
      }

      if (behaviorsToAssociate != null) {
        for (AjaxBehavior ajaxBehavior : behaviorsToAssociate) {
          immediateAssociateWith(ajaxBehavior, queueId);
        }

        behaviorsToAssociate = null;
      }
    }
  }
Example #19
0
 @Override
 public void restoreState(FacesContext context, Object stateObj) {
   Object[] state = (Object[]) stateObj;
   int i = 0;
   super.restoreState(context, state[i++]);
 }