Skip to content

Instantly share code, notes, and snippets.

@randycoulman
Created June 14, 2012 23:53
Show Gist options
  • Save randycoulman/2933711 to your computer and use it in GitHub Desktop.
Save randycoulman/2933711 to your computer and use it in GitHub Desktop.
Why is the optional block starting out unchecked, but expanded?
<f:optionalBlock name="generatingParcelBuilderInputFile" checked="${instance.getParcelBuilderInputFilename() != null}"
title="Generate input file for ParcelBuilder?">
<f:entry title="Filename" field="parcelBuilderInputFilename">
<f:textbox/>
</f:entry>
</f:optionalBlock>
public class StoreSCM extends SCM {
private String parcelBuilderInputFilename;
@DataBoundConstructor
public StoreSCM(String parcelBuilderInputFilename) {
this.parcelBuilderInputFilename = parcelBuilderInputFilename;
}
public String getParcelBuilderInputFilename() {
return parcelBuilderInputFilename;
}
//...
@Override
public DescriptorImpl getDescriptor() {
return (DescriptorImpl)super.getDescriptor();
}
@Extension
public static final class DescriptorImpl extends SCMDescriptor<StoreSCM> {
public DescriptorImpl() {
super(StoreSCM.class, null);
load();
}
@Override
public String getDisplayName() {
return "Store";
}
@Override
public boolean configure(StaplerRequest request, JSONObject formData) throws FormException {
request.bindJSON(this, formData);
save();
return true;
}
@Override
public StoreSCM newInstance(StaplerRequest request, JSONObject formData) throws FormException {
String parcelBuilderInputFilename = null;
Object parcelBuilderOptions = formData.get("generatingParcelBuilderInputFile");
if (parcelBuilderOptions != null) {
parcelBuilderInputFilename = ((JSONObject) parcelBuilderOptions).getString("parcelBuilderInputFilename");
}
return new StoreSCM(parcelBuilderInputFilename);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment