Create a GUI with templates and AUI

Similar documents
Creating Java EE Applications and Servlets with IntelliJ IDEA

Hands on exercise for

Maven2. Configuration and Build Management. Robert Reiz

Developing an EJB3 Application. on WebSphere 6.1. using RAD 7.5

PA165 - Lab session - Web Presentation Layer

Software project management. and. Maven

Java EE Introduction, Content. Component Architecture: Why and How Java EE: Enterprise Java

Web Container Components Servlet JSP Tag Libraries

How To Understand The Architecture Of Java 2Ee, J2Ee, And J2E (Java) In A Wordpress Blog Post

Continuous integration in OSGi projects using Maven (v:0.1) Sergio Blanco Diez

Database Applications Recitation 10. Project 3: CMUQFlix CMUQ s Movies Recommendation System

COMPUTACIÓN ORIENTADA A SERVICIOS (PRÁCTICA) Dr. Mauricio Arroqui EXA-UNICEN

Struts Tools Tutorial. Version: M5

Configure a SOAScheduler for a composite in SOA Suite 11g. By Robert Baumgartner, Senior Solution Architect ORACLE

Web Applications. For live Java training, please see training courses at

Penetration from application down to OS

Supplement IV.E: Tutorial for Tomcat. For Introduction to Java Programming By Y. Daniel Liang

Drupal CMS for marketing sites

WebSphere and Message Driven Beans

Web Development in Java Live Demonstrations (Live demonstrations done using Eclipse for Java EE 4.3 and WildFly 8)

2. Follow the installation directions and install the server on ccc

Java Servlet Tutorial. Java Servlet Tutorial

Web Application Programmer's Guide

Tutorial c-treeace Web Service Using Java

Developing Web Views for VMware vcenter Orchestrator

Joomla! Override Plugin

Build management & Continuous integration. with Maven & Hudson

Ipswitch Client Installation Guide

Smooks Dev Tools Reference Guide. Version: GA

Outline. CS 112 Introduction to Programming. Recap: HTML/CSS/Javascript. Admin. Outline

Tutorial: Building a Web Application with Struts

Web Development using PHP (WD_PHP) Duration 1.5 months

Sonatype CLM for Maven. Sonatype CLM for Maven

by Charles Souillard CTO and co-founder, BonitaSoft

Presentation of Enterprise Service Bus(ESB) and. Apache ServiceMix. Håkon Sagehaug

ACI Commerce Gateway Hosted Payment Page Guide

ResPAK Internet Module

Community Builder Language Package Guide Updated for CB 1.2.3

Builder User Guide. Version 5.4. Visual Rules Suite - Builder. Bosch Software Innovations

Data Tool Platform SQL Development Tools

1 Building, Deploying and Testing DPES application

An introduction to web programming with Java

Principles and Techniques of DBMS 5 Servlet

DocumentsCorePack for MS CRM 2011 Implementation Guide

Simplify Your Web App Development Using the Spring MVC Framework

Vim, Emacs, and JUnit Testing. Audience: Students in CS 331 Written by: Kathleen Lockhart, CS Tutor

Using CertAgent to Obtain Domain Controller and Smart Card Logon Certificates for Active Directory Authentication

7 Web Databases. Access to Web Databases: Servlets, Applets. Java Server Pages PHP, PEAR. Languages: Java, PHP, Python,...

BAPI. Business Application Programming Interface. Compiled by Y R Nagesh 1

Amazon Glacier. Developer Guide API Version

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

Handling the Client Request: Form Data

INTRODUCTION TO WEB TECHNOLOGY

OCS Training Workshop LAB13. Ethernet FTP and HTTP servers

White Label ios Application Installation and Customization Guide

Hands-On Lab. Web Development in Visual Studio Lab version: Last updated: 12/10/2010. Page 1

Joomla! template Blendvision v 1.0 Customization Manual

Aspect WordPress Theme

