plugins and jelly: specifying default values for configuration options

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

plugins and jelly: specifying default values for configuration options

Benjamin Shine-2

I've got a publisher which lets the user specify options using a  
textbox. I want to set default values that appear in the configuration  
fields when they are first displayed to the user.

In config.jelly for that publisher, I have a textbox in which the user  
can enter a number:
  <f:entry title="Graph Width"
              description="Specify the width of the graph in pixels." >
         <f:textbox name="lcov.graphWidth" value="$
{instance.graphWidth}" />
     </f:entry>

I know that I can do logic to the values that are *submitted* to  
configure; what I want to do here is control the values that appear in  
the HTML *before* the initial submission. How can I make the  
configuration options appear with sensible defaults the first time?

thanks,
ben




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: plugins and jelly: specifying default values for configuration options

Timothy Bingaman
You can use a "default" attribute on the textbox.

    <f:textbox name="lcov.graphWidth" value="${instance.graphWidth}" default="your default value" />

From the documentation:
      The default value of the text box, in case both @value is and 'instance[field]' is null.

cheers,
Timo

2009/6/30 Benjamin Shine <[hidden email]>

I've got a publisher which lets the user specify options using a textbox. I want to set default values that appear in the configuration fields when they are first displayed to the user.

In config.jelly for that publisher, I have a textbox in which the user can enter a number:
 <f:entry title="Graph Width"
            description="Specify the width of the graph in pixels." >
       <f:textbox name="lcov.graphWidth" value="${instance.graphWidth}" />
   </f:entry>

I know that I can do logic to the values that are *submitted* to configure; what I want to do here is control the values that appear in the HTML *before* the initial submission. How can I make the configuration options appear with sensible defaults the first time?

thanks,
ben




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




--
Timothy Bingaman
Software Engineer, Open Cloud Limited
Level 4, 54-56 Cambridge Tce, Wellington, New Zealand
http://www.opencloud.com
t:  +64 4 977 4782
m:  +64 21 027 33614
linkedIn:  http://www.linkedin.com/in/timobingaman
Reply | Threaded
Open this post in threaded view
|

Re: plugins and jelly: specifying default values for configuration options

Benjamin Shine-2
In reply to this post by Benjamin Shine-2
I found the answer in something Kohsuke wrote a few months ago:
http://www.nabble.com/Jelly-plug-in-configuration-and-default-values.-td22497143.html#a22497143

So my solution, based on his post, is just:

  <f:textbox name="lcov.graphWidth" value="$
{h.defaulted(instance.graphWidth,111)}" />

On core/src/main/resources/lib/layout/layout.jelly, a variable "h" is  
defined:
<j:new var="h" className="hudson.Functions" />

By some mechanism that I don't understand (anybody?) hudson.Functions  
is bound to some functions, including defaulted(anAttribute,  
defaultValue). That gets the job done.

-ben


On Jun 29, 2009, at 3:25 PM, Benjamin Shine wrote:

>
> I've got a publisher which lets the user specify options using a
> textbox. I want to set default values that appear in the configuration
> fields when they are first displayed to the user.
>
> In config.jelly for that publisher, I have a textbox in which the user
> can enter a number:
>  <f:entry title="Graph Width"
>              description="Specify the width of the graph in pixels." >
>         <f:textbox name="lcov.graphWidth" value="$
> {instance.graphWidth}" />
>     </f:entry>
>
> I know that I can do logic to the values that are *submitted* to
> configure; what I want to do here is control the values that appear in
> the HTML *before* the initial submission. How can I make the
> configuration options appear with sensible defaults the first time?
>
> thanks,
> ben
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: plugins and jelly: specifying default values for configuration options

Timothy Bingaman
cool, didn't know about that, I guess that'd work too.

Also, just for your info, if you specify the "field" attribute on the f:entry tag you can leave out the name and value on the textbox.

<f:entry title="Graph Width"
            field="graphWidth"
            description="Specify the width of the graph in pixels." >
  <f:textbox default="your default value" />
</f:entry>

2009/6/30 Benjamin Shine <[hidden email]>
I found the answer in something Kohsuke wrote a few months ago:
http://www.nabble.com/Jelly-plug-in-configuration-and-default-values.-td22497143.html#a22497143

So my solution, based on his post, is just:

 <f:textbox name="lcov.graphWidth" value="${h.defaulted(instance.graphWidth,111)}" />

On core/src/main/resources/lib/layout/layout.jelly, a variable "h" is defined:
<j:new var="h" className="hudson.Functions" />

By some mechanism that I don't understand (anybody?) hudson.Functions is bound to some functions, including defaulted(anAttribute, defaultValue). That gets the job done.

-ben



On Jun 29, 2009, at 3:25 PM, Benjamin Shine wrote:


I've got a publisher which lets the user specify options using a
textbox. I want to set default values that appear in the configuration
fields when they are first displayed to the user.

