Examples of UISelectManyShuttle


Examples of org.apache.myfaces.tobago.component.UISelectManyShuttle

public class SelectManyShuttleRenderer extends SelectManyRendererBase {

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
    UISelectManyShuttle select = (UISelectManyShuttle) component;
    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlElements.DIV, select);
    Style style = new Style(facesContext, select);
    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select));
    String clientId = select.getClientId(facesContext);
    writer.writeIdAttribute(clientId);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, select);
    String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    boolean hasLabel = select.hasLabel();
    // TODO get buttonWidth and label Height from theme
    Measure buttonWidth = Measure.valueOf(50);

    Measure labelHeight = Measure.valueOf(18);
    style.setTop(Measure.valueOf(0));
    style.setLeft(Measure.valueOf(0));
    Measure width = style.getWidth();
    Measure selectWidth = width.subtract(buttonWidth).divide(2);
    style.setWidth(selectWidth);
    Style labelStyle = null;
    if (hasLabel) {
      labelStyle = new Style(style);
      labelStyle.setHeight(labelHeight);
      style.setHeight(style.getHeight().subtract(labelHeight));
      style.setTop(style.getTop().add(labelHeight));
    }
    List<SelectItem> items = RenderUtils.getSelectItems(select);
    boolean disabled = items.size() == 0 || select.isDisabled() || select.isReadonly();

    String unselectedLabel = select.getUnselectedLabel();
    if (unselectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "unselectedLabel"));
      writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
      writer.write(unselectedLabel);
      writer.endElement(HtmlElements.DIV);
    }
    writer.startElement(HtmlElements.SELECT, null);
    String unselectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "unselected";
    writer.writeIdAttribute(unselectedClientId);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);

    // TODO tabIndex
    Integer tabIndex = select.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }

    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select, "unselected"));

    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);

    Object[] values = select.getSelectedValues();
    HtmlRendererUtils.renderSelectItems(select, items, values, false, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
    writer.startElement(HtmlElements.DIV, null);
    style.setLeft(style.getLeft().add(selectWidth));
    style.setWidth(buttonWidth);
    writer.writeStyleAttribute(style);
    writer.startElement(HtmlElements.DIV, null);
    writer.writeClassAttribute(Classes.create(select, "toolBar"));
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleAddAll.gif", "addAll");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleAdd.gif", "add");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleRemove.gif", "remove");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleRemoveAll.gif", "removeAll");
    writer.endElement(HtmlElements.DIV);
    writer.endElement(HtmlElements.DIV);
    String selectedLabel = select.getSelectedLabel();
    if (selectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      labelStyle.setLeft(labelStyle.getLeft().add(selectWidth).add(buttonWidth));
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "selectedLabel"));
      writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
      writer.write(selectedLabel);
      writer.endElement(HtmlElements.DIV);
    }

    writer.startElement(HtmlElements.SELECT, select);
    String selectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "selected";
    writer.writeIdAttribute(selectedClientId);

    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }
    style.setWidth(selectWidth);
    style.setLeft(style.getLeft().add(buttonWidth));
    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select, "selected"));
    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);
    HtmlRendererUtils.renderSelectItems(select, items, values, true, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
    writer.startElement(HtmlElements.SELECT, select);
    writer.writeClassAttribute(Classes.create(component, "hidden"));
    String hiddenClientId = clientId + ComponentUtils.SUB_SEPARATOR + "hidden";
    writer.writeIdAttribute(hiddenClientId);
    writer.writeNameAttribute(clientId);
    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);
    writer.writeAttribute(HtmlAttributes.REQUIRED, select.isRequired());
    HtmlRendererUtils.renderCommandFacet(select, facesContext, writer);
    HtmlRendererUtils.renderSelectItems(select, items, values, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UISelectManyShuttle

  }

  @Override
  protected void setProperties(final UIComponent uiComponent) {
    super.setProperties(uiComponent);
    final UISelectManyShuttle component = (UISelectManyShuttle) uiComponent;
    final FacesContext context = FacesContext.getCurrentInstance();
    final Application application = context.getApplication();
    if (validatorMessage != null) {
      component.setValueExpression("validatorMessage", validatorMessage);
    }

    if (markup != null) {
      if (!markup.isLiteralText()) {
        component.setValueExpression("markup", markup);
      } else {
        component.setMarkup(org.apache.myfaces.tobago.context.Markup.valueOf(markup.getExpressionString()));
      }
    }
    if (tabIndex != null) {
      if (!tabIndex.isLiteralText()) {
        component.setValueExpression("tabIndex", tabIndex);
      } else {
        component.setTabIndex(Integer.parseInt(tabIndex.getExpressionString()));
      }
    }
    if (validator != null) {
      component.addValidator(new javax.faces.validator.MethodExpressionValidator(validator));
    }
    if (unselectedLabel != null) {
      component.setValueExpression("unselectedLabel", unselectedLabel);
    }

    if (tip != null) {
      component.setValueExpression("tip", tip);
    }

    if (valueChangeListener != null) {
      component.addValueChangeListener(new javax.faces.event.MethodExpressionValueChangeListener(valueChangeListener));
    }
    if (converter != null) {
      if (!converter.isLiteralText()) {
        component.setValueExpression("converter", converter);
      } else {
        component.setConverter(application.createConverter(converter.getExpressionString()));
      }
    }
    if (value != null) {
      component.setValueExpression("value", value);
    }

    if (focus != null) {
      if (!focus.isLiteralText()) {
        component.setValueExpression("focus", focus);
      } else {
        component.setFocus(Boolean.parseBoolean(focus.getExpressionString()));
      }
    }
    if (selectedLabel != null) {
      component.setValueExpression("selectedLabel", selectedLabel);
    }

    if (required != null) {
      if (!required.isLiteralText()) {
        component.setValueExpression("required", required);
      } else {
        component.setRequired(Boolean.parseBoolean(required.getExpressionString()));
      }
    }
    if (converterMessage != null) {
      component.setValueExpression("converterMessage", converterMessage);
    }

    if (label != null) {
      component.setValueExpression("label", label);
    }

    if (requiredMessage != null) {
      component.setValueExpression("requiredMessage", requiredMessage);
    }

    if (onchange != null) {
      component.setValueExpression("onchange", onchange);
    }

    if (readonly != null) {
      if (!readonly.isLiteralText()) {
        component.setValueExpression("readonly", readonly);
      } else {
        component.setReadonly(Boolean.parseBoolean(readonly.getExpressionString()));
      }
    }
    if (disabled != null) {
      if (!disabled.isLiteralText()) {
        component.setValueExpression("disabled", disabled);
      } else {
        component.setDisabled(Boolean.parseBoolean(disabled.getExpressionString()));
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UISelectManyShuttle

public class SelectManyShuttleRenderer extends SelectManyRendererBase {

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
    UISelectManyShuttle select = (UISelectManyShuttle) component;
    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlElements.DIV, select);
    Style style = new Style(facesContext, select);
    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select));
    String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    boolean hasLabel = select.hasLabel();
    // TODO get buttonWidth and label Height from theme
    Measure buttonWidth = Measure.valueOf(50);

    Measure labelHeight = Measure.valueOf(18);
    style.setTop(Measure.valueOf(0));
    style.setLeft(Measure.valueOf(0));
    Measure width = style.getWidth();
    Measure selectWidth = width.subtract(buttonWidth).divide(2);
    style.setWidth(selectWidth);
    Style labelStyle = null;
    if (hasLabel) {
      labelStyle = new Style(style);
      labelStyle.setHeight(labelHeight);
      style.setHeight(style.getHeight().subtract(labelHeight));
      style.setTop(style.getTop().add(labelHeight));
    }
    String clientId = select.getClientId(facesContext);
    List<SelectItem> items = RenderUtils.getSelectItems(select);
    boolean disabled = items.size() == 0 || select.isDisabled() || select.isReadonly();

    String unselectedLabel = select.getUnselectedLabel();
    if (unselectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "unselectedLabel"));
      writer.write(unselectedLabel);
      writer.endElement(HtmlElements.DIV);
    }
    writer.startElement(HtmlElements.SELECT, null);
    String unselectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "unselected";
    writer.writeIdAttribute(unselectedClientId);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);

    // TODO tabIndex
    Integer tabIndex = select.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }

    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select, "unselected"));

    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);

    Object[] values = select.getSelectedValues();
    HtmlRendererUtils.renderSelectItems(select, items, values, false, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
    writer.startElement(HtmlElements.DIV, null);
    style.setLeft(style.getLeft().add(selectWidth));
    style.setWidth(buttonWidth);
    writer.writeStyleAttribute(style);
    writer.startElement(HtmlElements.DIV, null);
    writer.writeClassAttribute(Classes.create(select, "toolBar"));
    createButton(facesContext, component, writer, disabled, ">>", "addAll");
    createButton(facesContext, component, writer, disabled, ">", "add");
    createButton(facesContext, component, writer, disabled, "<", "remove");
    createButton(facesContext, component, writer, disabled, "<<", "removeAll");
    writer.endElement(HtmlElements.DIV);
    writer.endElement(HtmlElements.DIV);
    String selectedLabel = select.getSelectedLabel();
    if (selectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      labelStyle.setLeft(labelStyle.getLeft().add(selectWidth).add(buttonWidth));
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "selectedLabel"));
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UISelectManyShuttle

