[ANN] Simplified form validation in 1.238

View: New views
6 Messages — Rating Filter:   Alert me  

[ANN] Simplified form validation in 1.238

by kohsuke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I just committed a change in 1.238 to make the form validation easier.

Before this change, it was necessary to write 3 attributes when you are
defining form field tags like <f:textbox/>. The following example is
taken from
http://hudson.gotdns.com/wiki/display/HUDSON/SCM+plugin+architecture

>         <f:textbox name="tfs.project" value="${scm.project}"
>              checkUrl="'/fieldCheck?errorText='+escape('${%Project is mandatory.}')+'&value='+escape(this.value)"/>

   ...

>         <f:entry title="Workspace name" help="/plugin/tfs/workspacename.html">
>             <f:textbox name="tfs.workspaceName" value="${scm.workspaceName}"/>


With this change, you'll only need to write:

   <f:textbox field="project" />

   <f:textbox field="workspaceName" />

The tag will check if your Descriptor has the "doCheckProject" method
and "doCheckWorkspaceName" and if so, it automatically wire up the field
for the form field validation.

In this way, you can simplify the jelly programming part by relying more
on the convention, and hopefully this would encourage people to write
more form-field validation code.

This support is currently implemented for <f:textbox> and
<f:editableComboBox/>. I'll update the core to use this new feature and
expand the support to other tags. Plugin authors, please be encouraged
to use this new feature, because when people develop new plugins, they
look at your code and copy things from there.

My ultimate goal is to implement the auto-generation of the form, so
that in simple cases you don't have to write any Jelly code at all.

--
Kohsuke Kawaguchi
Sun Microsystems                   http://weblogs.java.net/blog/kohsuke/


smime.p7s (4K) Download Attachment

RE: [ANN] Simplified form validation in 1.238

by Ulli Hafner :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Cool, that makes checks much easier!

Does the update center currently enforce a Hudson minimum release for a
plug-in?
(Or is the new validation just not available for old Hudson releases and

new plug-ins - which encourages everybody to use the latest builds
only:-).

Ulli

> -----Original Message-----
> From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi@...]
> Sent: Samstag, 26. Juli 2008 02:23
> To: dev@...
> Subject: [ANN] Simplified form validation in 1.238
>
>
> I just committed a change in 1.238 to make the form validation easier.
>
> Before this change, it was necessary to write 3 attributes
> when you are defining form field tags like <f:textbox/>. The
> following example is taken from
> http://hudson.gotdns.com/wiki/display/HUDSON/SCM+plugin+architecture
>
> >         <f:textbox name="tfs.project" value="${scm.project}"
> >              
> checkUrl="'/fieldCheck?errorText='+escape('${%Project is
> > mandatory.}')+'&value='+escape(this.value)"/>
>
>    ...
>
> >         <f:entry title="Workspace name"
> help="/plugin/tfs/workspacename.html">
> >             <f:textbox name="tfs.workspaceName"
> > value="${scm.workspaceName}"/>
>
>
> With this change, you'll only need to write:
>
>    <f:textbox field="project" />
>
>    <f:textbox field="workspaceName" />
>
> The tag will check if your Descriptor has the
> "doCheckProject" method and "doCheckWorkspaceName" and if so,
> it automatically wire up the field for the form field validation.
>
> In this way, you can simplify the jelly programming part by
> relying more on the convention, and hopefully this would
> encourage people to write more form-field validation code.
>
> This support is currently implemented for <f:textbox> and
> <f:editableComboBox/>. I'll update the core to use this new
> feature and expand the support to other tags. Plugin authors,
> please be encouraged to use this new feature, because when
> people develop new plugins, they look at your code and copy
> things from there.
>
> My ultimate goal is to implement the auto-generation of the
> form, so that in simple cases you don't have to write any
> Jelly code at all.
>
> --
> Kohsuke Kawaguchi
> Sun Microsystems                  
> http://weblogs.java.net/blog/kohsuke/
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: [ANN] Simplified form validation in 1.238

by kohsuke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hafner Ullrich wrote:
> Cool, that makes checks much easier!
>
> Does the update center currently enforce a Hudson minimum release for a
> plug-in?

No, not yet. I really need to do this.