In config.jelly for that publisher, I have a textbox in which the user
can enter a number:
 <f:entry title="Graph Width"
            description="Specify the width of the graph in pixels." >
       <f:textbox name="lcov.graphWidth" value="$
{instance.graphWidth}" />
   </f:entry>

I know that I can do logic to the values that are *submitted* to
configure; what I want to do here is control the values that appear in
the HTML *before* the initial submission. How can I make the
configuration options appear with sensible defaults the first time?

thanks,
ben




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




--
Timothy Bingaman
Software Engineer, Open Cloud Limited
Level 4, 54-56 Cambridge Tce, Wellington, New Zealand
http://www.opencloud.com
t:  +64 4 977 4782
m:  +64 21 027 33614
linkedIn:  http://www.linkedin.com/in/timobingaman
Reply | Threaded
Open this post in threaded view
|

Re: plugins and jelly: specifying default values for configuration options

Benjamin Shine-2
In reply to this post by Benjamin Shine-2
Ah, hudson.Functions is just plain old java:
https://hudson.dev.java.net/nonav/javadoc/hudson/Functions.html

On Jun 29, 2009, at 3:54 PM, Benjamin Shine wrote:

> I found the answer in something Kohsuke wrote a few months ago:
> http://www.nabble.com/Jelly-plug-in-configuration-and-default-values.-td22497143.html#a22497143
>
> So my solution, based on his post, is just:
>
>  <f:textbox name="lcov.graphWidth" value="$
> {h.defaulted(instance.graphWidth,111)}" />
>
> On core/src/main/resources/lib/layout/layout.jelly, a variable "h" is
> defined:
> <j:new var="h" className="hudson.Functions" />
>
> By some mechanism that I don't understand (anybody?) hudson.Functions
> is bound to some functions, including defaulted(anAttribute,
> defaultValue). That gets the job done.
>
> -ben
>
>
> On Jun 29, 2009, at 3:25 PM, Benjamin Shine wrote:
>
>>
>> I've got a publisher which lets the user specify options using a
>> textbox. I want to set default values that appear in the  
>> configuration
>> fields when they are first displayed to the user.
>>
>> In config.jelly for that publisher, I have a textbox in which the  
>> user
>> can enter a number:
>> <f:entry title="Graph Width"
>>             description="Specify the width of the graph in pixels." >
>>        <f:textbox name="lcov.graphWidth" value="$
>> {instance.graphWidth}" />
>>    </f:entry>
>>
>> I know that I can do logic to the values that are *submitted* to
>> configure; what I want to do here is control the values that appear  
>> in
>> the HTML *before* the initial submission. How can I make the
>> configuration options appear with sensible defaults the first time?
>>
>> thanks,
>> ben
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: plugins and jelly: specifying default values for configuration options

Benjamin Shine-2
In reply to this post by Timothy Bingaman
Thanks for the suggestion, but that didn't work for me. I'm running 1.295, though, so this feature might be too new. 


On Jun 29, 2009, at 4:00 PM, Timothy Bingaman wrote:

cool, didn't know about that, I guess that'd work too.

Also, just for your info, if you specify the "field" attribute on the f:entry tag you can leave out the name and value on the textbox.

<f:entry title="Graph Width"
            field="graphWidth"
            description="Specify the width of the graph in pixels." >
  <f:textbox default="your default value" />
</f:entry>

2009/6/30 Benjamin Shine <[hidden email]>
I found the answer in something Kohsuke wrote a few months ago:
http://www.nabble.com/Jelly-plug-in-configuration-and-default-values.-td22497143.html#a22497143

So my solution, based on his post, is just:

 <f:textbox name="lcov.graphWidth" value="${h.defaulted(instance.graphWidth,111)}" />

On core/src/main/resources/lib/layout/layout.jelly, a variable "h" is defined:
<j:new var="h" className="hudson.Functions" />

By some mechanism that I don't understand (anybody?) hudson.Functions is bound to some functions, including defaulted(anAttribute, defaultValue). That gets the job done.

-ben



On Jun 29, 2009, at 3:25 PM, Benjamin Shine wrote:


I've got a publisher which lets the user specify options using a
textbox. I want to set default values that appear in the configuration
fields when they are first displayed to the user.

In config.jelly for that publisher, I have a textbox in which the user
can enter a number:
 <f:entry title="Graph Width"
            description="Specify the width of the graph in pixels." >
       <f:textbox name="lcov.graphWidth" value="$
{instance.graphWidth}" />
   </f:entry>

I know that I can do logic to the values that are *submitted* to
configure; what I want to do here is control the values that appear in
the HTML *before* the initial submission. How can I make the
configuration options appear with sensible defaults the first time?

thanks,
ben




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




--
Timothy Bingaman
Software Engineer, Open Cloud Limited
Level 4, 54-56 Cambridge Tce, Wellington, New Zealand
http://www.opencloud.com
t:  +64 4 977 4782
m:  +64 21 027 33614
linkedIn:  http://www.linkedin.com/in/timobingaman

Reply | Threaded
Open this post in threaded view
|

Re: plugins and jelly: specifying default values for configuration options