public class SelectManyShuttleRenderer extends SelectManyRendererBase {

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
    UISelectManyShuttle select = (UISelectManyShuttle) component;
    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlElements.DIV, select);
    Style style = new Style(facesContext, select);
    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select));
    String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    boolean hasLabel = select.hasLabel();
    // TODO get buttonWidth and label Height from theme
    Measure buttonWidth = Measure.valueOf(50);

    Measure labelHeight = Measure.valueOf(18);
    style.setTop(Measure.valueOf(0));
    style.setLeft(Measure.valueOf(0));
    Measure width = style.getWidth();
    Measure selectWidth = width.subtract(buttonWidth).divide(2);
    style.setWidth(selectWidth);
    Style labelStyle = null;
    if (hasLabel) {
      labelStyle = new Style(style);
      labelStyle.setHeight(labelHeight);
      style.setHeight(style.getHeight().subtract(labelHeight));
      style.setTop(style.getTop().add(labelHeight));
    }
    String clientId = select.getClientId(facesContext);
    List<SelectItem> items = RenderUtils.getSelectItems(select);
    boolean disabled = items.size() == 0 || select.isDisabled() || select.isReadonly();

    String unselectedLabel = select.getUnselectedLabel();
    if (unselectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "unselectedLabel"));
      writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
      writer.write(unselectedLabel);
      writer.endElement(HtmlElements.DIV);
    }
    writer.startElement(HtmlElements.SELECT, null);
    String unselectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "unselected";
    writer.writeIdAttribute(unselectedClientId);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);

    // TODO tabIndex
    Integer tabIndex = select.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }

    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select, "unselected"));

    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);

    Object[] values = select.getSelectedValues();
    HtmlRendererUtils.renderSelectItems(select, items, values, false, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
    writer.startElement(HtmlElements.DIV, null);
    style.setLeft(style.getLeft().add(selectWidth));
    style.setWidth(buttonWidth);
    writer.writeStyleAttribute(style);
    writer.startElement(HtmlElements.DIV, null);
    writer.writeClassAttribute(Classes.create(select, "toolBar"));
    createButton(facesContext, component, writer, disabled, ">>", "addAll");
    createButton(facesContext, component, writer, disabled, ">", "add");
    createButton(facesContext, component, writer, disabled, "<", "remove");
    createButton(facesContext, component, writer, disabled, "<<", "removeAll");
    writer.endElement(HtmlElements.DIV);
    writer.endElement(HtmlElements.DIV);
    String selectedLabel = select.getSelectedLabel();
    if (selectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      labelStyle.setLeft(labelStyle.getLeft().add(selectWidth).add(buttonWidth));
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "selectedLabel"));
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UISelectManyShuttle

  }

  @Override
  protected void setProperties(final UIComponent uiComponent) {
    super.setProperties(uiComponent);
    final UISelectManyShuttle component = (UISelectManyShuttle) uiComponent;
    final FacesContext context = FacesContext.getCurrentInstance();
    final Application application = context.getApplication();
    if (validatorMessage != null) {
      component.setValueExpression("validatorMessage", validatorMessage);
    }

    if (markup != null) {
      if (!markup.isLiteralText()) {
        component.setValueExpression("markup", markup);
      } else {
        component.setMarkup(org.apache.myfaces.tobago.context.Markup.valueOf(markup.getExpressionString()));
      }
    }
    if (validator != null) {
      component.addValidator(new javax.faces.validator.MethodExpressionValidator(validator));
    }
    if (tabIndex != null) {
      if (!tabIndex.isLiteralText()) {
        component.setValueExpression("tabIndex", tabIndex);
      } else {
        component.setTabIndex(Integer.parseInt(tabIndex.getExpressionString()));
      }
    }
    if (unselectedLabel != null) {
      component.setValueExpression("unselectedLabel", unselectedLabel);
    }

    if (tip != null) {
      component.setValueExpression("tip", tip);
    }

    if (valueChangeListener != null) {
      component.addValueChangeListener(new javax.faces.event.MethodExpressionValueChangeListener(valueChangeListener));
    }
    if (converter != null) {
      if (!converter.isLiteralText()) {
        component.setValueExpression("converter", converter);
      } else {
        component.setConverter(application.createConverter(converter.getExpressionString()));
      }
    }
    if (value != null) {
      component.setValueExpression("value", value);
    }

    if (focus != null) {
      if (!focus.isLiteralText()) {
        component.setValueExpression("focus", focus);
      } else {
        component.setFocus(Boolean.parseBoolean(focus.getExpressionString()));
      }
    }
    if (selectedLabel != null) {
      component.setValueExpression("selectedLabel", selectedLabel);
    }

    if (required != null) {
      if (!required.isLiteralText()) {
        component.setValueExpression("required", required);
      } else {
        component.setRequired(Boolean.parseBoolean(required.getExpressionString()));
      }
    }
    if (converterMessage != null) {
      component.setValueExpression("converterMessage", converterMessage);
    }

    if (label != null) {
      component.setValueExpression("label", label);
    }

    if (requiredMessage != null) {
      component.setValueExpression("requiredMessage", requiredMessage);
    }

    if (onchange != null) {
      component.setValueExpression("onchange", onchange);
    }

    if (readonly != null) {
      if (!readonly.isLiteralText()) {
        component.setValueExpression("readonly", readonly);
      } else {
        component.setReadonly(Boolean.parseBoolean(readonly.getExpressionString()));
      }
    }
    if (disabled != null) {
      if (!disabled.isLiteralText()) {
        component.setValueExpression("disabled", disabled);
      } else {
        component.setDisabled(Boolean.parseBoolean(disabled.getExpressionString()));
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UISelectManyShuttle

public class SelectManyShuttleRenderer extends SelectManyRendererBase {

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
    UISelectManyShuttle select = (UISelectManyShuttle) component;
    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlElements.DIV, select);
    Style style = new Style(facesContext, select);
    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select));
    String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    boolean hasLabel = select.hasLabel();
    // TODO get buttonWidth and label Height from theme
    Measure buttonWidth = Measure.valueOf(50);

    Measure labelHeight = Measure.valueOf(18);
    style.setTop(Measure.valueOf(0));
    style.setLeft(Measure.valueOf(0));
    Measure width = style.getWidth();
    Measure selectWidth = width.subtract(buttonWidth).divide(2);
    style.setWidth(selectWidth);
    Style labelStyle = null;
    if (hasLabel) {
      labelStyle = new Style(style);
      labelStyle.setHeight(labelHeight);
      style.setHeight(style.getHeight().subtract(labelHeight));
      style.setTop(style.getTop().add(labelHeight));
    }
    String clientId = select.getClientId(facesContext);
    List<SelectItem> items = RenderUtils.getSelectItems(select);
    boolean disabled = items.size() == 0 || select.isDisabled() || select.isReadonly();

    String unselectedLabel = select.getUnselectedLabel();
    if (unselectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "unselectedLabel"));
      writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
      writer.write(unselectedLabel);
      writer.endElement(HtmlElements.DIV);
    }
    writer.startElement(HtmlElements.SELECT, null);
    String unselectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "unselected";
    writer.writeIdAttribute(unselectedClientId);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);

    // TODO tabIndex
    Integer tabIndex = select.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }

    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select, "unselected"));

    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);

    Object[] values = select.getSelectedValues();
    HtmlRendererUtils.renderSelectItems(select, items, values, false, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
    writer.startElement(HtmlElements.DIV, null);
    style.setLeft(style.getLeft().add(selectWidth));
    style.setWidth(buttonWidth);
    writer.writeStyleAttribute(style);
    writer.startElement(HtmlElements.DIV, null);
    writer.writeClassAttribute(Classes.create(select, "toolBar"));
    createButton(facesContext, component, writer, disabled, ">>", "addAll");
    createButton(facesContext, component, writer, disabled, ">", "add");
    createButton(facesContext, component, writer, disabled, "<", "remove");
    createButton(facesContext, component, writer, disabled, "<<", "removeAll");
    writer.endElement(HtmlElements.DIV);
    writer.endElement(HtmlElements.DIV);
    String selectedLabel = select.getSelectedLabel();
    if (selectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      labelStyle.setLeft(labelStyle.getLeft().add(selectWidth).add(buttonWidth));
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "selectedLabel"));
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UISelectManyShuttle

