private UIComponent createDateTimeFields(
      FacesContext context, final EventEditorDialog dialog, final String idPrefix) {

    DateChooser dateField =
        Components.getOrCreateFacet(
            context, dialog, DateChooser.COMPONENT_TYPE, idPrefix + "DateField", DateChooser.class);
    HtmlOutputText nbsp = Components.createOutputText(context, HTML.NBSP_ENTITY, false);
    UIInput timeField =
        Components.getOrCreateFacet(
            context, dialog, HtmlInputText.COMPONENT_TYPE, idPrefix + "TimeField", UIInput.class);
    String timeCls =
        Styles.mergeClassNames(
            (String) timeField.getAttributes().get("styleClass"), "o_eventEditor_timeField");
    timeField.getAttributes().put("styleClass", timeCls);

    final UIComponent[][] components = new UIComponent[][] {{dateField, nbsp, timeField}};

    return new UIComponentBase() {
      @Override
      public String getFamily() {
        return null;
      }

      @Override
      public void encodeBegin(FacesContext context) throws IOException {
        new TableRenderer(idPrefix + "Fields", 0, 0, 0, null).render(dialog, components);
      }
    };
  }
Esempio n. 2
0
 public String getWrapperTagName() {
   String defaultWrapperTagName = null;
   boolean idSpecified = Components.isComponentIdSpecified(this);
   if (idSpecified || (getStyle() != null) || (getStyleClass() != null))
     defaultWrapperTagName = DEFAULT_WRAPPER_TAG_NAME;
   return ValueBindings.get(this, "wrapperTagName", wrapperTagName, defaultWrapperTagName);
 }
 private HtmlOutputText createLabelComponent(
     FacesContext context, EventEditorDialog dialog, String id, String text) {
   HtmlOutputText outputText = Components.composeHtmlOutputText(context, dialog, id, text);
   outputText.setStyle(dialog.getLabelStyle());
   outputText.setStyleClass(dialog.getLabelClass());
   return outputText;
 }
 private UIComponent getNameField(FacesContext context, EventEditorDialog dialog) {
   UIInput nameField =
       Components.getOrCreateFacet(
           context, dialog, HtmlInputText.COMPONENT_TYPE, "nameField", UIInput.class);
   nameField.getAttributes().put("styleClass", "o_fullWidth");
   return nameField;
 }
 private UIComponent getDescriptionField(FacesContext context, EventEditorDialog dialog) {
   UIInput descriptionField =
       Components.getOrCreateFacet(
           context, dialog, HtmlInputTextarea.COMPONENT_TYPE, "descriptionArea", UIInput.class);
   descriptionField.getAttributes().put("styleClass", "o_fullWidthAndHeight");
   descriptionField.getAttributes().put("style", "resize: none");
   return descriptionField;
 }
Esempio n. 6
0
 public void createSubComponents(FacesContext context) {
   Components.getOrCreateFacet(
       context,
       this,
       ImageExpansionToggle.COMPONENT_TYPE,
       "expansionToggle",
       ImageExpansionToggle.class);
 }
  private UIComponent getResourceField(FacesContext context, EventEditorDialog dialog) {
    DropDownField field =
        Components.getOrCreateFacet(
            context, dialog, DropDownField.COMPONENT_TYPE, "resourceField", DropDownField.class);

    List<TimetableResource> resources =
        (List<TimetableResource>)
            dialog.getAttributes().get(DayTableRenderer.EVENTEDITOR_RESOURCES_ATTR);
    for (TimetableResource resource : resources) {
      field.getChildren().add(new DropDownItem(resource.getName()));
    }

    field.setCustomValueAllowed(false);
    return field;
  }
Esempio n. 8
0
  public void setupCurrentRowVariables() {
    if (_evaluatingConverterInsideSetupCurrentRowVariables) {
      // Prevent endless recursion in the column.getGroupingValueConverter() call (see below).
      // The grouping-related variables are not required during calculation of
      // groupingValueConverter,
      // so we can just skip this method if _evaluatingConverterInsideSetupCurrentRowVariables ==
      // true
      return;
    }
    DataTable dataTable = getDataTable();
    Object rowData = dataTable.isRowAvailable() ? dataTable.getRowData() : null;
    if (!(rowData instanceof GroupHeaderOrFooter)) {
      Components.setRequestVariable(getColumnHeaderVar(), null);
      Components.setRequestVariable(getGroupingValueVar(), null);
      Components.setRequestVariable(getGroupingValueStringVar(), null);
      return;
    }

    GroupHeaderOrFooter row = (GroupHeaderOrFooter) rowData;
    RowGroup rowGroup = row.getRowGroup();

    String columnId = rowGroup.getColumnId();
    Column column = (Column) dataTable.getColumnById(columnId);

    String columnHeader = column.getColumnHeader();
    Components.setRequestVariable(getColumnHeaderVar(), columnHeader);

    Object groupingValue = rowGroup.getGroupingValue();
    Components.setRequestVariable(getGroupingValueVar(), groupingValue);

    Converter groupingValueConverter;
    _evaluatingConverterInsideSetupCurrentRowVariables = true;
    // The upcoming getGroupingValueConverter call can invoke table's setRowIndex, which will result
    // re-entering this setupCurrentRowVariables method, so we should prevent endless recursion
    // here.
    try {
      groupingValueConverter = column.getGroupingValueConverter();
    } finally {
      _evaluatingConverterInsideSetupCurrentRowVariables = false;
    }
    FacesContext context = FacesContext.getCurrentInstance();
    if (groupingValueConverter == null) {
      groupingValueConverter =
          groupingValue != null
              ? Rendering.getConverterForType(context, groupingValue.getClass())
              : null;
    }
    String groupingValueStr =
        groupingValueConverter != null
            ? groupingValueConverter.getAsString(context, column, groupingValue)
            : groupingValue != null ? groupingValue.toString() : "";
    Components.setRequestVariable(getGroupingValueStringVar(), groupingValueStr);
  }
 public ClientValidationMode getClientValidationRule(
     UIComponent component, UIComponent forComponent) {
   ClientValidationMode cv = null;
   if (forComponent != null) {
     String clientValidationAttribute =
         (String) forComponent.getAttributes().get("clientValidation");
     if (clientValidationAttribute != null) {
       cv = ClientValidationMode.fromString(clientValidationAttribute);
     }
   }
   if (cv == null) {
     UIForm form = Components.getEnclosingForm(component);
     cv = getClientValidationRuleForForm(form);
   }
   if (cv == null) {
     cv = getClientValidationRuleForApplication();
   }
   return cv;
 }
