What was wrong with using StandardListBoxModel?

e.g.

return new StandardUsernameListBoxModel()
    .withEmptySelection()

.withAll(CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class,
owner, ACL.SYSTEM, Collections.<DomainRequirement>emptyList()))

On 25 November 2015 at 11:10, Aldrin Leal <[email protected]> wrote:

> Silly question: How can I make a Credentials Select optional? I've tried
> the optional block, to no avail. Right now, I just left this on my Model as
> a Kludge:
>
> config.jelly:
>
> <f:section title="AWS Credentials and Region">
>     <f:entry title="${%Credentials}" field="credentialsId">
>         <c:select expressionAllowed="true"/>
>     </f:entry>
>
>     <f:entry title="AWS Region" field="awsRegion">
>         <f:textbox default="us-east-1"/>
>     </f:entry>
>
>     <!-- Not yet
>     <f:validateButton method="validateCredentials" title="Validate 
> Credentials" with="credentialsId,awsRegion"/>
>     -->
> </f:section>
>
> and on the Descriptor:
>
> public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item owner) {
>     if (owner == null || !owner.hasPermission(Item.CONFIGURE)) {
>         return new ListBoxModel();
>     }
>     // when configuring the job, you only want those credentials that are 
> available to ACL.SYSTEM selectable
>     // as we cannot select from a user's credentials unless they are the only 
> user submitting the build
>     // (which we cannot assume) thus ACL.SYSTEM is correct here.
>     List<IdCredentials> credentials = new ArrayList<>();
>
>     credentials.add(new 
> UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "NONE", "None", "", 
> ""));
>
>     
> credentials.addAll(CredentialsProvider.lookupCredentials(AmazonWebServicesCredentials.class,
>  owner, ACL.SYSTEM, Collections.<DomainRequirement>emptyList()));
>
>     return new Model().withAll(credentials);
> }
>
> Works, but... Ugly.
>
>
>
> Any ideas?
> --
> -- Aldrin Leal, <[email protected]> / http://about.me/aldrinleal
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/CALpo8NvOUwhiQbxAQsUBwNfpaSsGmambjgt8MDcvvFPgR7U9%2Bw%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/CALpo8NvOUwhiQbxAQsUBwNfpaSsGmambjgt8MDcvvFPgR7U9%2Bw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CA%2BnPnMzhyrDjw2xaQ%2BJjOoXMi_05FeFEpV_Q%3DQabjr_PbVYmxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to