提交 ed2566ce 编写于 作者: K kohsuke

added @field support. Added a test case to make sure that the old way of using it works

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13210 71c3de6d-444a-0410-be80-ed276b4c234a
上级 b28ccbc5
......@@ -10,6 +10,17 @@
</f:entry>
</j:if>
<f:entry title="${%Goals}">
<f:expandableTextbox name="maven.targets" value="${instance.targets}" />
<f:expandableTextbox field="targets" />
</f:entry>
<f:advanced>
<f:entry title="${%POM}" help="/help/maven/maven-pom.html">
<f:textbox field="pom"/>
</f:entry>
<f:entry title="${%Properties}" help="/help/maven/maven-properties.html">
<f:textarea field="properties"/>
</f:entry>
<f:entry title="${%JVM Options}" help="/help/maven/jvm-options.html">
<f:expandableTextbox field="jvmOptions"/>
</f:entry>
</f:advanced>
</j:jelly>
\ No newline at end of file
<!--
textbox that can be expanded into text area
<input class="setting-input ${h.ifThenElse(attrs.checkUrl!=null,'validated','')}" name="${attrs.name}"
type="text" value="${attrs.value}" checkUrl="${attrs.checkUrl}"/>
If @field is specified:
no other mandatory fields.
in this case, name and value are inferred from field,
and checkUrl is auto-generated if the check method is present.
Otherwise
@name and @value are mandatory.
TODO: support @checkUrl
-->
......@@ -10,17 +14,20 @@
<j:choose>
<j:when test="${h.isMultiline(attrs.value)}">
<!-- multiline text area to begin with -->
<f:textarea name='${attrs.name}' value="${attrs.value}"/>
<f:textarea name='${attrs.name}' value="${attrs.value}" field="${attrs.field}"/>
</j:when>
<j:otherwise>
<!-- single line textbox with expand button -->
<table border="0" style="width:100%" cellspacing="0" cellpadding="0">
<tr>
<td width="*">
<input class="setting-input" name="${attrs.name}" id="textarea.${attrs.name}"
type="text" value="${attrs.value}"/>
<j:set var="name" value="${h.defaulted(attrs.name,'_.'+attrs.field)}" />
<input class="setting-input" type="text"
name ="${name}"
value="${h.defaulted(attrs.value,instance[attrs.field])}"
id="textarea.${name}" />
</td><td width="1">
<input type="button" value="&#x25BC;" onclick="expandTextArea(this,'textarea.${attrs.name}')"
<input type="button" value="&#x25BC;" onclick="expandTextArea(this,'textarea.${name}')"
tooltip="Click to expand to multiple lines&lt;br&gt;where you can use new lines instead of space.&lt;br&gt;To revert back to single line, write everything in one line then submit."/>
</td>
</tr>
......
......@@ -2,13 +2,22 @@
<textarea> tag on steroid.
The textarea will be rendered to fit the content. It also gets the resize handle.
If @field is specified:
no other mandatory fields.
in this case, name and value are inferred from field,
and checkUrl is auto-generated if the check method is present.
Otherwise
@name and @value are mandatory.
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler">
<textarea name="${attrs.name}" id="${attrs.id}" style="${attrs.style}"
class="setting-input ${h.ifThenElse(attrs.checkUrl!=null,'validated','')}"
checkUrl="${attrs.checkUrl}"
<j:set var="checkUrl" value="${h.getCheckUrl(attrs.checkUrl,descriptor,attrs.field)}" />
<textarea id="${attrs.id}" style="${attrs.style}"
name ="${h.defaulted(attrs.name,'_.'+attrs.field)}"
class="setting-input ${h.ifThenElse(checkUrl!=null,'validated','')}"
checkUrl="${checkUrl}"
rows="${h.determineRows(attrs.value)}">
<st:out value="${attrs.value}" />
<st:out value="${h.defaulted(attrs.value,instance[attrs.field])}" />
</textarea>
<!-- resize handle -->
<div class="textarea-handle"/>
......
package hudson.tasks;
import org.jvnet.hudson.test.HudsonTestCase;
import hudson.model.FreeStyleProject;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlButton;
/**
* @author Kohsuke Kawaguchi
*/
public class AntTest extends HudsonTestCase {
/**
* Tests the round-tripping of the configuration.
*/
public void testConfigRoundtrip() throws Exception {
FreeStyleProject p = createFreeStyleProject();
p.getBuildersList().add(new Ant("a",null,"-b","c.xml","d=e"));
WebClient webClient = new WebClient();
HtmlPage page = webClient.getPage(p,"configure");
HtmlForm form = page.getFormByName("config");
form.submit((HtmlButton)last(form.getHtmlElementsByTagName("button")));
Ant a = (Ant)p.getBuildersList().get(Ant.DESCRIPTOR);
assertNotNull(a);
assertEquals("a",a.getTargets());
assertNull(a.getAnt());
assertEquals("-b",a.getAntOpts());
assertEquals("c.xml",a.getBuildFile());
assertEquals("d=e",a.getProperties());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册