Skip to content

Commit

Permalink
Merge pull request #93 from sdutry/issue90
Browse files Browse the repository at this point in the history
#90 - added tests for the sj:a and the sj:div tag
  • Loading branch information
jogep authored Jan 8, 2017
2 parents 912b638 + 6bf7aa6 commit 31d74ff
Show file tree
Hide file tree
Showing 66 changed files with 1,036 additions and 30 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Struts2 jQuery Plugin
## Build status:
* Branch `release/4.0.3`: [![Build Status](https://travis-ci.org/struts-community-plugins/struts2-jquery.svg?branch=release%2F4.0.3)](https://travis-ci.org/struts-community-plugins/struts2-jquery)
* Branch `release/4.0.2`: [![Build Status](https://travis-ci.org/struts-community-plugins/struts2-jquery.svg?branch=release%2F4.0.2)](https://travis-ci.org/struts-community-plugins/struts2-jquery)

A Plugin for the popular java web framework struts2 to provide ajax functionality and UI Widgets based on the jQuery javascript framework.

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery</artifactId>
Expand Down Expand Up @@ -92,6 +91,7 @@
<module>struts2-jquery-grid-showcase</module>
<module>struts2-jquery-mobile-showcase</module>
<module>struts2-jquery-archetypes</module>
<module>struts2-jquery-integration-tests</module>
</modules>

<build>
Expand Down
3 changes: 1 addition & 2 deletions struts2-jquery-archetypes/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?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"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jgeppert.struts2.jquery</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-archetypes</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-archetypes</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-archetypes</artifactId>
Expand Down
3 changes: 1 addition & 2 deletions struts2-jquery-chart-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jgeppert.struts2.jquery</groupId>
Expand Down
3 changes: 1 addition & 2 deletions struts2-jquery-datatables-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jgeppert.struts2.jquery</groupId>
Expand Down
3 changes: 1 addition & 2 deletions struts2-jquery-grid-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jgeppert.struts2.jquery</groupId>
Expand Down
3 changes: 1 addition & 2 deletions struts2-jquery-grid-showcase/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jgeppert.struts2.jquery</groupId>
Expand Down
1 change: 1 addition & 0 deletions struts2-jquery-integration-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
186 changes: 186 additions & 0 deletions struts2-jquery-integration-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery</artifactId>
<version>4.0.3-SNAPSHOT</version>
</parent>
<artifactId>struts2-jquery-integration-tests</artifactId>
<name>tests for the struts2-jquery-plugin</name>
<packaging>war</packaging>

<scm>
<url>https://github.com/struts-community-plugins/struts2-jquery/struts2-jquery-plugin-tests/</url>
</scm>

<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- plugins -->
<jetty-maven-plugin.version>8.1.16.v20140903</jetty-maven-plugin.version>
<maven-failsafe-plugin.version>2.19.1</maven-failsafe-plugin.version>
<!-- dependencies -->
<junit.version>4.12</junit.version>
<selenium.version>3.0.1</selenium.version>
<htmlunit-driver.version>2.23</htmlunit-driver.version>
<lombok.version>1.16.2</lombok.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-maven-plugin.version}</version>
<configuration>
<stopKey>CTRL+C</stopKey>
<stopPort>8999</stopPort>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>${jetty-maven-plugin.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-failsafe-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
</dependency>

<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-plugin</artifactId>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>

<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-plugin</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>${struts2.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>${htmlunit-driver.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>

</dependencies>
</dependencyManagement>
</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.jgeppert.jquery.actions;

import com.opensymphony.xwork2.ActionSupport;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class EchoAction extends ActionSupport {
private String echo;
private boolean escape = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.jgeppert.jquery.actions.ajax;

import com.opensymphony.xwork2.ActionSupport;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

@ParentPackage("json-default")
@Action(value="/ajax/letters", results = {@Result(type="json", name="success", params= {"root", "letters"})})
public class LettersJsonAction extends ActionSupport {
private static final char[] LETTERS;

static {
LETTERS = new char[26];
for (int i = 0; i < 26; i++) {
LETTERS[i] = (char)('a' + (char)i);
}
}

public char[] getLetters() {
return LETTERS;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is simple text from an ajax call.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%@ taglib prefix="s" uri="/struts-tags"%>
<p>Echo : <s:property value="echo" escapeHtml="%{escape}"/></p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>

<script type="text/javascript">
jQuery.subscribe("ajaxlinkclick", function(event, data) {
alert("ajax link clicked");
});
jQuery.subscribe("ajaxlinkcomplete", function(event, data) {
alert("ajax link complete");
});
</script>

<s:url var="ajax" namespace="/ajax" action="simple-text"/>

<div id="result" class="result ui-widget-content ui-corner-all">result div</div>
<sj:a id="ajaxlink" href="%{ajax}" targets="result" onClickTopics="ajaxlinkclick" onCompleteTopics="ajaxlinkcomplete" button="true" buttonIcon="ui-icon-refresh">
Run AJAX action
</sj:a>

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>

<div id="formResult" class="result ui-widget-content ui-corner-all">formResult div</div>

<s:form id="form" action="echo" namespace="/">
<s:label for="echo">Echo</s:label>
<s:textfield id="echo" name="echo" value="something to echo"/>
</s:form>
<sj:a id="ajaxformlink" formIds="form" targets="formResult" clearForm="true" indicator="indicator" button="true" buttonIcon="ui-icon-gear">
Submit form
</sj:a>

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>

<script type="text/javascript">
jQuery.subscribe("handleJsonResult", function(event, data) {
jQuery('#result').html('<ul id="lettersList"></ul>');
var $lettersList = jQuery('#lettersList');
jQuery.each(event.originalEvent.data, function(index, value) {
$lettersList.append('<li>' + value + '</li>');
});
});
</script>

<s:url var="lettersUrl" namespace="/ajax" action="letters"/>

<div id="result" class="result ui-widget-content ui-corner-all">result div</div>
<sj:a id="ajaxjsonlink" href="%{lettersUrl}" dataType="json" onSuccessTopics="handleJsonResult" button="true" buttonIcon="ui-icon-refresh">
Run AJAX action
</sj:a>

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>

<s:url var="ajax" namespace="/ajax" action="simple-text"/>

<div id="div1" class="result ui-widget-content ui-corner-all">Div 1</div>
<div id="div2" class="result ui-widget-content ui-corner-all">Div 2</div>
<sj:a id="ajaxlink" href="%{ajax}" targets="div1,div2" indicator="indicator" button="true" buttonIcon="ui-icon-refresh">
Run AJAX action
</sj:a>

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>

<s:url var="ajax" namespace="/ajax" action="simple-text"/>

<div id="result" class="result ui-widget-content ui-corner-all">Click on the link bellow.</div>
<sj:a id="ajaxlink" href="%{ajax}" targets="result" indicator="indicator" button="true" buttonIcon="ui-icon-refresh">
Run AJAX action
</sj:a>

Loading

0 comments on commit 31d74ff

Please sign in to comment.