Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Is it possible to create xwork actions for a Crowd Plugin?

daviderickson December 17, 2011

I don't see it listed https://developer.atlassian.com/display/CROWDDEV/Crowd+Developer+Documentation but it looks like Crowd internally is using xwork.

And if not, can I use a view technology like JSP and pass parameters from my servlet to a JSP file? And if so how?

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

1 vote
Answer accepted
Alexei Uvarov December 18, 2011

Hi, I don't know how make crowd plugin work with jsp pages or velocity templates, but I have managed to make it work with freemarker. My code is:

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
    <plugin-info>
        <description>${project.description}</description>
        <version>${project.version}</version>
        <vendor name="${project.organization.name}" url="${project.organization.url}" />
    </plugin-info>
    
    <component-import key="webResourceManager" interface="com.atlassian.plugin.webresource.WebResourceManager" />
    <component-import key="applicationProperties" interface="com.atlassian.sal.api.ApplicationProperties"/>
    <component-import key="i18nResolver" interface="com.atlassian.sal.api.message.I18nResolver" />
    
    <!-- Header Items -->
    <web-item key="tokens" name="Tokens Management" section="topnav" weight="10">
        <label key="Token management"/>
        <link linkId="topnavTokensManagement">/console/secure/plugins/cargosoft/managetokens.action</link>
    </web-item>
    
    <!-- Application Components - Left-Hand Side -->
    <web-section key="tokensnav" name="Tokens Navigation" location="left" weight="90">
        <condition class="com.atlassian.crowd.plugin.web.conditions.SitemeshPropertiesCondition">
            <param name="propertyName">meta.section</param>
            <param name="propertyValues">tokens</param>
        </condition>
    </web-section>
    
    <xwork name="Tokens Action" key="managetokens">
        <package name="managetokens" extends="default" namespace="/console/secure/plugins/cargosoft">
        	<default-interceptor-ref name="defaultStack"/>
        	
            <action name="managetokens" class="com.cargosoft.crowd.plugin.TokensAction">
                <result name="success" type="freemarker">/templates/view.ftl</result>
                <result name="error" type="freemarker">/templates/view.ftl</result>
            </action>
        </package>
    </xwork>
    

    
</atlassian-plugin>

public class TokensAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private final WebResourceManager webResourceManager;
	
	protected String firstName;
	protected String lastName;
	
	public TokensAction(WebResourceManager webResourceManager){
		this.webResourceManager = webResourceManager;
	}
	
	public void setFirstName(final String firstName) {this.firstName = firstName;}
	public String getFirstName() {return null == firstName ? "A" : firstName;}
	public void setLastName(final String lastName) {this.lastName = lastName;}
	public String getLastName() {return null == lastName ? "U" : lastName;}

	@Override
	public String execute() throws Exception{
		return SUCCESS;
	}
}

view.ftl

<html>
  <head>
    <title>Hello</title>
   	<meta name="decorator" content="myDecorator" />
  </head>
  <body>
    Hello ${action.firstName} ${action.lastName}
  </body>
</html>

And so, I have another quastion... Does crowd support velocity or jsp in plugins???

And I have anothe problem, see https://answers.atlassian.com/questions/25104/why-main-menu-disappear-from-page-in-crowd-plugin

daviderickson December 29, 2011

This is great, thanks!!

Mario Anstoots April 19, 2017

Hi,

if i do it your way it says no action mapped for... and so on. 

Any idea what could be wrong? I used your code and it does not work.

the url for your action is: www.myurl.com/crowd/console/secure/plugins/cargosoft/managetokens.action
right?

TAGS
AUG Leaders

Atlassian Community Events