Esempio n. 10
0
 public Collection<Marker> getMarkers() {
   return Components.findChildrenWithClass(this, Marker.class);
 }
Esempio n. 11
0
  @Override
  public void renderView(FacesContext context, UIViewRoot root) throws IOException, FacesException {
    Components.runScheduledActions();
    if (!context.getResponseComplete()) {

      ExternalContext externalContext = context.getExternalContext();
      Object session = externalContext.getSession(false);
      Map<String, Object> requestMap = externalContext.getRequestMap();

      if (externalContext.getSessionMap().containsKey(ERROR_OCCURRED_UNDER_PORTLETS)) {
        processExceptionUnderPortlets(context);
        return;
      }

      if (AjaxUtil.isPortletRequest(context)
          && Environment.isMyFaces()
          && isNewSession(externalContext.getSession(false))) {
        processSessionExpirationUnderPortletsMyFaces(context, root, externalContext, session);
      }

      if (AjaxUtil.isPortletRequest(context)
          && Environment.isRI()
          && isNewSession(externalContext.getSession(false))) {
        processSessionExpirationUnderPortletsRI(context, root, externalContext);
      }

      boolean ajaxRequest = AjaxUtil.isAjaxRequest(context);
      if (!ajaxRequest && !AjaxUtil.isAjax4jsfRequest())
        ValidationSupportResponseWriter.resetBubbleIndex(context);

      if (ajaxRequest) {
        updateSessionExpirationFlagUnderPortlets(context, root, externalContext, requestMap);
        try {
          // HACK for MyFaces ( <f:view> tag not call renderers )
          // ServletResponse response = (ServletResponse) context
          //		.getExternalContext().getResponse();
          Object response = externalContext.getResponse();

          if (!AjaxUtil.isPortletRequest(context)) {
            try {
              response.getClass().getDeclaredMethod("resetResponse").invoke(response);
              // response.reset();
            } catch (Exception e) {
              // Do nothing - we will use directly and reset
              // wrapper
            }
          }

          if (requestMap.containsKey(SESSION_EXPIRATION_PROCESSING)) {
            super.renderView(context, root);
            // This is done for MyFaces use-case, because MyFaces doesn't call rendering methods for
            // ViewRoot
            if (!Environment.isRI()) {
              root.encodeChildren(context);
            }
            Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
            if (sessionMap != null && !sessionMap.containsKey(SESSION_SCOPED_PARAMETER)) {
              sessionMap.put(SESSION_SCOPED_PARAMETER, Boolean.TRUE.toString());
            }
            return;
          }

          if (Environment.isFacelets(context)) {
            super.renderView(context, root);
          } else {
            root.encodeBegin(context);
            if (root.getRendersChildren()) {
              root.encodeChildren(context);
            }
            root.encodeEnd(context);
          }
        } catch (RuntimeException e) {
          CommonAjaxViewRoot.processExceptionDuringAjax(context, e);
          externalContext.log(e.getMessage(), e);
        } catch (Error e) {
          CommonAjaxViewRoot.processExceptionDuringAjax(context, e);
          externalContext.log(e.getMessage(), e);
        }

      } else {

        super.renderView(context, root);
        Map<String, Object> sessionMap = context.getExternalContext().getSessionMap();
        if (sessionMap != null && !sessionMap.containsKey(SESSION_SCOPED_PARAMETER)) {
          sessionMap.put(SESSION_SCOPED_PARAMETER, Boolean.TRUE.toString());
        }

        if (AjaxUtil.isAjax4jsfRequest()) {
          Resources.processHeadResources(context);
        }
      }
    }
  }
Esempio n. 12
0
 protected DataTable getDataTable() {
   if (dataTable == null) {
     dataTable = (DataTable) Components.checkParentTag(this, DataTable.class);
   }
   return dataTable;
 }
Esempio n. 13
0
 @Override
 public void processDecodes(FacesContext context) {
   Components.runScheduledActions();
   commonAjaxViewRoot.processDecodes(context, false);
 }
Esempio n. 14
0
 @Override
 public void encodeAll(FacesContext context) throws IOException {
   Components.runScheduledActions();
   super.encodeAll(context);
 }