コード例 #1
0
 /**
  * Called if an element inside the form triggers an event. In this particular case clicks on the
  * vertical radio buttons are caught and the user gets notified by his choice.
  *
  * @param ureq
  * @param source
  * @param event
  */
 @Override
 @SuppressWarnings("unused")
 protected void formInnerEvent(
     final UserRequest ureq, final FormItem source, final FormEvent event) {
   if (source == verticalRadioButtons) {
     if (event.wasTriggerdBy(FormEvent.ONCLICK)) {
       final int selectedIndex = verticalRadioButtons.getSelected();
       final String selection = options[selectedIndex];
       showInfo("advanced_form.your_selection_is", selection);
     }
   } else if (source == richTextElement) {
     getWindowControl()
         .setInfo(
             "Wow, you just changed the html editor area. The new content is now: "
                 + richTextElement.getValue());
   }
 }
コード例 #2
0
  /**
   * org.olat.presentation.framework.control.Controller,
   * org.olat.presentation.framework.UserRequest)
   */
  @Override
  @SuppressWarnings("unused")
  // listener is never used because listener == this!
  protected void initForm(
      final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) {
    setFormTitle("guidemo_flexi_form_advanced");
    setFormDescription("advanced_form.description");
    // setFormContextHelp(this.getClass().getPackage().getName(),
    // "advancedFormHelp", "advanced_form.description");
    // Mandatory and read-only text fields

    this.addTextFields(formLayout);

    // More form items: Date, link and file selector
    this.addDateLinkAndFileItems(formLayout);

    // Separator with line
    uifactory.addSpacerElement("spacer", formLayout, false);

    // Single and multible selections (radio buttons and checkboxes)
    this.addSelections(formLayout);

    // Separator without line
    uifactory.addSpacerElement("spacernoline", formLayout, true);

    // Sublayout (shown if no is selected)
    this.addSublayout(formLayout);

    // Here's a text area
    uifactory.addTextAreaElement("guidemo.form.textarea", 0, 2, null, formLayout);

    // Add some rich text elements
    richTextElement =
        uifactory.addRichTextElementForStringData(
            "guidemo.form.richtext.simple",
            "guidemo.form.richtext.simple",
            "click <i>to</i> <b>edit</b>. This one has an event listener and an <b>external menu with auto hide</b>",
            -1,
            -1,
            true,
            false,
            null,
            null,
            formLayout,
            ureq.getUserSession(),
            getWindowControl());
    // richTextElement.addActionListener(this, FormEvent.ONCHANGE);

    richTextElement2 =
        uifactory.addRichTextElementForStringData(
            "guidemo.form.richtext.simple2",
            null,
            "one <i>with</i> <b>height</b> and <span style='color:red'>no</span> event listener and an <b>internal</b> menu",
            10,
            40,
            false,
            true,
            null,
            null,
            formLayout,
            ureq.getUserSession(),
            getWindowControl());

    disabledRichTextElement =
        uifactory.addRichTextElementForStringData(
            "guidemo.form.richtext.simple3",
            "guidemo.form.richtext.simple",
            "this <i>is</i> <b>disabled</b>",
            -1,
            -1,
            true,
            false,
            null,
            null,
            formLayout,
            ureq.getUserSession(),
            getWindowControl());
    disabledRichTextElement.setEnabled(false);

    // Button layout
    final FormLayoutContainer buttonLayout =
        FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
    formLayout.add(buttonLayout);

    // Submit and cancel buttons (without effect)
    uifactory.addFormSubmitButton("advanced_form.submit", buttonLayout);
    uifactory.addFormLink("advanced_form.cancel", buttonLayout, Link.BUTTON);
  }