|
I'm trying to implement the Describable Extension point for one of my
views but I can't get the data binding working for the list box. In my publisher I have the following snippet to add a list of parsers to use in the warnings plug-in: <f:entry title="${%Scan workspace files}" description="${%description.logFilesParsers}"> <f:repeatableProperty field="parserConfigurations"/> </f:entry> The parser configurations are instances of a simple bean extending AbstractDescribableImpl (with attributes pattern and parserName). For that Describable class I have the following config.jelly: <j:invokeStatic var="allParsers" className="hudson.plugins.warnings.parser.ParserRegistry" method="getAvailableParsers" /> <f:entry field="pattern" title="${%File pattern}"> <f:textbox /> </f:entry> <f:entry title="${%Parser}" description="${%description.parser}"> <select class="setting-input" name="parserName"> <j:forEach var="availableParser" items="${allParsers}"> <f:option selected="${availableParser.isInGroup(it.parserName)}" value="${availableParser.group}">${availableParser.name}</f:option> </j:forEach> </select> </f:entry> The data binding of the textbox ('pattern' field) works correctly, however the binding to the list box ('parserName') does work only partly. If the user selects an item in the list box, my constructor of the Describable is correctly called with the new values for 'pattern' and 'parserName'. However I can't set the selected value for the list box when the view is initialized: always the first value is selected. How do I define the selected value using data binding? Or how do I reference an attribute of the describable instance in an expression? I tried - selected="${availableParser.isInGroup(it.parserName)}" - selected="${availableParser.isInGroup(instance.parserName)}" - selected="${availableParser.isInGroup(parserName)}" but nothing worked. When I use a String value, then the selection does work: - selected="${availableParser.isInGroup('Doxygen')}" Any ideas? Ulli |
|
Quoting Ullrich Hafner <[hidden email]>:
> I'm trying to implement the Describable Extension point for one of my > views but I can't get the data binding working for the list box. > > In my publisher I have the following snippet to add a list of parsers to > use in the warnings plug-in: > > <f:entry title="${%Scan workspace files}" > description="${%description.logFilesParsers}"> > <f:repeatableProperty field="parserConfigurations"/> > </f:entry> > > The parser configurations are instances of a simple bean extending > AbstractDescribableImpl (with attributes pattern and parserName). > > For that Describable class I have the following config.jelly: > > <j:invokeStatic var="allParsers" > className="hudson.plugins.warnings.parser.ParserRegistry" > method="getAvailableParsers" /> > > <f:entry field="pattern" title="${%File pattern}"> > <f:textbox /> > </f:entry> > <f:entry title="${%Parser}" description="${%description.parser}"> > <select class="setting-input" name="parserName"> > <j:forEach var="availableParser" items="${allParsers}"> > <f:option > selected="${availableParser.isInGroup(it.parserName)}" > > value="${availableParser.group}">${availableParser.name}</f:option> > </j:forEach> > </select> > </f:entry> > > The data binding of the textbox ('pattern' field) works correctly, > however the binding to the list box ('parserName') does work only > partly. If the user selects an item in the list box, my constructor of > the Describable is correctly called with the new values for 'pattern' > and 'parserName'. However I can't set the selected value for the list > box when the view is initialized: always the first value is selected. > > How do I define the selected value using data binding? Or how do I > reference an attribute of the describable instance in an expression? > > I tried > - selected="${availableParser.isInGroup(it.parserName)}" > - selected="${availableParser.isInGroup(instance.parserName)}" > - selected="${availableParser.isInGroup(parserName)}" > but nothing worked. When I use a String value, then the selection does work: > - selected="${availableParser.isInGroup('Doxygen')}" > > Any ideas? > > Ulli Not 100% sure I'm reading your explanation correctly, but something like the following should do the trick jelly: <f:entry field="pattern" title="${%File pattern}"> <f:textbox /> </f:entry> <f:entry title="${%Parser}" description="${%description.parser}" field="parserName"> <f:select/> </f:entry> descriptor: public ListBoxModel doFillParserNameItems() { ListBoxModel items = new ListBoxModel(); for (ParserConfiguration parser: ParserRegistry.getAvailableParsers()) { items.add(parser.name); } return items; } Hope that helps, Bap. |
|
On 05/30/2012 12:40 PM, Bap wrote:
> Quoting Ullrich Hafner <[hidden email]>: > >> I'm trying to implement the Describable Extension point for one of my >> views but I can't get the data binding working for the list box. >> >> In my publisher I have the following snippet to add a list of parsers to >> use in the warnings plug-in: >> >> <f:entry title="${%Scan workspace files}" >> description="${%description.logFilesParsers}"> >> <f:repeatableProperty field="parserConfigurations"/> >> </f:entry> >> >> The parser configurations are instances of a simple bean extending >> AbstractDescribableImpl (with attributes pattern and parserName). >> >> For that Describable class I have the following config.jelly: >> >> <j:invokeStatic var="allParsers" >> className="hudson.plugins.warnings.parser.ParserRegistry" >> method="getAvailableParsers" /> >> >> <f:entry field="pattern" title="${%File pattern}"> >> <f:textbox /> >> </f:entry> >> <f:entry title="${%Parser}" description="${%description.parser}"> >> <select class="setting-input" name="parserName"> >> <j:forEach var="availableParser" items="${allParsers}"> >> <f:option >> selected="${availableParser.isInGroup(it.parserName)}" >> >> value="${availableParser.group}">${availableParser.name}</f:option> >> </j:forEach> >> </select> >> </f:entry> >> >> The data binding of the textbox ('pattern' field) works correctly, >> however the binding to the list box ('parserName') does work only >> partly. If the user selects an item in the list box, my constructor of >> the Describable is correctly called with the new values for 'pattern' >> and 'parserName'. However I can't set the selected value for the list >> box when the view is initialized: always the first value is selected. >> >> How do I define the selected value using data binding? Or how do I >> reference an attribute of the describable instance in an expression? >> >> I tried >> - selected="${availableParser.isInGroup(it.parserName)}" >> - selected="${availableParser.isInGroup(instance.parserName)}" >> - selected="${availableParser.isInGroup(parserName)}" >> but nothing worked. When I use a String value, then the selection >> does work: >> - selected="${availableParser.isInGroup('Doxygen')}" >> >> Any ideas? >> >> Ulli > > Not 100% sure I'm reading your explanation correctly, but something > like the following should do the trick > > jelly: > > <f:entry field="pattern" title="${%File pattern}"> > <f:textbox /> > </f:entry> > <f:entry title="${%Parser}" description="${%description.parser}" > field="parserName"> > <f:select/> > </f:entry> > > descriptor: > > public ListBoxModel doFillParserNameItems() { > ListBoxModel items = new ListBoxModel(); > for (ParserConfiguration parser: > ParserRegistry.getAvailableParsers()) { > items.add(parser.name); > } > return items; > } > > Hope that helps, > Bap. > Thanks! That did the trick. I updated the wiki with an example. We should have more of these snippets in the wiki ;-) Ulli |
| Powered by Nabble | Edit this page |