Implementing the Shop with EJB

IBM Unica emessage Version 8 Release 6 February 13, User's Guide

Servlets. Based on Notes by Dave Hollinger & Ethan Cerami Also, the Online Java Tutorial by Sun

ShoreTel Enterprise Contact Center 8 Installing and Implementing Chat

Preface. Motivation for this Book

Builder User Guide. Version Visual Rules Suite - Builder. Bosch Software Innovations

Mobile Application Development

DEMO ONLY VERSION. Easy CramBible Lab M Magento Front End Developer Certification Exam. ** Single-user License **

Java Server Pages combined with servlets in action. Generals. Java Servlets

Microsoft Expression Web

We automatically generate the HTML for this as seen below. Provide the above components for the teaser.txt file.

Building Web Applications, Servlets, JSP and JDBC

Course Information Course Number: IWT 1229 Course Name: Web Development and Design Foundation

Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1

ACM Crossroads Student Magazine The ACM's First Electronic Publication

opencrx Language Localization Guide

Catalog Web service and catalog commerce management center customization

INF 111 / CSE 121. Homework 4: Subversion Due Tuesday, July 14, 2009

LabVIEW Report Generation Toolkit for Microsoft Office User Guide

Building A Very Simple Web Site

How to Improve Database Connectivity With the Data Tools Platform. John Graham (Sybase Data Tooling) Brian Payton (IBM Information Management)

User Guide. Making EasyBlog Your Perfect Blogging Tool

Building A Very Simple Website

LabVIEW Report Generation Toolkit for Microsoft Office

Administration: Users and Roles

Dreamweaver Tutorial - Dreamweaver Interface

No no-argument constructor. No default constructor found

Citrix StoreFront. Customizing the Receiver for Web User Interface Citrix. All rights reserved.

Installation and Configuration Guide

EVALUATION ONLY. WA2088 WebSphere Application Server 8.5 Administration on Windows. Student Labs. Web Age Solutions Inc.

Hadoop Basics with InfoSphere BigInsights

Model-View-Controller. and. Struts 2

Introduction to J2EE Web Technologies

Visa Checkout September 2015

How To Create A Website Template On Sitefinity

White Paper. JavaServer Faces, Graphical Components from Theory to Practice

Virtual Open-Source Labs for Web Security Education

LabVIEW Internet Toolkit User Guide

Quick start. A project with SpagoBI 3.x

Transcription:

Create a GUI with templates and AUI You've added SAL modules and built the foundation for an interactive plugin by creating a servlet component. Now, you'll add a GUI for your users to input data. You can use resources Atlassian provides in the Atlassian User Interface (AUI). This section of the tutorial will walk you through creating and managing Velocity templates, adding CSS, and viewing your plugin in its GUI form. This section includes the following instructions: Introduction to AUI (Atlassian User Interface) Step 1. Update dependencies in the pom.xml Step 2. Create a Velocity template Step 3. Update MyPluginServlet Step 4. Add a decorator and CSS Next steps Introduction to AUI (Atlassian User Interface) AUI is a library of resources you can use to make your plugin visually integrated with Atlassian products. The AUI library includes CSS, JavaScript, and other templates. Using resources from this library ensures your plugin interface is compliant with Atlassian Design Guidelines (ADG). In earlier steps, you added a component module called TemplateRenderer. Here, you'll update your source code to import TemplateRenderer. You'll configure TemplateRenderer to use a Velocity template to format your user interface. Then, you'll add AUI elements and templates for TemplateRenderer to display for an Atlassian look and feel. Step 1. Update dependencies in the pom.xml Here, you'll update the dependencies to reflect the TemplateRenderer module you added earlier. 1. Refresh your project in Eclipse. 2. 3. 4. 5. Open your pom.xml. Locate the section. Find the com.atlassian.sal group. Add the templaterenderer in a dependency group above the com.atlassian.sal group. <groupid>com.atlassian.templaterenderer</groupid> <artifactid>atlassian-template-renderer-api</artifactid> <version>1.3.1</version> Expand to see the entire pom.xml. Check your pom.xml: <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"

2 xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.atlassian.plugins.tutorial.refapp</groupid> <artifactid>adminui</artifactid> <version>1.0-snapshot</version> <organization> <name>awesomeness Inc</name> <url>http://www.awesomebreedsmoarawesome.com/</url> </organization> <name>adminui</name> <description>this is the com.atlassian.plugins.tutorial.refapp:adminui plugin for Atlassian Refapp.</description> <packaging>atlassian-plugin</packaging> <dependencies> <groupid>junit</groupid> <artifactid>junit</artifactid> <version>4.10</version> <scope>test</scope> <groupid>javax.servlet</groupid> <artifactid>servlet-api</artifactid> <version>2.4</version> <groupid>com.atlassian.templaterenderer</groupid> <artifactid>atlassian-template-renderer-api</artifactid> <version>1.3.1</version> <groupid>com.atlassian.sal</groupid> <artifactid>sal-api</artifactid> <version>2.7.1</version> <groupid>org.slf4j</groupid> <artifactid>slf4j-simple</artifactid> <version>1.5.8</version> <!-- WIRED TEST RUNNER DEPENDENCIES --> <groupid>com.atlassian.plugins</groupid> <artifactid>atlassian-plugins-osgi-testrunner</artifactid> <version>$plugin.testrunner.version</version> <scope>test</scope> <groupid>javax.ws.rs</groupid> <artifactid>jsr311-api</artifactid>

3 <version>1.1.1</version> <groupid>com.google.code.gson</groupid> <artifactid>gson</artifactid> <version>2.2.2-atlassian-1</version> <groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> <version>1.6.6</version> <groupid>org.mockito</groupid> <artifactid>mockito-all</artifactid> <version>1.8.5</version> <scope>test</scope> </dependencies> <dependencymanagement> <dependencies> <groupid>com.atlassian.refapp</groupid> <artifactid>atlassian-platform</artifactid> <version>$refapp.version</version> <type>pom</type> <scope>import</scope> </dependencies> </dependencymanagement> <build> <plugins> <plugin> <groupid>com.atlassian.maven.plugins</groupid> <artifactid>maven-refapp-plugin</artifactid> <version>$amps.version</version> <extensions>true</extensions> <configuration> <productversion>$refapp.version</productversion> </configuration> </plugin> <plugin> <artifactid>maven-compiler-plugin</artifactid> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> <properties> <refapp.version>2.19.0</refapp.version> <amps.version>4.2.2</amps.version>

4 <plugin.testrunner.version>1.1.1</plugin.testrunner.version> </properties> </project> 6. 7. Save and close the file in Eclipse. Update your Eclipse changes from your project root. $ atlas-mvn eclipse:eclipse Step 2. Create a Velocity template Atlassian applications use both.soy (Soy) and.vm (Velocity) templates for rendering user interfaces. In this example, you'll create a Velocity template to support your GUI. 1. Navigate to your project root in terminal. $ cd ~/atlastutorial/adminui 2. Drill down to your /resources directory. $ cd src/main/resources 3. Create an admin.vm Velocity template. You'll be prompted to paste content into the VI editor after this command. $ cat > admin.vm 4. Note that if you decide to create this file within an IDE or some other editor, ensure the encoding is UTF-8 - if you don't you'll get odd characters appearing in the output Paste the following into the editor:

5 <html> <head> <title>my Admin</title> </head> <body> <form id="admin"> <label for="name">name</label> <input type="text" id="name" name="name"> <label for="age">age</label> <input type="text" id="age" name="age"> <input type="submit" value="save"> </form> </body> </html> 5. Click Escape, then type :sq to save the entry and exit the vi editor. To review the contents of admin.vm, you can enter the following command: $ cat admin.vm Step 3. Update MyPluginServlet Up until this point, your servlet has been displaying HTML from your MyPluginServlet class. Now you'll update the class to render content using the TemplateRenderer component import you added earlier. Templa terenderer will display the admin.vm template you just created. 1. Update MyPluginServlet.java to import TemplateRenderer and use your new admin.vm template. MyPluginServlet should look as follows: package com.atlassian.plugins.tutorial.refapp; import org.slf4j.logger; import org.slf4j.loggerfactory; import javax.servlet.*; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import java.io.ioexception; import java.net.uri; import com.atlassian.sal.api.auth.loginuriprovider; import com.atlassian.sal.api.user.usermanager;

6 import com.atlassian.templaterenderer.templaterenderer; public class MyPluginServlet extends HttpServlet private final UserManager usermanager; private final LoginUriProvider loginuriprovider; private final TemplateRenderer templaterenderer; public MyPluginServlet(UserManager usermanager, LoginUriProvider loginuriprovider, TemplateRenderer templaterenderer) this.usermanager = usermanager; this.loginuriprovider = loginuriprovider; this.templaterenderer = templaterenderer; @Override public void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException String username = usermanager.getremoteusername(request); if (username == null!usermanager.issystemadmin(username)) redirecttologin(request, response); return; templaterenderer.render("admin.vm", response.getwriter()); private void redirecttologin(httpservletrequest request, HttpServletResponse response) throws IOException response.sendredirect(loginuriprovider.getloginuri(geturi(request)).toasciistring()); private URI geturi(httpservletrequest request) StringBuffer builder = request.getrequesturl(); if (request.getquerystring()!= null) builder.append("?"); builder.append(request.getquerystring()); return URI.create(builder.toString());

7 // This is what your MyPluginServlet.java class should look like after creating your admin.vm template 2. 3. 4. Save the changes and close the file. Return to http://localhost:2990/jira/plugins/servlet/test. Click SHIFT+F5 (or CMD+R) to perform a hard refresh. Your servlet reloads, now with fields from your admin.vm: Step 4. Add a decorator and CSS You have a GUI, but it's not much to look at. Now you can add some visual appeal to your plugin using Atlassian User Interface (AUI) resources and some CSS. 1. Change to your atlastutorial/adminui/src/main/resources directory. $ cd adminui/src/main/resources 2. 3. Open your admin.vm Velocity template. Add a <meta> element directly after the title. Insert <meta name="decorator" content="atl.admin">. This tag should be inside the <head> s ection.

8 <html> <head> <title>my Admin</title> <meta name="decorator" content="atl.admin"> </head> <body> <form id="admin"> <label for="name">name</label> <input type="text" id="name" name="name"> <label for="age">age</label> <input type="text" id="age" name="age"> <input type="submit" value="save"> </form> </body> </html> 4. 5. Save the file. Leave the file open for future changes. Navigate back to your servlet in your running JIRA instance at http://localhost:2990/jira/plugins/servlet/ test. 6. Click Shift + F5 to run FastDev and display your changes. The page loads and now uses an AUI decorator. 7. Return to your admin.vm file.

9 8. Add some CSS. Replace your admin.vm contents with the following: <html> <head> <title>myservlet Admin</title> <meta name="decorator" content="atl.admin"> </head> <body> <form id="admin" class="aui"> <div class="field-group"> <label for="name">name:</label> <input type="text" id="name" name="name" class="text"> <div class="field-group"> <label for="age">age:</label> <input type="text" id="age" name="age" class="text"> <div class="field-group"> <input type="submit" value="save" class="button"> </form> </body> </html> 9. 10. Return to your servlet at http://localhost:2990/jira/plugins/servlet/test Click Shift + F5 to run FastDev and display your changes. Alternately you should be able to refresh the page and see the changes. Much fancier! Next steps Your add-on looks great! Now you'll add a POST method so it can store and retrieve user data.