> (Or is the new validation just not available for old Hudson releases and
>
> new plug-ins - which encourages everybody to use the latest builds
> only:-).
>
> Ulli
>
>> -----Original Message-----
>> From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi@...]
>> Sent: Samstag, 26. Juli 2008 02:23
>> To: dev@...
>> Subject: [ANN] Simplified form validation in 1.238
>>
>>
>> I just committed a change in 1.238 to make the form validation easier.
>>
>> Before this change, it was necessary to write 3 attributes
>> when you are defining form field tags like <f:textbox/>. The
>> following example is taken from
>> http://hudson.gotdns.com/wiki/display/HUDSON/SCM+plugin+architecture
>>
>> >         <f:textbox name="tfs.project" value="${scm.project}"
>> >              
>> checkUrl="'/fieldCheck?errorText='+escape('${%Project is
>> > mandatory.}')+'&value='+escape(this.value)"/>
>>
>>    ...
>>
>> >         <f:entry title="Workspace name"
>> help="/plugin/tfs/workspacename.html">
>> >             <f:textbox name="tfs.workspaceName"
>> > value="${scm.workspaceName}"/>
>>
>>
>> With this change, you'll only need to write:
>>
>>    <f:textbox field="project" />
>>
>>    <f:textbox field="workspaceName" />
>>
>> The tag will check if your Descriptor has the
>> "doCheckProject" method and "doCheckWorkspaceName" and if so,
>> it automatically wire up the field for the form field validation.
>>
>> In this way, you can simplify the jelly programming part by
>> relying more on the convention, and hopefully this would
>> encourage people to write more form-field validation code.
>>
>> This support is currently implemented for <f:textbox> and
>> <f:editableComboBox/>. I'll update the core to use this new
>> feature and expand the support to other tags. Plugin authors,
>> please be encouraged to use this new feature, because when
>> people develop new plugins, they look at your code and copy
>> things from there.
>>
>> My ultimate goal is to implement the auto-generation of the
>> form, so that in simple cases you don't have to write any
>> Jelly code at all.
>>
>> --
>> Kohsuke Kawaguchi
>> Sun Microsystems                  
>> http://weblogs.java.net/blog/kohsuke/
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>
>

--
Kohsuke Kawaguchi
Sun Microsystems                   http://weblogs.java.net/blog/kohsuke/


smime.p7s (4K) Download Attachment

Re: [ANN] Simplified form validation in 1.238

by Erik Ramfelt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is this available for Descriptor implementations as well? Im currently
looking at the page decorator and its configure() method. Do I still
have to manual bind the field to the variable in configure()?

I searched the wiki for this info, but couldnt find any.

//Erik


On Sat, Jul 26, 2008 at 2:23 AM, Kohsuke Kawaguchi
<Kohsuke.Kawaguchi@...> wrote:

>
> I just committed a change in 1.238 to make the form validation easier.
>
> Before this change, it was necessary to write 3 attributes when you are
> defining form field tags like <f:textbox/>. The following example is taken
> from http://hudson.gotdns.com/wiki/display/HUDSON/SCM+plugin+architecture
>
>>        <f:textbox name="tfs.project" value="${scm.project}"
>>             checkUrl="'/fieldCheck?errorText='+escape('${%Project is
>> mandatory.}')+'&value='+escape(this.value)"/>
>
>  ...
>
>>        <f:entry title="Workspace name"
>> help="/plugin/tfs/workspacename.html">
>>            <f:textbox name="tfs.workspaceName"
>> value="${scm.workspaceName}"/>
>
>
> With this change, you'll only need to write:
>
>  <f:textbox field="project" />
>
>  <f:textbox field="workspaceName" />
>
> The tag will check if your Descriptor has the "doCheckProject" method and
> "doCheckWorkspaceName" and if so, it automatically wire up the field for the
> form field validation.
>
> In this way, you can simplify the jelly programming part by relying more on
> the convention, and hopefully this would encourage people to write more
> form-field validation code.
>
> This support is currently implemented for <f:textbox> and
> <f:editableComboBox/>. I'll update the core to use this new feature and
> expand the support to other tags. Plugin authors, please be encouraged to
> use this new feature, because when people develop new plugins, they look at
> your code and copy things from there.
>
> My ultimate goal is to implement the auto-generation of the form, so that in
> simple cases you don't have to write any Jelly code at all.
>
> --
> Kohsuke Kawaguchi
> Sun Microsystems                   http://weblogs.java.net/blog/kohsuke/
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: [ANN] Simplified form validation in 1.238

by Erik Ramfelt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

BTW, if I want to be able to configure a PageDecorator, shouldnt it
show up in the "System configuration" page?

Ive created a global.jelly for the file, but not sure where it should show up.

//Erik

On Thu, Aug 28, 2008 at 2:23 PM, Erik Ramfelt <eramfelt@...> wrote:

