Wouldn't it be simpler to use a @DataBoundConstructor, i.e. make your class 
describable? Then you don't need to overwrite the newInstance method.

I.e. I have a jelly snippet:

  <f:entry title="${%Parser}" description="${%description.parser}" 
field="parserName">
    <f:select/>
  </f:entry>

And the corresponding class:

public class ConsoleParser extends AbstractDescribableImpl<ConsoleParser> {
    private final String parserName;

    /**
     * Creates a new instance of {@link ConsoleParser}.
     *
     * @param parserName
     *            the name of the parser to use
     */
    @DataBoundConstructor
    public ConsoleParser(final String parserName) {
        super();

        this.parserName = parserName;
    }

[...]


    /**
     * Dummy descriptor for {@link ConsoleParser}.
     *
     * @author Ulli Hafner
     */
   @Extension
   public static class DescriptorImpl extends Descriptor<ConsoleParser> {
       /**
        * Returns the available parsers. These values will be shown in the list
        * box of the config.jelly view part.
        *
        * @return the model of the list box
        */
       public ListBoxModel doFillParserNameItems() {
           return ParserRegistry.getParsersAsListModel();
       }

       @Override
       public String getDisplayName() {
           return StringUtils.EMPTY;
       }
   }


Full code is available at 
https://github.com/jenkinsci/warnings-plugin/blob/master/src/main/java/hudson/plugins/warnings/ConsoleParser.java

Ulli

Am 28.11.2012 um 13:17 schrieb isabel <[email protected]>:

> Hi all,
> 
> This is part of my config.jelly formed by a  dropdownlist and a textbox:
> 
>                 <f:entry title="Node" field="node">
>                     <f:select  name="subscription.node"/>
>                 </f:entry>
> 
>                 <f:entry title="Filter" field="filter">
>                     <f:expandableTextbox name="subscription.filter"/>
>                 </f:entry>
> 
> The dropdownlist is correctly filled by the method "doFillNodesItems()".
> I can bind the value of the textbox with a java object but I cant bind the 
> value of the selected item of the dropdownlist. What am I doing wrong?
> 
>         @Override
>         public Trigger<?> newInstance(StaplerRequest req, JSONObject 
> formData) throws FormException {
> 
>             List<SubscriptionProperties> tasksprops = 
> req.bindParametersToList(SubscriptionProperties.class, "subscription.");
>             return new Myclass(tasksprops);
> 
>         }
> 
> Thanks for your help!
> Isabel
> 

Reply via email to