Kohsuke Kawaguchi
Administrator
In reply to this post by Benjamin Shine-2

I extended
http://wiki.hudson-ci.org/display/HUDSON/Basic+guide+to+Jelly+usage+in+Hudson
to cover the default value topic.

Benjamin Shine wrote:

> I've got a publisher which lets the user specify options using a  
> textbox. I want to set default values that appear in the configuration  
> fields when they are first displayed to the user.
>
> In config.jelly for that publisher, I have a textbox in which the user  
> can enter a number:
>   <f:entry title="Graph Width"
>               description="Specify the width of the graph in pixels." >
>          <f:textbox name="lcov.graphWidth" value="$
> {instance.graphWidth}" />
>      </f:entry>
>
> I know that I can do logic to the values that are *submitted* to  
> configure; what I want to do here is control the values that appear in  
> the HTML *before* the initial submission. How can I make the  
> configuration options appear with sensible defaults the first time?
>
> thanks,
> ben
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

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

smime.p7s (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

RE: Re: plugins and jelly: specifying default values for configuration options

Sankaran, Nambi
Hi Kohsuke

I'm following
http://wiki.hudson-ci.org/display/HUDSON/Basic+guide+to+Jelly+usage+in+H
udson

If you want the configuration page to have the initial default value,
use @default. The first example shows the literal default value, while
the second example shows the programmatically computed default value:

Where do I add @default ?

<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
  <f:entry title="${%Port}" field="port">
    <f:textbox default="80" />
  </f:entry>
  <f:entry title="${%Host}" field="host">
    <f:textbox default="${descriptor.defaultHost()}/>
  </f:entry>
</j:jelly>
 

-----Original Message-----
From: Kohsuke Kawaguchi [mailto:[hidden email]]
Sent: Wednesday, July 08, 2009 5:30 PM
To: [hidden email]
Subject: Re: plugins and jelly: specifying default values for
configuration options


I extended
http://wiki.hudson-ci.org/display/HUDSON/Basic+guide+to+Jelly+usage+in+H
udson
to cover the default value topic.

Benjamin Shine wrote:
> I've got a publisher which lets the user specify options using a
> textbox. I want to set default values that appear in the configuration

> fields when they are first displayed to the user.
>
> In config.jelly for that publisher, I have a textbox in which the user

> can enter a number:
>   <f:entry title="Graph Width"
>               description="Specify the width of the graph in pixels."
>
>          <f:textbox name="lcov.graphWidth" value="$
> {instance.graphWidth}" />
>      </f:entry>
>
> I know that I can do logic to the values that are *submitted* to
> configure; what I want to do here is control the values that appear in

> the HTML *before* the initial submission. How can I make the
> configuration options appear with sensible defaults the first time?
>
> thanks,
> ben
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: plugins and jelly: specifying default values for configuration options

Kohsuke Kawaguchi
Administrator

To <f:textbox> and other similar tags, as illustrated in the code.

Sankaran, Nambi wrote:

> Hi Kohsuke
>
> I'm following
> http://wiki.hudson-ci.org/display/HUDSON/Basic+guide+to+Jelly+usage+in+H
> udson
>
> If you want the configuration page to have the initial default value,
> use @default. The first example shows the literal default value, while
> the second example shows the programmatically computed default value:
>
> Where do I add @default ?
>
> <j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
>   <f:entry title="${%Port}" field="port">
>     <f:textbox default="80" />
>   </f:entry>
>   <f:entry title="${%Host}" field="host">
>     <f:textbox default="${descriptor.defaultHost()}/>
>   </f:entry>
> </j:jelly>
>  
>
> -----Original Message-----
> From: Kohsuke Kawaguchi [mailto:[hidden email]]
> Sent: Wednesday, July 08, 2009 5:30 PM
> To: [hidden email]
> Subject: Re: plugins and jelly: specifying default values for
> configuration options
>
>
> I extended
> http://wiki.hudson-ci.org/display/HUDSON/Basic+guide+to+Jelly+usage+in+H
> udson
> to cover the default value topic.
>
> Benjamin Shine wrote:
>> I've got a publisher which lets the user specify options using a
>> textbox. I want to set default values that appear in the configuration
>
>> fields when they are first displayed to the user.
>>
>> In config.jelly for that publisher, I have a textbox in which the user
>
>> can enter a number:
>>   <f:entry title="Graph Width"
>>               description="Specify the width of the graph in pixels."
>>
>>          <f:textbox name="lcov.graphWidth" value="$
>> {instance.graphWidth}" />
>>      </f:entry>
>>
>> I know that I can do logic to the values that are *submitted* to
>> configure; what I want to do here is control the values that appear in
>
>> the HTML *before* the initial submission. How can I make the
>> configuration options appear with sensible defaults the first time?
>>
>> thanks,
>> ben
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
> --
> Kohsuke Kawaguchi
> Sun Microsystems                   http://weblogs.java.net/blog/kohsuke/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

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

smime.p7s (4K) Download Attachment