> Is this available for Descriptor implementations as well? Im currently
> looking at the page decorator and its configure() method. Do I still
> have to manual bind the field to the variable in configure()?
>
> I searched the wiki for this info, but couldnt find any.
>
> //Erik
>
>
> On Sat, Jul 26, 2008 at 2:23 AM, Kohsuke Kawaguchi
> <Kohsuke.Kawaguchi@...> wrote:
>>
>> I just committed a change in 1.238 to make the form validation easier.
>>
>> Before this change, it was necessary to write 3 attributes when you are
>> defining form field tags like <f:textbox/>. The following example is taken
>> from http://hudson.gotdns.com/wiki/display/HUDSON/SCM+plugin+architecture
>>
>>>        <f:textbox name="tfs.project" value="${scm.project}"
>>>             checkUrl="'/fieldCheck?errorText='+escape('${%Project is
>>> mandatory.}')+'&value='+escape(this.value)"/>
>>
>>  ...
>>
>>>        <f:entry title="Workspace name"
>>> help="/plugin/tfs/workspacename.html">
>>>            <f:textbox name="tfs.workspaceName"
>>> value="${scm.workspaceName}"/>
>>
>>
>> With this change, you'll only need to write:
>>
>>  <f:textbox field="project" />
>>
>>  <f:textbox field="workspaceName" />
>>
>> The tag will check if your Descriptor has the "doCheckProject" method and
>> "doCheckWorkspaceName" and if so, it automatically wire up the field for the
>> form field validation.
>>
>> In this way, you can simplify the jelly programming part by relying more on
>> the convention, and hopefully this would encourage people to write more
>> form-field validation code.
>>
>> This support is currently implemented for <f:textbox> and
>> <f:editableComboBox/>. I'll update the core to use this new feature and
>> expand the support to other tags. Plugin authors, please be encouraged to
>> use this new feature, because when people develop new plugins, they look at
>> your code and copy things from there.
>>
>> My ultimate goal is to implement the auto-generation of the form, so that in
>> simple cases you don't have to write any Jelly code at all.
>>
>> --
>> Kohsuke Kawaguchi
>> Sun Microsystems                   http://weblogs.java.net/blog/kohsuke/
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...


Re: [ANN] Simplified form validation in 1.238

by kohsuke :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Erik Ramfelt wrote:
> Is this available for Descriptor implementations as well? Im currently
> looking at the page decorator and its configure() method. Do I still
> have to manual bind the field to the variable in configure()?

In the configure() method, you can use the bindJSON method:

>     /**
>      * Data-binds from {@link JSONObject} to the given object.
>      *
>      * <p>
>      * This method is bit like {@link #bindJSON(Class, JSONObject)}, except that this method
>      * populates an existing object, instead of creating a new instance.
>      *
>      * <p>
>      * This method is also bit like {@link #bindParameters(Object, String)}, in that it
>      * populates an existing object from a form submission, except that this method
>      * obtains data from {@link JSONObject} thus more structured, whereas {@link #bindParameters(Object, String)}
>      * uses the map structure of the form submission.
>      */
>     void bindJSON( Object bean, JSONObject src );
This is fairly new --- definitely newer than 1.238. So if you still
don't see it in your current hudson-core, give us one more release.


>
> I searched the wiki for this info, but couldnt find any.
>
> //Erik
>
>
> On Sat, Jul 26, 2008 at 2:23 AM, Kohsuke Kawaguchi
> <Kohsuke.Kawaguchi@...> wrote:
>>
>> I just committed a change in 1.238 to make the form validation easier.
>>
>> Before this change, it was necessary to write 3 attributes when you are
>> defining form field tags like <f:textbox/>. The following example is taken
>> from http://hudson.gotdns.com/wiki/display/HUDSON/SCM+plugin+architecture
>>
>>>        <f:textbox name="tfs.project" value="${scm.project}"
>>>             checkUrl="'/fieldCheck?errorText='+escape('${%Project is
>>> mandatory.}')+'&value='+escape(this.value)"/>
>>
>>  ...
>>
>>>        <f:entry title="Workspace name"
>>> help="/plugin/tfs/workspacename.html">
>>>            <f:textbox name="tfs.workspaceName"
>>> value="${scm.workspaceName}"/>
>>
>>
>> With this change, you'll only need to write:
>>
>>  <f:textbox field="project" />
>>
>>  <f:textbox field="workspaceName" />
>>
>> The tag will check if your Descriptor has the "doCheckProject" method and
>> "doCheckWorkspaceName" and if so, it automatically wire up the field for the
>> form field validation.
>>
>> In this way, you can simplify the jelly programming part by relying more on
>> the convention, and hopefully this would encourage people to write more
>> form-field validation code.
>>
>> This support is currently implemented for <f:textbox> and
>> <f:editableComboBox/>. I'll update the core to use this new feature and
>> expand the support to other tags. Plugin authors, please be encouraged to
>> use this new feature, because when people develop new plugins, they look at
>> your code and copy things from there.
>>
>> My ultimate goal is to implement the auto-generation of the form, so that in
>> simple cases you don't have to write any Jelly code at all.
>>
>> --
>> Kohsuke Kawaguchi
>> Sun Microsystems                   http://weblogs.java.net/blog/kohsuke/
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@...
> For additional commands, e-mail: dev-help@...
>
>

--
Kohsuke Kawaguchi
Sun Microsystems                   http://weblogs.java.net/blog/kohsuke/


smime.p7s (4K) Download Attachment
LightInTheBox - Buy quality products at wholesale price!