Editing a Dashboard view

31 views
Skip to first unread message

Jacqueline Taing

unread,
Jun 30, 2016, 6:50:33 PM6/30/16
to Jenkins Developers
I wrote a plugin that extends from Dashboard view. The dashboard has default values for entries in the Create View form. Sample content in configure-entries.jelly is below:

    <f:section title="Dashboard Content">
        <f:entry title="Build Age (Days)"
                 help="/plugin/quality-dashboard/help/help-configBuildAge.html">
            <f:textbox name="daysFilter" field="daysFilter" default="7" />
        </f:entry>

The dashboard gets created properly (e.g. non-default values are used in the dashboard created), but when I click Edit View link, the form does not show the values that were used to create the view.  Instead, it shows the default values for the fields.

How do I properly implement this so that current values used are propagated? Do I need to create a different .jelly file for Edit View?

Thanks!
-jacqui

Ulli Hafner

unread,
Jul 1, 2016, 2:03:04 AM7/1/16
to jenkin...@googlegroups.com
If values are not restored then check:
- do you have public getters for all your fields of the entry?
- do the names of fields of the entry match with the names in the constructor?
--
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 jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/e6363b40-e65d-4f82-847e-faf417ccbce2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jacqueline Taing

unread,
Jul 5, 2016, 1:13:21 PM7/5/16
to Jenkins Developers
The answer to both questions is yes.

The problem is when I do Edit View. Somehow, the values entered when view was created is not getting persisted.  I have a feeling I'm missing a call to save these values?  How do I do that?

Here are the relevant functions in .java file for my dashboard (extends hudson.plugins.view.dashboard.Dashboard):

public class QualityDashboard extends Dashboard {

    /**
     * QualityDashboard constructor.
     * 
     * @param name Name for this dashboard
     */
    @DataBoundConstructor
    public QualityDashboard(String name) {
        super(name);
    }

    @Override
    protected synchronized void submit(StaplerRequest sr) 
            throws IOException, ServletException, Descriptor.FormException {
        super.submit(sr);
        JSONObject json = sr.getSubmittedForm();
        if (sr.getParameter("daysFilter") != null) {
            buildIncludeDays = Integer.parseInt(sr.getParameter("daysFilter"));
        }
        else {
            buildIncludeDays = DEFAULT_BUILD_INCLUDE_DAYS;
        }
        if (sr.getParameter("buildFlowFolder") != null) {
            buildFlowFolder = sr.getParameter("buildFlowFolder");
        }
        if (sr.getParameter("buildFlowNameFilter") != null) {
            buildFlowNameFilter = sr.getParameter("buildFlowNameFilter");
        }
        if (sr.getParameter("testFlowFolder") != null) {
            testFlowFolder = sr.getParameter("testFlowFolder");
        }
        if (sr.getParameter("testFlowNameFilter") != null) {
            testFlowNameFilter = sr.getParameter("testFlowNameFilter");
        }
        if (sr.getParameter("testIgnoreList") != null) {
            String ignoreStr = sr.getParameter("testIgnoreList");
            ignoreFailuresList = Arrays.asList(ignoreStr.split(","));
        }
        if (sr.getParameter("testReviewList") != null) {
            String reviewStr = sr.getParameter("testReviewList");
            reviewFailuresList = Arrays.asList(reviewStr.split(","));
        }
        // TODO: Exclude other DashboardPortlets 
        topPortlets = Descriptor.newInstancesFromHeteroList(sr, json, 
                                                            "topPortlet", 
                                                            DashboardPortlet.all());
        // TODO: Exclude other DashboardPortlets 
        bottomPortlets = Descriptor.newInstancesFromHeteroList(sr, json, 
                                                               "bottomPortlet", 
                                                               DashboardPortlet.all());
    }

    /**
     * Required for View configuration
     */
    @Extension 
    public static final class DescriptorImpl extends ViewDescriptor {
        /**
         * Get the display name
         *
         * @return display name
         */
        @Override
        public String getDisplayName() {
            return "DSSD Build Quality Dashboard";
        }
    }


Thanks,
-jaqui
Reply all
Reply to author
Forward
0 new messages