提交 f7e9b4fb 编写于 作者: M mindless

Replace uses of /fieldCheck validator with clazz="required" client-side validation.

Marked Hudson.doFieldCheck as deprecated.
Also a few more escape->encodeURIComponent.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@21549 71c3de6d-444a-0410-be80-ed276b4c234a
上级 41b1ebd4
...@@ -2982,11 +2982,15 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl ...@@ -2982,11 +2982,15 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
/** /**
* Checks if the value for a field is set; if not an error or warning text is displayed. * Checks if the value for a field is set; if not an error or warning text is displayed.
* If the parameter "value" is not set then the parameter "errorText" is displayed * If the parameter "value" is not set then the parameter "errorText" is displayed
* as an error text. If the parameter "errorText" is not set, then the parameter "warningText" is * as an error text. If the parameter "errorText" is not set, then the parameter "warningText"
* displayed as a warning text. * is displayed as a warning text.
* <p> * <p>
* If the text is set and the parameter "type" is set, it will validate that the value is of the * If the text is set and the parameter "type" is set, it will validate that the value is of the
* correct type. Supported types are "number, "number-positive" and "number-negative". * correct type. Supported types are "number, "number-positive" and "number-negative".
*
* @deprecated as of 1.324
* Either use client-side validation (e.g. class="required number")
* or define your own check method, instead of relying on this generic one.
*/ */
public FormValidation doFieldCheck(@QueryParameter(fixEmpty=true) String value, public FormValidation doFieldCheck(@QueryParameter(fixEmpty=true) String value,
@QueryParameter(fixEmpty=true) String type, @QueryParameter(fixEmpty=true) String type,
......
...@@ -32,8 +32,7 @@ THE SOFTWARE. ...@@ -32,8 +32,7 @@ THE SOFTWARE.
<l:main-panel> <l:main-panel>
<f:form method="post" action="doCreateItem"> <f:form method="post" action="doCreateItem">
<f:entry title="${%Name}" help="/help/system-config/master-slave/name.html"> <f:entry title="${%Name}" help="/help/system-config/master-slave/name.html">
<f:textbox name="name" value="${request.getParameter('name')}" <f:textbox name="name" value="${request.getParameter('name')}" clazz="required" checkMessage="${%Name is mandatory}"/>
checkUrl="'../fieldCheck?errorText=${h.jsStringEscape(h.encode('%Name is mandatory'))}&amp;value='+escape(this.value)"/>
</f:entry> </f:entry>
<!-- main body of the configuration --> <!-- main body of the configuration -->
......
...@@ -37,8 +37,8 @@ THE SOFTWARE. ...@@ -37,8 +37,8 @@ THE SOFTWARE.
<table> <table>
<f:block> <f:block>
${%Choose the CVS tag name for this build}: ${%Choose the CVS tag name for this build}:
<input type="text" name="name" value="hudson-${it.build.number}" class="validated" <f:textbox name="name" value="hudson-${it.build.number}"
checkUrl="'checkTag?value='+escape(this.value)"/> checkUrl="'checkTag?value='+encodeURIComponent(this.value)"/>
</f:block> </f:block>
<j:set var="upstream" value="${it.build.transitiveUpstreamBuilds}" /> <j:set var="upstream" value="${it.build.transitiveUpstreamBuilds}" />
...@@ -46,8 +46,8 @@ THE SOFTWARE. ...@@ -46,8 +46,8 @@ THE SOFTWARE.
<f:optionalBlock name="upstream" title="Tag all upstream builds at once" help="${descriptor.getHelpFile('tagAll')}"> <f:optionalBlock name="upstream" title="Tag all upstream builds at once" help="${descriptor.getHelpFile('tagAll')}">
<j:forEach var="up" items="${upstream}"> <j:forEach var="up" items="${upstream}">
<f:entry title="${up.key.name} #${up.value}"> <f:entry title="${up.key.name} #${up.value}">
<input type="text" name="upstream.${up.key.name}" value="hudson-${up.value}" class="validated" <f:textbox name="upstream.${up.key.name}" value="hudson-${up.value}"
checkUrl="'checkTag?value='+escape(this.value)"/> checkUrl="'checkTag?value='+encodeURIComponent(this.value)"/>
</f:entry> </f:entry>
</j:forEach> </j:forEach>
</f:optionalBlock> </f:optionalBlock>
......
...@@ -25,13 +25,13 @@ THE SOFTWARE. ...@@ -25,13 +25,13 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form"> xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%In demand delay}" help="/help/system-config/master-slave/demand/inDemandDelay.html"> <f:entry title="${%In demand delay}" help="/help/system-config/master-slave/demand/inDemandDelay.html">
<input class="setting-input number validated" name="retentionStrategy.inDemandDelay" <f:textbox clazz="required number"
type="text" value="${instance.inDemandDelay}" name="retentionStrategy.inDemandDelay" value="${instance.inDemandDelay}"
checkUrl="'${rootURL}/fieldCheck?errorText=${h.jsStringEscape(h.encode('%In demand delay is mandatory.'))}&amp;value='+escape(this.value)"/> checkMessage="${%In demand delay is mandatory and must be a number.}"/>
</f:entry> </f:entry>
<f:entry title="${%Idle delay}" help="/help/system-config/master-slave/demand/idleDelay.html"> <f:entry title="${%Idle delay}" help="/help/system-config/master-slave/demand/idleDelay.html">
<input class="setting-input number validated" name="retentionStrategy.idleDelay" <f:textbox clazz="required number"
type="text" value="${instance.idleDelay}" name="retentionStrategy.idleDelay" value="${instance.idleDelay}"
checkUrl="'${rootURL}/fieldCheck?errorText=${h.jsStringEscape(h.encode('%Idle delay is mandatory.'))}&amp;value='+escape(this.value)"/> checkMessage="${%Idle delay is mandatory and must be a number.}"/>
</f:entry> </f:entry>
</j:jelly> </j:jelly>
...@@ -25,14 +25,14 @@ THE SOFTWARE. ...@@ -25,14 +25,14 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form"> xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%Startup Schedule}" help="/help/project-config/timer-format.html"> <f:entry title="${%Startup Schedule}" help="/help/project-config/timer-format.html">
<f:textarea name="retentionStrategy.startTimeSpec" checkUrl="'${rootURL}/retentionStrategy/SimpleScheduledRetentionStrategy/check?value='+escape(this.value)" <f:textarea name="retentionStrategy.startTimeSpec" checkUrl="'${rootURL}/retentionStrategy/SimpleScheduledRetentionStrategy/check?value='+encodeURIComponent(this.value)"
value="${instance.startTimeSpec}"/> value="${instance.startTimeSpec}"/>
</f:entry> </f:entry>
<f:entry title="${%Scheduled Uptime}" <f:entry title="${%Scheduled Uptime}"
description="The number of minutes to keep the node up for. If this is longer than the startup schedule, then the node will remain constantly on-line."> description="The number of minutes to keep the node up for. If this is longer than the startup schedule, then the node will remain constantly on-line.">
<input class="setting-input number validated" name="retentionStrategy.upTimeMins" <f:textbox clazz="required number"
type="text" value="${instance.upTimeMins}" name="retentionStrategy.upTimeMins" value="${instance.upTimeMins}"
checkUrl="'${rootURL}/fieldCheck?errorText=${h.jsStringEscape(h.encode('%Scheduled Uptime is mandatory.'))}&amp;value='+escape(this.value)"/> checkMessage="${%Scheduled Uptime is mandatory and must be a number.}"/>
</f:entry> </f:entry>
<f:entry title="${%Keep on-line while jobs are running}"> <f:entry title="${%Keep on-line while jobs are running}">
<f:checkbox name="retentionStrategy.keepUpWhenActive" checked="${h.defaultToTrue(instance.keepUpWhenActive)}"/> <f:checkbox name="retentionStrategy.keepUpWhenActive" checked="${h.defaultToTrue(instance.keepUpWhenActive)}"/>
......
...@@ -36,9 +36,8 @@ THE SOFTWARE. ...@@ -36,9 +36,8 @@ THE SOFTWARE.
checked="${!empty(up)}"> checked="${!empty(up)}">
<f:entry title="${%Projects names}" <f:entry title="${%Projects names}"
description="${%Multiple projects can be specified like 'abc, def'}"> description="${%Multiple projects can be specified like 'abc, def'}">
<input class="setting-input validated" name="upstreamProjects" <f:textbox name="upstreamProjects" value="${h.getProjectListString(up)}"
checkUrl="'descriptorByName/BuildTrigger/check?value='+escape(this.value)" checkUrl="'descriptorByName/BuildTrigger/check?value='+encodeURIComponent(this.value)"/>
type="text" value="${h.getProjectListString(up)}"/>
</f:entry> </f:entry>
</f:optionalBlock> </f:optionalBlock>
</j:jelly> </j:jelly>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册