提交 b2f13179 编写于 作者: R redsolo

[FIXED HUDSON-2289] Fixed so the page decorator is properly configured

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11823 71c3de6d-444a-0410-be80-ed276b4c234a
上级 287b3b10
......@@ -1631,6 +1631,9 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
for( JobPropertyDescriptor d : Jobs.PROPERTIES )
result &= configureDescriptor(req,json,d);
for( PageDecorator d : PageDecorator.ALL )
result &= configureDescriptor(req,json,d);
for( JSONObject o : StructuredForm.toList(json,"plugin"))
pluginManager.getPlugin(o.getString("name")).getPlugin().configure(o);
......
package hudson.model;
import java.util.ArrayList;
import java.util.List;
import hudson.ExtensionPoint;
import hudson.Plugin;
import hudson.util.DescriptorList;
/**
* Participates in the rendering of HTML pages for all pages of Hudson.
......@@ -64,5 +66,5 @@ public abstract class PageDecorator extends Descriptor<PageDecorator> implements
/**
* All the registered instances.
*/
public static final DescriptorList<PageDecorator> ALL = new DescriptorList<PageDecorator>();
public static final List<PageDecorator> ALL = new ArrayList<PageDecorator>();
}
......@@ -3,8 +3,13 @@ package hudson.pages;
import static com.gargoylesoftware.htmlunit.WebAssert.*;
import hudson.model.PageDecorator;
import net.sf.json.JSONObject;
import org.jvnet.hudson.test.HudsonTestCase;
import org.kohsuke.stapler.StaplerRequest;
import com.gargoylesoftware.htmlunit.html.HtmlButton;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
public class SystemConfigurationTestCase extends HudsonTestCase {
......@@ -27,19 +32,36 @@ public class SystemConfigurationTestCase extends HudsonTestCase {
HtmlPage page = new WebClient().goTo("configure");
assertElementPresent(page, "hudson-pages-SystemConfigurationTestCase$PageDecoratorImpl");
HtmlForm form = page.getFormByName("config");
form.getInputByName("_.decoratorId").setValueAttribute("this_is_a_profile");
form.submit((HtmlButton)last(form.getHtmlElementsByTagName("button")));
assertEquals("The decorator field was incorrect", "this_is_a_profile", pageDecoratorImpl.getDecoratorId());
}
/**
* PageDecorator for bug#2289
*/
private static class PageDecoratorImpl extends PageDecorator {
private String decoratorId;
protected PageDecoratorImpl() {
super(PageDecoratorImpl.class);
}
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
decoratorId = json.getString("decoratorId");
return true;
}
@Override
public String getDisplayName() {
return "PageDecoratorImpl";
}
public String getDecoratorId() {
return decoratorId;
}
}
}
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:section title="PageDecorator">
<f:entry title="PageDecoratorId">
<f:textbox field="decoratorId"/>
</f:entry>
</f:section>
</j:jelly>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册