public class SelectManyShuttleRenderer extends SelectManyRendererBase {

  @Override
  public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {
    final UISelectManyShuttle select = (UISelectManyShuttle) component;
    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlElements.DIV, select);
    final Style style = new Style(facesContext, select);
    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select));
    final String clientId = select.getClientId(facesContext);
    writer.writeIdAttribute(clientId);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, select);
    final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    final boolean hasLabel = select.hasLabel();
    // TODO get buttonWidth and label Height from theme
    final Measure buttonWidth = Measure.valueOf(50);

    final Measure labelHeight = Measure.valueOf(18);
    style.setTop(Measure.valueOf(0));
    style.setLeft(Measure.valueOf(0));
    final Measure width = style.getWidth();
    final Measure selectWidth = width.subtract(buttonWidth).divide(2);
    style.setWidth(selectWidth);
    Style labelStyle = null;
    if (hasLabel) {
      labelStyle = new Style(style);
      labelStyle.setHeight(labelHeight);
      style.setHeight(style.getHeight().subtract(labelHeight));
      style.setTop(style.getTop().add(labelHeight));
    }
    final List<SelectItem> items = RenderUtils.getSelectItems(select);
    final boolean disabled = items.size() == 0 || select.isDisabled() || select.isReadonly();

    final String unselectedLabel = select.getUnselectedLabel();
    if (unselectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "unselectedLabel"));
      writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
      writer.write(unselectedLabel);
      writer.endElement(HtmlElements.DIV);
    }
    writer.startElement(HtmlElements.SELECT, null);
    final String unselectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "unselected";
    writer.writeIdAttribute(unselectedClientId);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);

    // TODO tabIndex
    final Integer tabIndex = select.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }

    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select, "unselected"));

    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);

    final Object[] values = select.getSelectedValues();
    HtmlRendererUtils.renderSelectItems(select, items, values, false, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
    writer.startElement(HtmlElements.DIV, null);
    style.setLeft(style.getLeft().add(selectWidth));
    style.setWidth(buttonWidth);
    writer.writeStyleAttribute(style);
    writer.startElement(HtmlElements.DIV, null);
    writer.writeClassAttribute(Classes.create(select, "toolBar"));
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleAddAll.gif", "addAll");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleAdd.gif", "add");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleRemove.gif", "remove");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleRemoveAll.gif", "removeAll");
    writer.endElement(HtmlElements.DIV);
    writer.endElement(HtmlElements.DIV);
    final String selectedLabel = select.getSelectedLabel();
    if (selectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      labelStyle.setLeft(labelStyle.getLeft().add(selectWidth).add(buttonWidth));
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "selectedLabel"));
      writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
      writer.write(selectedLabel);
      writer.endElement(HtmlElements.DIV);
    }

    writer.startElement(HtmlElements.SELECT, select);
    final String selectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "selected";
    writer.writeIdAttribute(selectedClientId);

    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }
    style.setWidth(selectWidth);
    style.setLeft(style.getLeft().add(buttonWidth));
    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select, "selected"));
    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);
    HtmlRendererUtils.renderSelectItems(select, items, values, true, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
    writer.startElement(HtmlElements.SELECT, select);
    writer.writeClassAttribute(Classes.create(component, "hidden"));
    final String hiddenClientId = clientId + ComponentUtils.SUB_SEPARATOR + "hidden";
    writer.writeIdAttribute(hiddenClientId);
    writer.writeNameAttribute(clientId);
    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);
    writer.writeAttribute(HtmlAttributes.REQUIRED, select.isRequired());
    HtmlRendererUtils.renderCommandFacet(select, facesContext, writer);
    HtmlRendererUtils.renderSelectItems(select, items, values, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UISelectManyShuttle

  }

  @Override
  protected void setProperties(final UIComponent uiComponent) {
    super.setProperties(uiComponent);
    final UISelectManyShuttle component = (UISelectManyShuttle) uiComponent;
    final FacesContext context = FacesContext.getCurrentInstance();
    final Application application = context.getApplication();
    if (validatorMessage != null) {
      component.setValueExpression("validatorMessage", validatorMessage);
    }

    if (markup != null) {
      if (!markup.isLiteralText()) {
        component.setValueExpression("markup", markup);
      } else {
        component.setMarkup(org.apache.myfaces.tobago.context.Markup.valueOf(markup.getExpressionString()));
      }
    }
    if (validator != null) {
      component.addValidator(new javax.faces.validator.MethodExpressionValidator(validator));
    }
    if (tabIndex != null) {
      if (!tabIndex.isLiteralText()) {
        component.setValueExpression("tabIndex", tabIndex);
      } else {
        component.setTabIndex(Integer.parseInt(tabIndex.getExpressionString()));
      }
    }
    if (unselectedLabel != null) {
      component.setValueExpression("unselectedLabel", unselectedLabel);
    }

    if (tip != null) {
      component.setValueExpression("tip", tip);
    }

    if (valueChangeListener != null) {
      component.addValueChangeListener(new javax.faces.event.MethodExpressionValueChangeListener(valueChangeListener));
    }
    if (converter != null) {
      if (!converter.isLiteralText()) {
        component.setValueExpression("converter", converter);
      } else {
        component.setConverter(application.createConverter(converter.getExpressionString()));
      }
    }
    if (value != null) {
      component.setValueExpression("value", value);
    }

    if (focus != null) {
      if (!focus.isLiteralText()) {
        component.setValueExpression("focus", focus);
      } else {
        component.setFocus(Boolean.parseBoolean(focus.getExpressionString()));
      }
    }
    if (selectedLabel != null) {
      component.setValueExpression("selectedLabel", selectedLabel);
    }

    if (required != null) {
      if (!required.isLiteralText()) {
        component.setValueExpression("required", required);
      } else {
        component.setRequired(Boolean.parseBoolean(required.getExpressionString()));
      }
    }
    if (converterMessage != null) {
      component.setValueExpression("converterMessage", converterMessage);
    }

    if (label != null) {
      component.setValueExpression("label", label);
    }

    if (requiredMessage != null) {
      component.setValueExpression("requiredMessage", requiredMessage);
    }

    if (onchange != null) {
      component.setValueExpression("onchange", onchange);
    }

    if (readonly != null) {
      if (!readonly.isLiteralText()) {
        component.setValueExpression("readonly", readonly);
      } else {
        component.setReadonly(Boolean.parseBoolean(readonly.getExpressionString()));
      }
    }
    if (disabled != null) {
      if (!disabled.isLiteralText()) {
        component.setValueExpression("disabled", disabled);
      } else {
        component.setDisabled(Boolean.parseBoolean(disabled.getExpressionString()));
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UISelectManyShuttle

public class SelectManyShuttleRenderer extends SelectManyRendererBase {

  @Override
  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
    UISelectManyShuttle select = (UISelectManyShuttle) component;
    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlElements.DIV, select);
    Style style = new Style(facesContext, select);
    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select));
    String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    boolean hasLabel = select.hasLabel();
    // TODO get buttonWidth and label Height from theme
    Measure buttonWidth = Measure.valueOf(50);

    Measure labelHeight = Measure.valueOf(18);
    style.setTop(Measure.valueOf(0));
    style.setLeft(Measure.valueOf(0));
    Measure width = style.getWidth();
    Measure selectWidth = width.subtract(buttonWidth).divide(2);
    style.setWidth(selectWidth);
    Style labelStyle = null;
    if (hasLabel) {
      labelStyle = new Style(style);
      labelStyle.setHeight(labelHeight);
      style.setHeight(style.getHeight().subtract(labelHeight));
      style.setTop(style.getTop().add(labelHeight));
    }
    String clientId = select.getClientId(facesContext);
    List<SelectItem> items = RenderUtils.getSelectItems(select);
    boolean disabled = items.size() == 0 || select.isDisabled() || select.isReadonly();

    String unselectedLabel = select.getUnselectedLabel();
    if (unselectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "unselectedLabel"));
      writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
      writer.write(unselectedLabel);
      writer.endElement(HtmlElements.DIV);
    }
    writer.startElement(HtmlElements.SELECT, null);
    String unselectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "unselected";
    writer.writeIdAttribute(unselectedClientId);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);

    // TODO tabIndex
    Integer tabIndex = select.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }

    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select, "unselected"));

    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);

    Object[] values = select.getSelectedValues();
    HtmlRendererUtils.renderSelectItems(select, items, values, false, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
    writer.startElement(HtmlElements.DIV, null);
    style.setLeft(style.getLeft().add(selectWidth));
    style.setWidth(buttonWidth);
    writer.writeStyleAttribute(style);
    writer.startElement(HtmlElements.DIV, null);
    writer.writeClassAttribute(Classes.create(select, "toolBar"));
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleAddAll.gif", "addAll");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleAdd.gif", "add");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleRemove.gif", "remove");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleRemoveAll.gif", "removeAll");
    writer.endElement(HtmlElements.DIV);
    writer.endElement(HtmlElements.DIV);
    String selectedLabel = select.getSelectedLabel();
    if (selectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      labelStyle.setLeft(labelStyle.getLeft().add(selectWidth).add(buttonWidth));
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "selectedLabel"));
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UISelectManyShuttle

