Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Jelly form controls"

(Optional attributes:)
(3 intermediate revisions by the same user not shown)
Line 64: Line 64:
  
 
<b>Example:</b>
 
<b>Example:</b>
 
[[image:secondimage]]
 
 
 
 
At start only button is shown:
 
At start only button is shown:
  
When the button is clicked it disappears, and the content is displayed instead
+
[[image:advanced_not_clicked.PNG]]
  
 +
When the button is clicked it disappears, and the content is displayed instead:
  
 +
[[image:advanced_clicked.PNG]]
  
 
+
== OptionalBlock ==
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
OptionalBlock
+
  
 
Foldable block expanded when the menu item is checked.
 
Foldable block expanded when the menu item is checked.
Mandatory attributes:
+
=== Mandatory attributes: ===
  
    name Name of the checkbox.
+
<code>name</code> Name of the checkbox.
    title Human readable text that follows the checkbox
+
<code>title</code> Human readable text that follows the checkbox
    checked Initial checkbox status. true/false.
+
<code>checked</code> Initial checkbox status. true/false.
  
Optional attributes:
+
=== Optional attributes: ===
  
    help (optional) If present, URL of the help HTML page.
+
<code>help</code> (optional) If present, URL of the help HTML page.
  
 
Jelly code Example
 
Jelly code Example
  
 
+
<pre>
 
<f:block>
 
<f:block>
 
   <table>
 
   <table>
Line 109: Line 97:
 
   </table>
 
   </table>
 
</f:block>
 
</f:block>
 
+
</pre>
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
 
  
 
Unchecked the text box will not be displayed:
 
Unchecked the text box will not be displayed:
 +
 +
[[image:optional_block_unchecked.PNG]]
  
 
Checked the text box is displayed
 
Checked the text box is displayed
  
  
 +
[[image:optional_block_checked.PNG]]
  
  
 
+
=== Select (drop-down menu) ===
 
+
 
+
 
+
 
+
 
+
 
+
 
+
 
+
Select (drop-down menu)
+
  
 
Use an <f:entry> tag to enclose the normal select tag.
 
Use an <f:entry> tag to enclose the normal select tag.
Line 153: Line 122:
 
             </select>
 
             </select>
 
         </f:entry>
 
         </f:entry>
 +
 +
[[image:optionbox.PNG]]

Revision as of 15:23, 22 July 2013

Jelly form controls

Building Tag Library Documentation

Most of the the jelly files in the Hudson source have embedded documentation .

Validation Button

This tag creates a right-aligned button for performing server-side validation. It is suitable for situations where the validation depends on the values of multiple input fields, such as credential check that uses both username and password. Jelly code

<f:entry title="${%Access Key ID}" help="...">
  <f:textbox field="accessId" />
</f:entry>
<f:entry title="${%Secret Access Key}" help="...">
  <f:password field="secretKey" />
</f:entry>
<f:validateButton
   title="${%Test Connection}" progress="${%Testing...}"
   method="testConnection" with="secretKey,accessId" />

ValidateButton.png


The title attribute is used to determine the text written on the button. The progress attribute determines the message displayed while the server-side validation is in progress. The method attribute specifies the server-side method invoked by this button; this follows the stapler name mangling convention, so for example method="testConnection" will invoke the doTestConnection method. This method needs to be on the Descriptor class that owns this form fragment.

Finally, the with attribute specifies the input fields sent to the server for the validation. They are matched against the field attribute or the name attribute of other input controls. The values of the nearest input fields above the <f:validateButton/> are sent to the server, so this means the button has to come after the input fields. Multiple fields can be specified by using ','.

On the server side, this tag invokes the standard "check"-style method like this:

public void doTestConnection(StaplerRequest req, StaplerResponse rsp,
    @QueryParameter("accessId") final String accessId, @QueryParameter("secretKey") final String secretKey) throws IOException, ServletException {
    new FormFieldValidator(req,rsp,true) {
        protected void check() throws IOException, ServletException {
            try {
                ... do some tests ...
                ok("Success");
            } catch (EC2Exception e) {
                error("Client error : "+e.getMessage());
            }
        }
    }.process();
}

The check method contains the validation logic. In the end, this method has to call either ok, warning, or error method. Depending on which method you use, the appropriate HTML will be rendered on the client side to indicate the status to the user.

Advanced

Expandable section that shows "advanced..." button by default. Upon clicking it, a section unfolds.

Optional attributes:

help (optional) If present, URL of the help HTML page.

Jelly code

<f:section title="Advanced Project Options">
  <f:advanced>
    <p:config-quietPeriod />
    <st:include page="configure-advanced.jelly" optional="true" />
  </f:advanced>
</f:section>

Example: At start only button is shown:

Advanced not clicked.PNG

When the button is clicked it disappears, and the content is displayed instead:

Advanced clicked.PNG

OptionalBlock

Foldable block expanded when the menu item is checked.

Mandatory attributes:

name Name of the checkbox. title Human readable text that follows the checkbox checked Initial checkbox status. true/false.

Optional attributes:

help (optional) If present, URL of the help HTML page.

Jelly code Example

<f:block>
  <table>
    <f:optionalBlock name="dynamic" title="Use existing dynamic view">
      <f:entry title="View drive">
        <f:textbox name="drive" value="${it.drive}"/>
      </f:entry>
    </f:optionalBlock>
  </table>
</f:block>


Unchecked the text box will not be displayed:

Optional block unchecked.PNG

Checked the text box is displayed


Optional block checked.PNG


Select (drop-down menu)

Use an <f:entry> tag to enclose the normal select tag. Jelly code Example


<f:entry name="goalType" title="Choose Goal Type" field="goalType">

           <select name="goalType">
               <option value="buildGoal">Build Goal</option>
               <option value="findBugsGoal">FindBugs goal</option>
           </select>
       </f:entry>

Optionbox.PNG

Back to the top