@Override
    public void execute(IViewState viewState) {
      if (hidden.getValue() != null && hidden.getValue().equalsIgnoreCase("true")) {
        String destinationName = this.destination == null ? "postback" : this.destination;
        ViewDestination destination = viewState.getDestination(destinationName);

        if (destination != null) {
          viewState.setCurrentDestination(destination);
        } else {
          viewState.setCurrentDestination("postBack");
        }

        hidden.setValue("false");
        viewState.setSkipValidation(true);
      }
    }
コード例 #2
0
  @Override
  protected HtmlComponent renderComponent(Layout layout, Object object, Class type) {
    String value = (String) object;
    MetaSlot slot = (MetaSlot) getInputContext().getMetaObject();

    HtmlMenu menu = (HtmlMenu) super.renderComponent(layout, object, type);
    HtmlMenuOption otherOption = createOtherOption(menu);

    HtmlHiddenField field = new HtmlHiddenField();

    HtmlTextInput other = new HtmlTextInput();
    other.setSize(getOtherSize());

    boolean otherSelected = true;
    for (HtmlMenuEntry entry : menu.getEntries()) {
      if (entry.isSelected()) {
        other.setStyle("display: none;");
        otherSelected = false;
        break;
      }
    }

    if (otherSelected) {
      otherOption.setSelected(true);
      other.setValue(value);
    }

    field.setValue(value);
    field.bind(slot);
    field.setController(new CopyController(menu, other));

    menu.setTargetSlot(null);
    menu.setName(getLocalName(slot, "menu"));
    other.setName(getLocalName(slot, "other"));

    HtmlContainer container = new HtmlBlockContainer();

    container.addChild(createSwitchScript(field, menu, other));
    container.addChild(field);
    container.addChild(menu);
    container.addChild(other);

    return container;
  }