public class SelectManyShuttleRenderer extends SelectManyRendererBase {

  @Override
  public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws IOException {
    final UISelectManyShuttle select = (UISelectManyShuttle) component;
    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlElements.DIV, select);
    final Style style = new Style(facesContext, select);
    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select));
    final String clientId = select.getClientId(facesContext);
    writer.writeIdAttribute(clientId);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, select);
    final String title = HtmlRendererUtils.getTitleFromTipAndMessages(facesContext, select);
    if (title != null) {
      writer.writeAttribute(HtmlAttributes.TITLE, title, true);
    }
    final boolean hasLabel = select.hasLabel();
    // TODO get buttonWidth and label Height from theme
    final Measure buttonWidth = Measure.valueOf(50);

    final Measure labelHeight = Measure.valueOf(18);
    style.setTop(Measure.valueOf(0));
    style.setLeft(Measure.valueOf(0));
    final Measure width = style.getWidth();
    final Measure selectWidth = width.subtract(buttonWidth).divide(2);
    style.setWidth(selectWidth);
    Style labelStyle = null;
    if (hasLabel) {
      labelStyle = new Style(style);
      labelStyle.setHeight(labelHeight);
      style.setHeight(style.getHeight().subtract(labelHeight));
      style.setTop(style.getTop().add(labelHeight));
    }
    final Iterable<SelectItem> items = SelectItemUtils.getItemIterator(facesContext, select);
    final boolean disabled = !items.iterator().hasNext() || select.isDisabled() || select.isReadonly();

    final String unselectedLabel = select.getUnselectedLabel();
    if (unselectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "unselectedLabel"));
      writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
      writer.write(unselectedLabel);
      writer.endElement(HtmlElements.DIV);
    }
    writer.startElement(HtmlElements.SELECT, null);
    final String unselectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "unselected";
    writer.writeIdAttribute(unselectedClientId);
    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);

    // TODO tabIndex
    final Integer tabIndex = select.getTabIndex();
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }

    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select, "unselected"));

    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);

    final Object[] values = select.getSelectedValues();
    HtmlRendererUtils.renderSelectItems(select, items, values, false, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
    writer.startElement(HtmlElements.DIV, null);
    style.setLeft(style.getLeft().add(selectWidth));
    style.setWidth(buttonWidth);
    writer.writeStyleAttribute(style);
    writer.startElement(HtmlElements.DIV, null);
    writer.writeClassAttribute(Classes.create(select, "toolBar"));
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleAddAll.gif", "addAll");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleAdd.gif", "add");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleRemove.gif", "remove");
    createButton(facesContext, component, writer, disabled, "image/selectManyShuttleRemoveAll.gif", "removeAll");
    writer.endElement(HtmlElements.DIV);
    writer.endElement(HtmlElements.DIV);
    final String selectedLabel = select.getSelectedLabel();
    if (selectedLabel != null) {
      writer.startElement(HtmlElements.DIV, null);
      labelStyle.setLeft(labelStyle.getLeft().add(selectWidth).add(buttonWidth));
      writer.writeStyleAttribute(labelStyle);
      writer.writeClassAttribute(Classes.create(select, "selectedLabel"));
      writer.flush(); // is needed in some cases, e. g. TOBAGO-1094
      writer.write(selectedLabel);
      writer.endElement(HtmlElements.DIV);
    }

    writer.startElement(HtmlElements.SELECT, select);
    final String selectedClientId = clientId + ComponentUtils.SUB_SEPARATOR + "selected";
    writer.writeIdAttribute(selectedClientId);

    writer.writeAttribute(HtmlAttributes.DISABLED, disabled);
    if (tabIndex != null) {
      writer.writeAttribute(HtmlAttributes.TABINDEX, tabIndex);
    }
    style.setWidth(selectWidth);
    style.setLeft(style.getLeft().add(buttonWidth));
    writer.writeStyleAttribute(style);
    writer.writeClassAttribute(Classes.create(select, "selected"));
    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);
    HtmlRendererUtils.renderSelectItems(select, items, values, true, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
    writer.startElement(HtmlElements.SELECT, select);
    writer.writeClassAttribute(Classes.create(component, "hidden"));
    final String hiddenClientId = clientId + ComponentUtils.SUB_SEPARATOR + "hidden";
    writer.writeIdAttribute(hiddenClientId);
    writer.writeNameAttribute(clientId);
    writer.writeAttribute(HtmlAttributes.MULTIPLE, HtmlAttributes.MULTIPLE, false);
    writer.writeAttribute(HtmlAttributes.REQUIRED, select.isRequired());
    HtmlRendererUtils.renderCommandFacet(select, facesContext, writer);
    HtmlRendererUtils.renderSelectItems(select, items, values, writer, facesContext);

    writer.endElement(HtmlElements.SELECT);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.