Confluence Web Panel and populate it with Data

Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 16, 2013

hi,

i have created a web panel like so:

<web-panel key="myPanel" location="atl.userprofile" weight="200">
        <resource name="view" type="velocity" location="/templates/user/viewmyskills.vm"/>
    </web-panel>

and now i would like to populate it dynamically with data from DB. Which is the best way to do it?

Thanks!!!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2013

I have solved this problem! I have added a new Context Provider to my Web Panel:

<web-panel key="myPanel" location="atl.userprofile" weight="200">
        <context-provider class="de.twt.confluence.plugins.contextprovider.UserSkillPanelContextProvider" />
        <resource name="view" type="velocity" location="/templates/user/viewmyskills.vm"/>
    </web-panel>

Java:

public class UserSkillPanelContextProvider implements ContextProvider{

    private UserServiceImpl userService;

    public UserSkillPanelContextProvider(UserServiceImpl userService) {
        this.userService = userService;
    }

    @Override
    public void init(Map<String, String> params) throws PluginParseException {
    }

    @Override
    public Map<String, Object> getContextMap(Map<String, Object> context) {
        User user = AuthenticatedUserThreadLocal.getUser();

        UserVO userVO = userService.fetchUserByEmail(user);

        context.put("userVO", userVO);

        return context;
    }
}

*.vm Page:

<table style="width: 1000px;">
    <caption style="text-align: left;" ><b>Qualifikationen Übersicht</b></caption>
    #foreach($!userSkill in $!userVO.userSkills)
        <tr>
            <td style="vertical-align: middle">$!userSkill.skillEntity.skillTitle</td>
            <td style="vertical-align: middle">$!userSkill.selfAssessment</td>
        </tr>
    #end
</table>

Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 17, 2013

is there a way to use com.atlassian.plugin.web.model.WebPanel? some example of getHtml(...) method usage?

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 17, 2013

There will be plenty of examples of using WebPanel.getHtml() within the Confluence source code - if you have a commercial licence for Confluence you should be able to login to my.atlassian.com and download it.

TAGS
AUG Leaders

Atlassian Community Events