ajaxtags-1.5.1/ 0000777 0001750 0001750 00000000000 11305026660 013261 5 ustar twerner twerner ajaxtags-1.5.1/pom.xml 0000644 0001750 0001750 00000022417 11305024400 014566 0 ustar twerner twerner 4.0.0ajaxtagsajaxtags-doc1.5.1AjaxTags DOCpom2005ajaxtagsajaxtags-resourcesajaxtags-demohttp://ajaxtags.sourceforge.net/SourceForge Trackerhttp://sourceforge.net/tracker/?group_id=140499jenskapitzaJens Kapitzajenskapitza [at] users.sourceforge.netProject ManagerDeveloperMichael Osipovhttp://sourceforge.net/project/memberlist.php?group_id=140499DeveloperDarren Spurgeonhttp://sourceforge.net/project/memberlist.php?group_id=140499Project ManagerDevelopersunshineDeveloperhttp://sourceforge.net/project/memberlist.php?group_id=140499jluixDeveloperhttp://sourceforge.net/project/memberlist.php?group_id=140499musachyDeveloperhttp://sourceforge.net/project/memberlist.php?group_id=140499PabloDeveloperhttp://sourceforge.net/project/memberlist.php?group_id=140499Jose E. GonzalezDeveloperhttp://sourceforge.net/project/memberlist.php?group_id=140499Charles HDeveloperhttp://sourceforge.net/project/memberlist.php?group_id=140499Serge KnystautasDeveloperhttp://sourceforge.net/project/memberlist.php?group_id=140499SudheerDeveloperhttp://sourceforge.net/project/memberlist.php?group_id=140499The Apache Software License, Version 2.0http://www.apache.org/licenses/LICENSE-2.0manual
The ajaxtags tag library is an open source suite of custom tags that provide high-level web presentation patterns which will work in an MVC model. The library provides a significant amount of functionality while still being easy to use.
the ajaxtags teamhttp://ajaxtags.sourceforge.net/packageorg.mortbay.jettymaven-jetty-pluginorg.apache.maven.pluginsmaven-jar-pluginorg.apache.maven.pluginsmaven-compiler-plugin1.51.5ononutf-8org.apache.maven.pluginsmaven-surefire-pluginorg.apache.maven.pluginsmaven-site-pluginorg.apache.maven.pluginsmaven-assembly-pluginsrc/main/assembly/bin.xmlsrc/main/assembly/src.xmlajaxtags-${pom.version}com.google.code.maven-license-pluginmaven-license-plugin1.4.0false${basedir}/header.txt**/**.java**/**.jsp**/**.css**/ajaxtags.jstrueSLASHSTAR_STYLEDYNASCRIPT_STYLEJAVADOC_STYLEJAVADOC_STYLE2009checkjavax.servletservlet-api2.5providedjunitjunit4.5testjavax.servlet.jspjsp-api2.1providednet.sourceforge.maven-taglibmaven-taglib-pluginorg.apache.maven.pluginsmaven-javadoc-pluginUTF-8trueorg.apache.maven.pluginsmaven-pmd-plugin1.5UTF-8org.apache.maven.pluginsmaven-project-info-reports-pluginorg.apache.maven.pluginsmaven-changes-plugin2.1false%URL%/%ISSUE%${basedir}/src/site/changes.xmlorg.apache.maven.pluginsmaven-surefire-report-pluginorg.apache.maven.pluginsmaven-checkstyle-plugin${basedir}/../checkstyle.xmlfalseorg.codehaus.mojofindbugs-maven-plugin1.2true
ajaxtags-1.5.1/ajaxtags/ 0000777 0001750 0001750 00000000000 11305026660 015063 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/pom.xml 0000644 0001750 0001750 00000001312 11305024442 016365 0 ustar twerner twerner
ajaxtags-docajaxtags1.5.14.0.0ajaxtagsajaxtagsjar1.5.1AjaxTagscommons-langcommons-lang2.4
ajaxtags-1.5.1/ajaxtags/src/ 0000755 0001750 0001750 00000000000 11265146022 015646 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/test/ 0000755 0001750 0001750 00000000000 11240372226 016625 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/test/java/ 0000755 0001750 0001750 00000000000 11240372226 017546 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/test/java/net/ 0000755 0001750 0001750 00000000000 11240372226 020334 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ 0000755 0001750 0001750 00000000000 11240372226 022657 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/ 0000755 0001750 0001750 00000000000 11253742240 024462 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/ 0000755 0001750 0001750 00000000000 11262371154 025422 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/AjaxSubmitTagTest.java 0000644 0001750 0001750 00000006124 11300773740 031633 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import static org.junit.Assert.assertEquals;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTag;
import javax.servlet.jsp.tagext.Tag;
import javax.xml.transform.TransformerException;
import net.sourceforge.ajaxtags.FakeBodyContent;
import net.sourceforge.ajaxtags.FakePageContext;
import net.sourceforge.ajaxtags.helpers.XMLUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
/**
* Test for AjaxSubmitTag.
*
* @author Victor Homyakov
* @version $Revision$ $Date$ $Author$
*/
public class AjaxSubmitTagTest {
private AjaxSubmitTag tag;
/**
* Set up.
*/
@Before
public void setUp() {
tag = new AjaxSubmitTag();
tag.setBodyContent(new FakeBodyContent());
tag.setPageContext(new FakePageContext());
}
/**
* Tear down.
*/
@After
public void tearDown() {
tag.release();
}
/**
* Test method for tag content generation.
*
* @throws JspException
* on tag errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testDoEndTag() throws JspException, TransformerException, SAXException {
final PageContext context = new FakePageContext();
tag.setPageContext(context);
tag.setSource("formId");
tag.setTarget("targetId");
assertEquals("doStartTag() must return Tag.SKIP_BODY", Tag.SKIP_BODY, tag.doStartTag());
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
assertEquals("doEndTag() must return BodyTag.EVAL_PAGE", BodyTag.EVAL_PAGE, tag.doEndTag());
final String content = ((FakeBodyContent) context.getOut()).getString();
final String expected = "";
assertEquals("HTML after doEndTag()", reformat(expected), reformat(content));
}
private String reformat(final String html) throws TransformerException, SAXException {
return XMLUtils.format(html).replaceAll("[\\s\r\n]", "");
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/AjaxPortletTagTest.java 0000644 0001750 0001750 00000006563 11300773736 032035 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTag;
import javax.servlet.jsp.tagext.Tag;
import javax.xml.transform.TransformerException;
import net.sourceforge.ajaxtags.FakeBodyContent;
import net.sourceforge.ajaxtags.FakePageContext;
import net.sourceforge.ajaxtags.helpers.XMLUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
/**
* Test for AjaxPortletTag.
*
* @author Victor Homyakov
* @version $Revision$ $Date$ $Author$
*/
public class AjaxPortletTagTest {
private static final String TAG_ID = "ajaxFrame";
private AjaxPortletTag tag;
/**
* Set up.
*/
@Before
public void setUp() {
tag = new AjaxPortletTag();
tag.setBodyContent(new FakeBodyContent());
tag.setPageContext(new FakePageContext());
}
/**
* Tear down.
*/
@After
public void tearDown() {
tag.release();
}
/**
* Test method for tag content generation in response to usual HTTP request.
*
* @throws JspException
* on tag errors
* @throws IOException
* on BodyContent errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testTag() throws JspException, IOException, TransformerException, SAXException {
final PageContext context = new FakePageContext();
tag.setPageContext(context);
tag.setId(TAG_ID);
context.getOut().print("
before tag");
assertEquals("doStartTag() must return Tag.SKIP_BODY", Tag.SKIP_BODY, tag.doStartTag());
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
assertEquals("doEndTag() must return BodyTag.EVAL_PAGE", BodyTag.EVAL_PAGE, tag.doEndTag());
context.getOut().print("after tag
");
final String content = ((FakeBodyContent) context.getOut()).getString();
final String expected = "
before tag
" + ""
+ "
after tag
";
// .replaceAll("[\\s|\n|\r\n]","") dirty hack, problem with WS remove all! cause
// we just need to check the javascript here
assertEquals("HTML after doEndTag()", XMLUtils.format(expected).replaceAll("[\\s|\n|\r\n]",
""), XMLUtils.format(content).replaceAll("[\\s|\n|\r\n]", ""));
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/OptionsBuilderTest.java 0000644 0001750 0001750 00000007730 11252743562 032103 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
*
*/
package net.sourceforge.ajaxtags.tags;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import org.junit.Before;
import org.junit.Test;
/**
* @author В.Хомяков
* @version $Revision$ $Date$ $Author$
*/
public class OptionsBuilderTest {
private OptionsBuilder options;
/**
* Set up.
*/
@Before
public void setUp() {
options = OptionsBuilder.getOptionsBuilder();
}
/**
* Test method for {@link OptionsBuilder#getOptionsBuilder(OptionsBuilder)} .
*/
@Test
public void testGetOptionsBuilder() {
assertNotNull("OptionsBuilder must be created successfully", options);
assertEquals("Empty OptionsBuilder 1", "", options.toString());
final OptionsBuilder ob1 = OptionsBuilder.getOptionsBuilder(options);
assertEquals("Empty OptionsBuilder 2", "", ob1.toString());
}
/**
* Test method for {@link OptionsBuilder#add(String, boolean)}.
*/
@Test
public void testAddStringBoolean() {
options.add("parameter", true);
options.add("parameter with space", false);
assertEquals("toString", "parameter: true" + options.getOptionsDelimiter()
+ "parameter with space: false", options.toString());
}
/**
* Test method for {@link OptionsBuilder#add(String, int)}.
*/
@Test
public void testAddStringInt() {
final String param1 = "test1-param1";
final String expected1 = "test1-param1: -1";
options.add(param1, -1);
assertEquals("int option", expected1, options.toString());
options.add(param1, 0); // immutable option, should not change
assertEquals("int immutable option", expected1, options.toString());
options.add("test1-param2", 0).add("test1-param3", 1);
assertEquals("int options", expected1 + options.getOptionsDelimiter() + "test1-param2: 0"
+ options.getOptionsDelimiter() + "test1-param3: 1", options.toString());
}
/**
* Test method for {@link OptionsBuilder#add(String, String, boolean)} .
*/
@Test
public void testAddStringStringBoolean() {
final String param1 = "test2-param1";
final String expected1 = "test2-param1: ";
options.add(param1, "", false);
options.add("test2-param2", "", true);
options.add("test2-param3", "string3", false);
options.add("test2-param4", "string4", true);
assertEquals("string options", expected1 + options.getOptionsDelimiter()
+ "test2-param2: \"\"" + options.getOptionsDelimiter() + "test2-param3: string3"
+ options.getOptionsDelimiter() + "test2-param4: \"string4\"", options.toString());
}
/**
* Test method for {@link OptionsBuilder#remove(String)} .
*/
@Test
public void testRemove() {
final String param1 = "test3-param1";
options.remove("test3-param123");
assertEquals("Empty OptionsBuilder 3", "", options.toString());
options.add(param1, true).remove(param1);
assertEquals("Empty OptionsBuilder 4", "", options.toString());
options.add(param1, true).add("test3-param2", true).remove(param1);
assertEquals("OptionsBuilder", "test3-param2: true", options.toString());
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/AjaxTabPanelTagTest.java 0000644 0001750 0001750 00000011267 11300773740 032062 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTag;
import javax.xml.transform.TransformerException;
import net.sourceforge.ajaxtags.FakeBodyContent;
import net.sourceforge.ajaxtags.FakePageContext;
import net.sourceforge.ajaxtags.helpers.XMLUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
/**
* Test for AjaxTabPanelTag.
*
* @author Victor Homyakov
* @version $Revision$ $Date$ $Author$
*/
public class AjaxTabPanelTagTest {
private AjaxTabPanelTag tag;
/**
* Set up.
*/
@Before
public void setUp() {
tag = new AjaxTabPanelTag();
tag.setBodyContent(new FakeBodyContent());
tag.setPageContext(new FakePageContext());
}
/**
* Tear down.
*/
@After
public void tearDown() {
tag.release();
}
@Test
public void testGetPages() {
assertEquals("No pages", "[]", tag.getPages());
tag.addPage(page(1));
assertEquals("One page", "[" + pageText(1) + "]", tag.getPages());
tag.addPage(page(2));
assertEquals("Two pages", "[" + pageText(1) + "," + pageText(2) + "]", tag.getPages());
tag.addPage(page(3));
assertEquals("Three pages",
"[" + pageText(1) + "," + pageText(2) + "," + pageText(3) + "]", tag.getPages());
}
/**
* Test method for tag content generation.
*
* @throws JspException
* on tag errors
*/
@Test
public void testDoEndTagEmpty() throws JspException {
assertEquals("doStartTag() must return BodyTag.EVAL_BODY_BUFFERED",
BodyTag.EVAL_BODY_BUFFERED, tag.doStartTag());
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
try {
tag.doEndTag();
fail("Empty tab panel should throw JspException");
} catch (JspException e) {
// annotation Test(expected) for exception doesn't work for me
}
}
/**
* Test method for tag content generation.
*
* @throws JspException
* on tag errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testDoEndTag() throws JspException, TransformerException, SAXException {
final PageContext context = new FakePageContext();
tag.setPageContext(context);
assertEquals("doStartTag() must return BodyTag.EVAL_BODY_BUFFERED",
BodyTag.EVAL_BODY_BUFFERED, tag.doStartTag());
tag.addPage(page(1));
tag.addPage(page(2));
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
assertEquals("doEndTag() must return BodyTag.EVAL_PAGE", BodyTag.EVAL_PAGE, tag.doEndTag());
final String content = ((FakeBodyContent) context.getOut()).getString();
final String expected = "";
assertEquals("HTML after doEndTag()", reformat(expected), reformat(content));
}
private String reformat(final String html) throws TransformerException, SAXException {
return XMLUtils.format(html).replaceAll("[\\s\r\n]", "");
}
private AjaxTabPageTag page(final int n) {
final AjaxTabPageTag page = new AjaxTabPageTag();
page.setCaption("c" + n);
page.setBaseUrl("b" + n);
return page;
}
private String pageText(final int n) {
return "{baseUrl: \"b" + n + "\", caption: \"c" + n + "\"}";
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/AjaxAreaTagTest.java 0000644 0001750 0001750 00000022256 11300773736 031251 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTag;
import javax.xml.transform.TransformerException;
import net.sourceforge.ajaxtags.FakeBodyContent;
import net.sourceforge.ajaxtags.FakeHttpServletRequest;
import net.sourceforge.ajaxtags.FakePageContext;
import net.sourceforge.ajaxtags.helpers.XMLUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
/**
* Test for AjaxAreaTag.
*
* @author Victor Homyakov
* @version $Revision$ $Date$ $Author$
*/
public class AjaxAreaTagTest {
private static final String TAG_CLASS = "textArea";
private static final String TAG_ID = "ajaxFrame";
private AjaxAreaTag tag;
/**
* Set up.
*/
@Before
public void setUp() {
tag = new AjaxAreaTag();
tag.setBodyContent(new FakeBodyContent());
tag.setPageContext(new FakePageContext());
}
/**
* Tear down.
*/
@After
public void tearDown() {
tag.release();
}
/**
* Test method for tag content generation in response to usual HTTP request.
*
* @throws JspException
* on errors
* @throws IOException
* on BodyContent errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testTag() throws JspException, IOException, TransformerException, SAXException {
final PageContext context = new FakePageContext();
tag.setPageContext(context);
tag.setId(TAG_ID);
tag.setStyleClass(TAG_CLASS);
tag.setAjaxAnchors(true);
context.getOut().print("
before tag");
assertEquals("doStartTag() must return BodyTag.EVAL_BODY_BUFFERED",
BodyTag.EVAL_BODY_BUFFERED, tag.doStartTag());
final String html = "
";
tag.getBodyContent().print(html);
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
assertEquals("doEndTag() must return BodyTag.EVAL_PAGE", BodyTag.EVAL_PAGE, tag.doEndTag());
context.getOut().print("after tag
");
final String content = ((FakeBodyContent) context.getOut()).getString();
// .replaceAll("[\\s|\n|\r\n]","") dirty hack, problem with WS remove all! cause
// we just need to check the javascript here
assertEquals("HTML after doEndTag()", XMLUtils.format(expected).replaceAll("[\\s|\n|\r\n]",
""), XMLUtils.format(content).replaceAll("[\\s|\n|\r\n]", ""));
}
/**
* Test method for tag content generation in response to AJAX request.
*
* @throws JspException
* on errors
* @throws IOException
* on BodyContent errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testTagAjax() throws JspException, IOException, TransformerException, SAXException {
final PageContext context = new FakePageContext();
tag.setPageContext(context);
((FakeHttpServletRequest) context.getRequest())
.setHeader(AjaxAreaTag.TARGET_HEADER, TAG_ID);
((FakeHttpServletRequest) context.getRequest()).setHeader(BaseAjaxBodyTag.HEADER_FLAG,
BaseAjaxBodyTag.HEADER_FLAG_VALUE);
tag.setId(TAG_ID);
tag.setStyleClass(TAG_CLASS);
tag.setAjaxAnchors(true);
context.getOut().print("
before tag");
assertEquals("doStartTag() must return BodyTag.EVAL_BODY_BUFFERED",
BodyTag.EVAL_BODY_BUFFERED, tag.doStartTag());
final String html = "
";
tag.getBodyContent().print(html);
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
assertEquals("doEndTag() must return BodyTag.SKIP_PAGE", BodyTag.SKIP_PAGE, tag.doEndTag());
// context.getOut().print("after tag
"); SKIP_PAGE
final String content = ((FakeBodyContent) context.getOut()).getString();
assertEquals("HTML after doEndTag()", XMLUtils.format(expected), XMLUtils.format(content));
}
/**
* Test method for {@link AjaxAreaTag#isAjaxRequest()}.
*/
@Test
public void testIsAjaxRequest() {
assertFalse("Request without headers", tag.isAjaxRequest());
tag.setId(TAG_ID);
final PageContext context = new FakePageContext();
tag.setPageContext(context);
((FakeHttpServletRequest) context.getRequest())
.setHeader(AjaxAreaTag.TARGET_HEADER, TAG_ID);
((FakeHttpServletRequest) context.getRequest()).setHeader(BaseAjaxBodyTag.HEADER_FLAG,
BaseAjaxBodyTag.HEADER_FLAG_VALUE);
assertTrue("Request with proper " + BaseAjaxBodyTag.HEADER_FLAG + " and "
+ AjaxAreaTag.TARGET_HEADER + " headers", tag.isAjaxRequest());
((FakeHttpServletRequest) context.getRequest()).setHeader(AjaxAreaTag.TARGET_HEADER, TAG_ID
+ "1");
assertFalse("Request with proper " + BaseAjaxBodyTag.HEADER_FLAG + " header and invalid "
+ AjaxAreaTag.TARGET_HEADER + " header", tag.isAjaxRequest());
}
/**
* Test method for {@link AjaxAreaTag#processContent(String)}.
*
* @throws JspException
* on errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testProcessContent() throws JspException, TransformerException, SAXException {
tag.setAjaxAnchors(false);
String html = null, expected = null;
assertEquals("null content", expected, tag.processContent(html));
html = "";
expected = "";
assertEquals("empty content", expected, tag.processContent(html));
tag.setAjaxAnchors(true);
html = "content";
expected = "
";
assertEquals(XMLUtils.format(expected), tag.processContent(html));
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/AjaxAnchorsTagTest.java 0000644 0001750 0001750 00000012607 11300773740 031770 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
*
*/
package net.sourceforge.ajaxtags.tags;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTag;
import javax.xml.transform.TransformerException;
import net.sourceforge.ajaxtags.FakeBodyContent;
import net.sourceforge.ajaxtags.FakePageContext;
import net.sourceforge.ajaxtags.helpers.XMLUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
/**
* Test for AjaxAnchorsTag.
*
* @author В.Хомяков
* @version $Revision$ $Date$ $Author$
*/
public class AjaxAnchorsTagTest {
private static final String HEADER = "";
private static final String BASE_URL = "http://localhost:8080/test/test.do";
private AjaxAnchorsTag tag;
/**
* Set up.
*/
@Before
public void setUp() {
tag = new AjaxAnchorsTag();
tag.setBodyContent(new FakeBodyContent());
tag.setPageContext(new FakePageContext());
}
/**
* Tear down.
*/
@After
public void tearDown() {
tag.release();
}
/**
* Test method for {@link AjaxAnchorsTag#doEndTag()}.
*
* @throws JspException
* on errors
* @throws IOException
* on BodyContent errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testDoEndTag() throws JspException, IOException, TransformerException, SAXException {
final OptionsBuilder options = OptionsBuilder.getOptionsBuilder();
final PageContext context = new FakePageContext();
tag.setPageContext(context);
// tag.setVar("ajaxAnchors");
tag.setTarget("target");
assertEquals("doStartTag() must return BodyTag.EVAL_BODY_BUFFERED",
BodyTag.EVAL_BODY_BUFFERED, tag.doStartTag());
final String html = "testDoEndTag";
final String expected = HEADER + "
";
tag.getBodyContent().print(html);
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
assertEquals("doEndTag() must return BodyTag.EVAL_PAGE", BodyTag.EVAL_PAGE, tag.doEndTag());
final String content = ((FakeBodyContent) context.getOut()).getString();
assertEquals("HTML after doEndTag()", XMLUtils.format(expected), content);
}
/**
* Test method for {@link AjaxAnchorsTag#ajaxAnchors(String, String, String)}.
*
* @throws JspException
* on errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testAjaxAnchors() throws JspException, TransformerException, SAXException {
final OptionsBuilder options = OptionsBuilder.getOptionsBuilder();
String html = "HTML content";
String expected = HEADER + "
";
assertEquals("HTML with link", XMLUtils.format(expected), tag.ajaxAnchors(html, "target",
null));
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/AjaxToggleTagTest.java 0000644 0001750 0001750 00000020301 11300773740 031602 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import static org.junit.Assert.assertEquals;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTag;
import javax.servlet.jsp.tagext.Tag;
import javax.xml.transform.TransformerException;
import net.sourceforge.ajaxtags.FakeBodyContent;
import net.sourceforge.ajaxtags.FakePageContext;
import net.sourceforge.ajaxtags.helpers.XMLUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.SAXException;
/**
* Test for AjaxToggleTag.
*
* @author Victor Homyakov
* @version $Revision$ $Date$ $Author$
*/
public class AjaxToggleTagTest {
private AjaxToggleTag tag;
/**
* Set up.
*/
@Before
public void setUp() {
tag = new AjaxToggleTag();
tag.setBodyContent(new FakeBodyContent());
tag.setPageContext(new FakePageContext());
}
/**
* Tear down.
*/
@After
public void tearDown() {
tag.release();
}
/**
* Test method for tag content generation (star rating with empty value).
*
* @throws JspException
* on tag errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testDoEndTag0() throws JspException, TransformerException, SAXException {
final PageContext context = new FakePageContext();
tag.setPageContext(context);
tag.setContainerClass("star-rating");
tag.setRatings(",Two,Three");
assertEquals("doStartTag() must return Tag.SKIP_BODY", Tag.SKIP_BODY, tag.doStartTag());
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
assertEquals("doEndTag() must return BodyTag.EVAL_PAGE", BodyTag.EVAL_PAGE, tag.doEndTag());
final String content = ((FakeBodyContent) context.getOut()).getString();
final String expected = "
"
+ ""
+ ""
+ ""
+ "
";
assertEquals("HTML after doEndTag()", reformat(expected), reformat(content));
}
/**
* Test method for tag content generation (star rating).
*
* @throws JspException
* on tag errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testDoEndTag1() throws JspException, TransformerException, SAXException {
final PageContext context = new FakePageContext();
tag.setPageContext(context);
tag.setContainerClass("star-rating");
tag.setRatings("One,Two,Three");
assertEquals("doStartTag() must return Tag.SKIP_BODY", Tag.SKIP_BODY, tag.doStartTag());
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
assertEquals("doEndTag() must return BodyTag.EVAL_PAGE", BodyTag.EVAL_PAGE, tag.doEndTag());
final String content = ((FakeBodyContent) context.getOut()).getString();
final String expected = "
"
+ ""
+ ""
+ ""
+ "
";
assertEquals("HTML after doEndTag()", reformat(expected), reformat(content));
}
/**
* Test method for tag content generation (star rating with selected element).
*
* @throws JspException
* on tag errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testDoEndTag2() throws JspException, TransformerException, SAXException {
final PageContext context = new FakePageContext();
tag.setPageContext(context);
tag.setContainerClass("star-rating");
tag.setRatings("One,Two,Three");
tag.setDefaultRating("Two");
tag.setSelectedClass("selected");
assertEquals("doStartTag() must return Tag.SKIP_BODY", Tag.SKIP_BODY, tag.doStartTag());
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
assertEquals("doEndTag() must return BodyTag.EVAL_PAGE", BodyTag.EVAL_PAGE, tag.doEndTag());
final String content = ((FakeBodyContent) context.getOut()).getString();
final String expected = "
"
+ ""
+ ""
+ ""
+ "
";
assertEquals("HTML after doEndTag()", reformat(expected), reformat(content));
}
/**
* Test method for tag content generation (on-off toggle).
*
* @throws JspException
* on tag errors
* @throws SAXException
* if any parse errors occur
* @throws TransformerException
* if it is not possible to transform document to string
*/
@Test
public void testDoEndTagOnOff() throws JspException, TransformerException, SAXException {
final PageContext context = new FakePageContext();
tag.setPageContext(context);
tag.setContainerClass("power-rating");
tag.setRatings("true,false");
tag.setOnOff("true");
assertEquals("doStartTag() must return Tag.SKIP_BODY", Tag.SKIP_BODY, tag.doStartTag());
assertEquals("doAfterBody() must return BodyTag.SKIP_BODY", BodyTag.SKIP_BODY, tag
.doAfterBody());
assertEquals("doEndTag() must return BodyTag.EVAL_PAGE", BodyTag.EVAL_PAGE, tag.doEndTag());
final String content = ((FakeBodyContent) context.getOut()).getString();
final String expected = "
"
+ ""
+ "
";
assertEquals("HTML after doEndTag()", reformat(expected), reformat(content));
}
private String reformat(final String html) throws TransformerException, SAXException {
return XMLUtils.format(html).replaceAll("[\\s\r\n]", "");
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/xml/ 0000755 0001750 0001750 00000000000 11250754334 025266 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/xml/AjaxTreeXmlBuilderTest.java 0000644 0001750 0001750 00000012045 11301073050 032450 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
*
*/
package net.sourceforge.ajaxtags.xml;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
/**
* Test for AjaxTreeXmlBuilder.
*
* @author В.Хомяков
*/
public class AjaxTreeXmlBuilderTest {
private AjaxTreeXmlBuilder xml;
/**
* Set up.
*/
@Before
public void setUp() {
xml = new AjaxTreeXmlBuilder();
}
/**
* Test method for {@link AjaxTreeXmlBuilder#getXMLString()}.
*/
@Test
public void testGetXMLString() {
assertEquals(AjaxTreeXmlBuilder.RESPONSE_START + AjaxTreeXmlBuilder.RESPONSE_END, xml
.getXMLString());
}
/**
* Test method for {@link AjaxTreeXmlBuilder#addItem(String, String)} .
*/
@Test
public void testAddItemStringString() {
xml.addItem("name1", "value");
assertEquals(AjaxTreeXmlBuilder.RESPONSE_START
+ "name1value"
+ AjaxTreeXmlBuilder.RESPONSE_END, xml.getXMLString());
xml.addItem("name2", "");
assertEquals(AjaxTreeXmlBuilder.RESPONSE_START
+ "name1value"
+ "name2"
+ AjaxTreeXmlBuilder.RESPONSE_END, xml.getXMLString());
xml.addItem("name3", null);
assertEquals(AjaxTreeXmlBuilder.RESPONSE_START
+ "name1value"
+ "name2"
+ "name3null"
+ AjaxTreeXmlBuilder.RESPONSE_END, xml.getXMLString());
}
/**
* Test method for {@link AjaxTreeXmlBuilder#addItemAsCData(String, String)} .
*/
@Test
public void testAddItemAsCDataStringString() {
xml.addItemAsCData("name 4", "Value contains and tags");
assertEquals(
AjaxTreeXmlBuilder.RESPONSE_START
+ " and tags]]>"
+ AjaxTreeXmlBuilder.RESPONSE_END, xml.getXMLString());
}
/**
* Test method for {@link AjaxTreeXmlBuilder#addItem(String, String, String, boolean)} .
*/
@Test
public void testAddItemStringStringStringBoolean() {
xml.addItem("name5", "value5", "url5", false);
assertEquals(
AjaxTreeXmlBuilder.RESPONSE_START
+ "name5value5falseurl5"
+ AjaxTreeXmlBuilder.RESPONSE_END, xml.getXMLString());
}
/**
* Test method for {@link AjaxTreeXmlBuilder#addItem(String, String, boolean, String)} .
*/
@Test
public void testAddItemStringStringBooleanString() {
xml.addItem("name6", "value6", true, "url6");
assertEquals(
AjaxTreeXmlBuilder.RESPONSE_START
+ "name6value6trueurl6"
+ AjaxTreeXmlBuilder.RESPONSE_END, xml.getXMLString());
}
/**
* Test method for {@link AjaxTreeXmlBuilder#addItem(String, String, boolean, String, boolean)}
* .
*/
@Test
public void testAddItemStringStringBooleanStringBoolean() {
xml.addItem("name7", "value7", true, "url7", true);
assertEquals(
AjaxTreeXmlBuilder.RESPONSE_START
+ "trueurl7"
+ AjaxTreeXmlBuilder.RESPONSE_END, xml.getXMLString());
}
/**
* Test method for {@link AjaxTreeXmlBuilder#addItemAsCData(String, String, boolean, String)} .
*/
@Test
public void testAddItemAsCDataStringStringBooleanString() {
xml.addItemAsCData("name8", "value8", true, "url8");
assertEquals(
AjaxTreeXmlBuilder.RESPONSE_START
+ "trueurl8"
+ AjaxTreeXmlBuilder.RESPONSE_END, xml.getXMLString());
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/xml/AjaxXmlBuilderTest.java 0000644 0001750 0001750 00000003545 11300773740 031651 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
*
*/
package net.sourceforge.ajaxtags.xml;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
/**
* Test for AjaxXmlBuilder.
*
* @author В.Хомяков
* @version $Revision$ $Date$ $Author$
*/
public class AjaxXmlBuilderTest {
private AjaxXmlBuilder xml;
/**
* Set up.
*/
@Before
public void setUp() {
xml = new AjaxXmlBuilder();
}
/**
* Test method for {@link AjaxXmlBuilder#addItem(String, String)} .
*/
@Test
public void testAddItemStringString() {
xml.addItem("name1", "value1");
assertEquals(AjaxXmlBuilder.RESPONSE_START
+ "name1value1"
+ AjaxXmlBuilder.RESPONSE_END, xml.getXMLString());
}
/**
* Test method for {@link AjaxXmlBuilder#addItemAsCData(String, String)} .
*/
@Test
public void testAddItemAsCData() {
xml.addItemAsCData("name2", "value2");
assertEquals(AjaxXmlBuilder.RESPONSE_START
+ ""
+ AjaxXmlBuilder.RESPONSE_END, xml.getXMLString());
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/FakePageContext.java 0000644 0001750 0001750 00000012223 11300773736 030344 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags;
import java.io.IOException;
import java.util.Enumeration;
import javax.el.ELContext;
import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.el.ExpressionEvaluator;
import javax.servlet.jsp.el.VariableResolver;
import javax.servlet.jsp.tagext.BodyContent;
/**
* Fake PageContext to test tags.
*
* @author В.Хомяков
* @version $Revision$ $Date$ $Author$
*/
public class FakePageContext extends PageContext {
private BodyContent content = new FakeBodyContent();
private ServletRequest request = new FakeHttpServletRequest();
private ServletResponse response = new FakeHttpServletResponse();
@Override
public void forward(String relativeUrlPath) throws ServletException, IOException {
// TODO Auto-generated method stub
}
@Override
public Exception getException() {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getPage() {
// TODO Auto-generated method stub
return null;
}
@Override
public ServletRequest getRequest() {
return request;
}
@Override
public ServletResponse getResponse() {
return response;
}
@Override
public ServletConfig getServletConfig() {
// TODO Auto-generated method stub
return null;
}
@Override
public ServletContext getServletContext() {
// TODO Auto-generated method stub
return null;
}
@Override
public HttpSession getSession() {
// TODO Auto-generated method stub
return null;
}
@Override
public void handlePageException(Exception e) throws ServletException, IOException {
}
@Override
public void handlePageException(Throwable t) throws ServletException, IOException {
}
@Override
public void include(String relativeUrlPath) throws ServletException, IOException {
// TODO Auto-generated method stub
}
@Override
public void include(String relativeUrlPath, boolean flush) throws ServletException, IOException {
// TODO Auto-generated method stub
}
@Override
public void initialize(Servlet servlet, ServletRequest request, ServletResponse response,
String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)
throws IOException, IllegalStateException, IllegalArgumentException {
// TODO Auto-generated method stub
}
@Override
public void release() {
}
@Override
public Object findAttribute(String name) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getAttribute(String name) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getAttribute(String name, int scope) {
// TODO Auto-generated method stub
return null;
}
@Override
public Enumeration getAttributeNamesInScope(int scope) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getAttributesScope(String name) {
// TODO Auto-generated method stub
return 0;
}
@Override
public JspWriter getOut() {
return content;
}
@Override
public void removeAttribute(String name) {
// TODO Auto-generated method stub
}
@Override
public void removeAttribute(String name, int scope) {
// TODO Auto-generated method stub
}
@Override
public void setAttribute(String name, Object value) {
// TODO Auto-generated method stub
}
@Override
public void setAttribute(String name, Object value, int scope) {
// TODO Auto-generated method stub
}
@Override
public ELContext getELContext() {
// TODO Auto-generated method stub
return null;
}
@Override
public ExpressionEvaluator getExpressionEvaluator() {
// TODO Auto-generated method stub
return null;
}
@Override
public VariableResolver getVariableResolver() {
// TODO Auto-generated method stub
return null;
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/FakeHttpServletRequest.java 0000644 0001750 0001750 00000017264 11300773740 031765 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.Principal;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletInputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* @author В.Хомяков
* @version $Revision: 86 $ $Date: 2007/06/20 20:55:56 $ $Author: jenskapitza $
*/
public class FakeHttpServletRequest implements HttpServletRequest {
private final Map headers = new HashMap();
public String getAuthType() {
// TODO Auto-generated method stub
return null;
}
public String getContextPath() {
// TODO Auto-generated method stub
return null;
}
public Cookie[] getCookies() {
final Cookie[] cookies = {};
return cookies;
}
public long getDateHeader(String name) {
// TODO Auto-generated method stub
return 0;
}
public void setHeader(String name, String value) {
headers.put(name, value);
}
public String getHeader(String name) {
final Object o = headers.get(name);
return o == null ? null : String.valueOf(o);
}
public Enumeration> getHeaderNames() {
// TODO Auto-generated method stub
return null;
}
public Enumeration> getHeaders(String name) {
// TODO Auto-generated method stub
return null;
}
public int getIntHeader(String name) {
// TODO Auto-generated method stub
return 0;
}
public String getMethod() {
// TODO Auto-generated method stub
return null;
}
public String getPathInfo() {
// TODO Auto-generated method stub
return null;
}
public String getPathTranslated() {
// TODO Auto-generated method stub
return null;
}
public String getQueryString() {
// TODO Auto-generated method stub
return null;
}
public String getRemoteUser() {
// TODO Auto-generated method stub
return null;
}
public String getRequestURI() {
// TODO Auto-generated method stub
return null;
}
public StringBuffer getRequestURL() {
// TODO Auto-generated method stub
return null;
}
public String getRequestedSessionId() {
// TODO Auto-generated method stub
return null;
}
public String getServletPath() {
// TODO Auto-generated method stub
return null;
}
public HttpSession getSession() {
// TODO Auto-generated method stub
return null;
}
public HttpSession getSession(boolean create) {
// TODO Auto-generated method stub
return null;
}
public Principal getUserPrincipal() {
// TODO Auto-generated method stub
return null;
}
public boolean isRequestedSessionIdFromCookie() {
// TODO Auto-generated method stub
return false;
}
public boolean isRequestedSessionIdFromURL() {
// TODO Auto-generated method stub
return false;
}
public boolean isRequestedSessionIdFromUrl() {
// TODO Auto-generated method stub
return false;
}
public boolean isRequestedSessionIdValid() {
// TODO Auto-generated method stub
return false;
}
public boolean isUserInRole(String role) {
// TODO Auto-generated method stub
return false;
}
public Object getAttribute(String name) {
// TODO Auto-generated method stub
return null;
}
public Enumeration> getAttributeNames() {
// TODO Auto-generated method stub
return null;
}
public String getCharacterEncoding() {
// TODO Auto-generated method stub
return null;
}
public int getContentLength() {
// TODO Auto-generated method stub
return 0;
}
public String getContentType() {
// TODO Auto-generated method stub
return null;
}
public ServletInputStream getInputStream() throws IOException {
// TODO Auto-generated method stub
return null;
}
public String getLocalAddr() {
// TODO Auto-generated method stub
return null;
}
public String getLocalName() {
// TODO Auto-generated method stub
return null;
}
public int getLocalPort() {
// TODO Auto-generated method stub
return 0;
}
public Locale getLocale() {
// TODO Auto-generated method stub
return null;
}
public Enumeration> getLocales() {
// TODO Auto-generated method stub
return null;
}
public String getParameter(String name) {
// TODO Auto-generated method stub
return null;
}
public Map, ?> getParameterMap() {
// TODO Auto-generated method stub
return null;
}
public Enumeration> getParameterNames() {
// TODO Auto-generated method stub
return null;
}
public String[] getParameterValues(String name) {
final String[] values = {};
return values;
}
public String getProtocol() {
// TODO Auto-generated method stub
return null;
}
public BufferedReader getReader() throws IOException {
// TODO Auto-generated method stub
return null;
}
public String getRealPath(String path) {
// TODO Auto-generated method stub
return null;
}
public String getRemoteAddr() {
// TODO Auto-generated method stub
return null;
}
public String getRemoteHost() {
// TODO Auto-generated method stub
return null;
}
public int getRemotePort() {
// TODO Auto-generated method stub
return 0;
}
public RequestDispatcher getRequestDispatcher(String path) {
// TODO Auto-generated method stub
return null;
}
public String getScheme() {
// TODO Auto-generated method stub
return null;
}
public String getServerName() {
// TODO Auto-generated method stub
return null;
}
public int getServerPort() {
// TODO Auto-generated method stub
return 0;
}
public boolean isSecure() {
// TODO Auto-generated method stub
return false;
}
public void removeAttribute(String name) {
// TODO Auto-generated method stub
}
public void setAttribute(String name, Object o) {
// TODO Auto-generated method stub
}
public void setCharacterEncoding(String env) throws UnsupportedEncodingException {
// TODO Auto-generated method stub
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/FakeBodyContent.java 0000644 0001750 0001750 00000010777 11300773736 030367 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyContent;
/**
* Fake BodyContent to test tags.
*
* @author В.Хомяков
* @version $Revision$ $Date$ $Author$
*/
public class FakeBodyContent extends BodyContent {
private static final String NEW_LINE = "\n";
private String content = "";
protected FakeBodyContent(JspWriter writer) {
super(writer);
}
public FakeBodyContent() {
super(null);
}
@Override
public Reader getReader() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getString() {
return content;
}
@Override
public void writeOut(Writer out) throws IOException {
out.write(content);
}
@Override
public void clear() throws IOException {
content = "";
}
@Override
public void clearBuffer() throws IOException {
content = "";
}
@Override
public void close() throws IOException {
// TODO Auto-generated method stub
}
@Override
public int getRemaining() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void newLine() throws IOException {
this.content += NEW_LINE;
}
@Override
public Writer append(CharSequence csq) throws IOException {
this.content += csq;
return this;
}
@Override
public void print(boolean b) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void print(char c) throws IOException {
this.content += c;
}
@Override
public void print(int i) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void print(long l) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void print(float f) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void print(double d) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void print(char[] s) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void print(String s) throws IOException {
this.content += s;
}
@Override
public void print(Object obj) throws IOException {
this.content += obj;
}
@Override
public void println() throws IOException {
this.content += NEW_LINE;
}
@Override
public void println(boolean x) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void println(char x) throws IOException {
this.content += x + NEW_LINE;
}
@Override
public void println(int x) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void println(long x) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void println(float x) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void println(double x) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void println(char[] x) throws IOException {
// TODO Auto-generated method stub
}
@Override
public void println(String x) throws IOException {
this.content += x + NEW_LINE;
}
@Override
public void println(Object x) throws IOException {
this.content += x + NEW_LINE;
}
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
// TODO Auto-generated method stub
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/helpers/ 0000755 0001750 0001750 00000000000 11253742424 026130 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/helpers/DIVElementTest.java 0000644 0001750 0001750 00000004226 11253742424 031573 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
*
*/
package net.sourceforge.ajaxtags.helpers;
import static org.junit.Assert.assertEquals;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author В.Хомяков
* @version $Revision$ $Date$ $Author$
*/
public class DIVElementTest {
private DIVElement div;
/**
* Set up.
*/
@Before
public void setUp() {
div = new DIVElement(null);
}
/**
* Tear down.
*/
@After
public void tearDown() {
div = null;
}
/**
* Test method for
* {@link net.sourceforge.ajaxtags.helpers.DIVElement#DIVElement(java.lang.String)}.
*/
@Test
public void testDIVElement() {
assertEquals("Empty div", "", div.toString());
div = new DIVElement("idDiv1");
assertEquals("Empty div with id", "", div.toString());
}
/**
* Test method for
* {@link net.sourceforge.ajaxtags.helpers.AbstractHTMLElement#setClassName(java.lang.String)}.
*/
@Test
public void testSetClassName() {
div.setClassName("class1");
assertEquals("Empty div with class", "", div.toString());
}
/**
* Test method for
* {@link net.sourceforge.ajaxtags.helpers.AbstractHTMLElement#setId(java.lang.String)}.
*/
@Test
public void testSetId() {
div.setId("idDiv2");
assertEquals("Empty div with id", "", div.toString());
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/helpers/HTML.java 0000644 0001750 0001750 00000001375 11300773740 027543 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.helpers;
import org.junit.Test;
/**
*
* @author Jens Kapitza
*/
public class HTML {
@Test
public void test() {
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/helpers/StringUtilsTest.java 0000644 0001750 0001750 00000003433 11252743562 032130 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
*
*/
package net.sourceforge.ajaxtags.helpers;
import static org.apache.commons.lang.StringUtils.trimToNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import org.junit.Test;
/**
* @author В.Хомяков
* @version $Revision$ $Date$ $Author$
*/
public class StringUtilsTest {
/**
* Test method for
* {@link net.sourceforge.ajaxtags.helpers.StringUtils#trimToNull(java.lang.String)}.
*/
@Test
public void testTrim2Null() {
assertNull("trim2Null(null) must be null", trimToNull(null));
assertNull("trim2Null(\"\") must be null", trimToNull(""));
assertNull("trim2Null(\" \") must be null", trimToNull(" "));
assertNull("trim2Null(\"\t\") must be null", trimToNull("\t"));
assertNull("trim2Null(\"\r\n\") must be null", trimToNull("\r\n"));
String str = "a";
assertEquals("Without whitespace", str, trimToNull(str));
str = " a ";
// this test fail if we use trimToNULL
// assertEquals("With whitespace", str, trim2Null(str));
assertEquals("With whitespace", str.trim(), trimToNull(str));
}
}
ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/FakeHttpServletResponse.java 0000644 0001750 0001750 00000010742 11300773736 032132 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Locale;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
/**
* Fake HttpServletResponse to test tags.
*
* @author В.Хомяков
* @version $Revision$ $Date$ $Author$
*/
public class FakeHttpServletResponse implements HttpServletResponse {
public void addCookie(Cookie cookie) {
// TODO Auto-generated method stub
}
public void addDateHeader(String name, long date) {
// TODO Auto-generated method stub
}
public void addHeader(String name, String value) {
// TODO Auto-generated method stub
}
public void addIntHeader(String name, int value) {
// TODO Auto-generated method stub
}
public boolean containsHeader(String name) {
// TODO Auto-generated method stub
return false;
}
public String encodeRedirectURL(String url) {
// TODO Auto-generated method stub
return null;
}
public String encodeRedirectUrl(String url) {
// TODO Auto-generated method stub
return null;
}
public String encodeURL(String url) {
// TODO Auto-generated method stub
return null;
}
public String encodeUrl(String url) {
// TODO Auto-generated method stub
return null;
}
public void sendError(int sc) throws IOException {
// TODO Auto-generated method stub
}
public void sendError(int sc, String msg) throws IOException {
// TODO Auto-generated method stub
}
public void sendRedirect(String location) throws IOException {
// TODO Auto-generated method stub
}
public void setDateHeader(String name, long date) {
// TODO Auto-generated method stub
}
public void setHeader(String name, String value) {
// TODO Auto-generated method stub
}
public void setIntHeader(String name, int value) {
// TODO Auto-generated method stub
}
public void setStatus(int sc) {
// TODO Auto-generated method stub
}
public void setStatus(int sc, String sm) {
// TODO Auto-generated method stub
}
public void flushBuffer() throws IOException {
// TODO Auto-generated method stub
}
public int getBufferSize() {
// TODO Auto-generated method stub
return 0;
}
public String getCharacterEncoding() {
// TODO Auto-generated method stub
return null;
}
public String getContentType() {
// TODO Auto-generated method stub
return null;
}
public Locale getLocale() {
// TODO Auto-generated method stub
return null;
}
public ServletOutputStream getOutputStream() throws IOException {
// TODO Auto-generated method stub
return null;
}
public PrintWriter getWriter() throws IOException {
// TODO Auto-generated method stub
return null;
}
public boolean isCommitted() {
// TODO Auto-generated method stub
return false;
}
public void reset() {
// TODO Auto-generated method stub
}
public void resetBuffer() {
// TODO Auto-generated method stub
}
public void setBufferSize(int size) {
// TODO Auto-generated method stub
}
public void setCharacterEncoding(String charset) {
// TODO Auto-generated method stub
}
public void setContentLength(int len) {
// TODO Auto-generated method stub
}
public void setContentType(String type) {
// TODO Auto-generated method stub
}
public void setLocale(Locale loc) {
// TODO Auto-generated method stub
}
}
ajaxtags-1.5.1/ajaxtags/src/site/ 0000755 0001750 0001750 00000000000 11265436614 016623 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/site/site.xml 0000644 0001750 0001750 00000000255 11276326504 020311 0 ustar twerner twerner
ajaxtags-1.5.1/ajaxtags/src/main/ 0000755 0001750 0001750 00000000000 11240372226 016572 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/main/java/ 0000755 0001750 0001750 00000000000 11240372226 017513 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/main/java/net/ 0000755 0001750 0001750 00000000000 11240372226 020301 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ 0000755 0001750 0001750 00000000000 11240372226 022624 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/ 0000755 0001750 0001750 00000000000 11240372226 024426 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/ 0000755 0001750 0001750 00000000000 11262371154 025367 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxSubmitTag.java 0000644 0001750 0001750 00000002673 11300773740 030745 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
/**
* Builds the JavaScript required to submit form and retrieve response via AJAX.
*
* @author Victor Homyakov
*/
public class AjaxSubmitTag extends BaseAjaxTag {
private static final long serialVersionUID = -8804246033367573302L;
@Override
protected String getJsClass() {
return JSCLASS_BASE + "Submit";
}
@Override
protected OptionsBuilder getOptions() {
// empty options
final OptionsBuilder options = getOptionsBuilder(true);
options.add("source", getSource(), true);
options.add("target", getTarget(), true);
return options;
}
@Override
public int doEndTag() throws JspException {
out(buildScript());
return EVAL_PAGE;
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxAnchorsTag.java 0000644 0001750 0001750 00000011442 11300777764 031103 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import static org.apache.commons.lang.StringUtils.trimToNull;
import javax.servlet.jsp.JspException;
import javax.xml.transform.TransformerException;
import javax.xml.xpath.XPathExpressionException;
import net.sourceforge.ajaxtags.helpers.XMLUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
* Rewrites HTML anchor tags (<A>), replacing the href attribute with an onclick event so that
* retrieved content is loaded inside a region on the page.
*
* @author Darren Spurgeon
* @author Jens Kapitza
*/
public class AjaxAnchorsTag extends BaseAjaxBodyTag {
private static final long serialVersionUID = -1732745741282114289L;
/**
* rewrite the body and make use of ajax. rewriting all <a> links to use javascript calls
* to prototype.
*
* @return EVAL_PAGE
*/
@Override
public int doEndTag() throws JspException {
out(ajaxAnchors(getBody(), getTarget(), getSourceClass()));
return EVAL_PAGE;
}
/**
* Rewrite anchors.
*
* @param html
* XHTML source
* @param target
* target of request
* @param clazz
* CSS class of anchors
* @return rewritten and reformatted XHTML text
* @throws JspException
* on errors
*/
public String ajaxAnchors(final String html, final String target, final String clazz)
throws JspException {
try {
return rewriteAnchors(getDocument(html), target, clazz);
} catch (XPathExpressionException e) {
throw new JspException("rewrite links failed (wrong XPath expression)\n" + html, e);
} catch (TransformerException e) {
throw new JspException(
"rewrite links failed (cannot transform XHTML to text)\n" + html, e);
} catch (SAXException e) {
throw new JspException("rewrite links failed (is the content xhtml?)\n" + html, e);
}
}
private String rewriteAnchors(final Document document, final String target,
final String className) throws XPathExpressionException, TransformerException {
String xpath = "//a";
if (className != null) {
xpath = xpath + "[@class=\"" + className + "\"]";
}
final NodeList links = XMLUtils.evaluateXPathExpression(xpath, document);
// document.getElementsByTagName("a");
for (int i = 0; i < links.getLength(); i++) {
rewriteLink(links.item(i), target);
}
return XMLUtils.toString(document);
}
/**
* Rewrite link. Change (or create) "onclick" attribute, set "href" attribute to
* "javascript://nop/".
*
* @param link
* node of document with link
* @param target
* target of request
*/
protected final void rewriteLink(final Node link, final String target) {
final NamedNodeMap map = link.getAttributes();
final Attr href = (Attr) map.getNamedItem("href");
if (href != null) {
Attr onclick = (Attr) map.getNamedItem("onclick");
if (onclick == null) {
onclick = link.getOwnerDocument().createAttribute("onclick");
map.setNamedItem(onclick);
}
onclick.setValue(getOnclickAjax(target, href.getValue(), getOptionsBuilder()));
href.setValue("javascript://nop/");
}
}
/**
* Parse XHTML document from given string.
*
* @param html
* string with XHTML content
* @return parsed document or null
* @throws SAXException
* if string cannot be parsed
*/
protected static final Document getDocument(final String html) throws SAXException {
final String xhtml = trimToNull(html); // .replaceAll(" ", " ");
if (xhtml == null) {
return null;
}
// warp dirty hack to use internal HTML parser.
final String WARP0 = "
";
final String WARP1 = "
";
return XMLUtils.getXMLDocument(WARP0 + xhtml + WARP1);
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxAutocompleteTag.java 0000644 0001750 0001750 00000005215 11300773740 032136 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
/**
* Tag handler for the autocomplete AJAX tag.
*
* @author Darren Spurgeon
* @version $Revision: 86 $ $Date: 2007/06/20 20:55:56 $ $Author: jenskapitza $
*/
public class AjaxAutocompleteTag extends BaseAjaxTag {
private static final long serialVersionUID = -6332721548834673822L;
private String minimumCharacters;
private String appendSeparator;
private String className;
private String indicator;
public String getAppendSeparator() {
return appendSeparator;
}
public void setAppendSeparator(final String appendSeparator) {
this.appendSeparator = appendSeparator;
}
public String getClassName() {
return className;
}
public void setClassName(final String className) {
this.className = className;
}
public String getIndicator() {
return indicator;
}
public void setIndicator(final String indicator) {
this.indicator = indicator;
}
public String getMinimumCharacters() {
return minimumCharacters;
}
public void setMinimumCharacters(final String minimumCharacters) {
this.minimumCharacters = minimumCharacters;
}
@Override
protected String getJsClass() {
return JSCLASS_BASE + "Autocomplete";
}
@Override
protected OptionsBuilder getOptions() {
final OptionsBuilder options = getOptionsBuilder();
options.add("className", this.className, true);
options.add("indicator", this.indicator, true);
options.add("minChars", this.minimumCharacters, true);
options.add("appendSeparator", this.appendSeparator, true);
return options;
}
@Override
public int doEndTag() throws JspException {
out(buildScript());
return EVAL_PAGE;
}
@Override
public void releaseTag() {
this.className = null; // NOPMD
this.minimumCharacters = null; // NOPMD
this.appendSeparator = null; // NOPMD
this.indicator = null; // NOPMD
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/BaseAjaxTag.java 0000644 0001750 0001750 00000002046 11252743562 030353 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
/**
* This class does not support body content.
*
* @author Jens Kapitza
* @version $Revision$ $Date$ $Author$
*/
public abstract class BaseAjaxTag extends BaseAjaxBodyTag {
private static final long serialVersionUID = -6954908083925539558L;
@Override
protected void initParameters() throws JspException {
super.initParameters();
skipBody();
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxDisplayTag.java 0000644 0001750 0001750 00000011235 11300773736 031106 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import static org.apache.commons.lang.StringUtils.trimToNull;
import javax.servlet.jsp.JspException;
import javax.xml.transform.TransformerException;
import net.sourceforge.ajaxtags.helpers.XMLUtils;
import org.apache.commons.lang.StringUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
* Wraps a DisplayTag (http://displaytag.org) table, enabling AJAX capabilities. In the process,
* anchors in the navigation are rewritten on the fly so that the DisplayTag table refreshes within
* the same region on the page without a full-page reload.
*
* @author Darren Spurgeon
* @version $Revision: 86 $ $Date: 2007/07/08 17:52:30 $ $Author: jenskapitza $
*/
public class AjaxDisplayTag extends AjaxAreaTag {
private static final long serialVersionUID = -5945152631578965550L;
private String pagelinksClass;
private String columnClass;
/**
* Default constructor.
*/
public AjaxDisplayTag() {
super();
init();
}
/**
* Initialize properties to default values. Used in {@link #AjaxDisplayTag()} and in
* {@link #releaseTag()}.
*/
private void init() {
this.pagelinksClass = "pagelinks";
this.columnClass = "sortable";
}
/**
* @return Returns the pagelinksClass.
*/
public String getPagelinksClass() {
return this.pagelinksClass;
}
/**
* @param pagelinksClass
* The pagelinksClass to set. Null-safe.
*/
public void setPagelinksClass(final String pagelinksClass) {
// this.pagelinksClass = pagelinksClass == null ? StringUtils.EMPTY : pagelinksClass;
this.pagelinksClass = trimToNull(pagelinksClass);
}
/**
* @return Returns the columnClass.
*/
public String getColumnClass() {
return this.columnClass;
}
/**
* @param columnClass
* The columnClass to set. Null-safe.
*/
public void setColumnClass(final String columnClass) {
// this.columnClass = columnClass == null ? StringUtils.EMPTY : columnClass;
this.columnClass = trimToNull(columnClass);
}
/**
* @see javax.servlet.jsp.tagext.Tag#release()
*/
@Override
public void releaseTag() {
super.releaseTag();
init();
}
private void rewriteAnchors0(final Document document) {
final NodeList links = document.getElementsByTagName("a");
for (int i = 0; i < links.getLength(); i++) {
final Node link = links.item(i);
final Node parent = link.getParentNode();
final Attr parentClass = (Attr) parent.getAttributes().getNamedItem("class");
if (parentClass == null) {
continue;
}
boolean rewrite = false;
final String parentName = parent.getNodeName();
final String parentClassValue = parentClass.getNodeValue();
if ("span".equals(parentName)) {
rewrite = StringUtils.contains(parentClassValue, getPagelinksClass());
} else if ("th".equals(parentName)) {
rewrite = StringUtils.contains(parentClassValue, getColumnClass());
}
if (rewrite) {
rewriteLink(link, getId());
}
}
}
/**
* Rewrite anchors in content.
*
* Parse content to XHTML {@link org.w3c.dom.Document}, rewrite DisplayTag anchor elements and
* return string representation of document.
*
* @throws JspException
* @see net.sourceforge.ajaxtags.tags.AjaxAreaTag#processContent(java.lang.String)
*/
@Override
protected String processContent(final String content) throws JspException {
try {
final Document doc = getDocument(content);
rewriteAnchors0(doc);
return XMLUtils.toString(doc);
} catch (SAXException e) {
throw new JspException(e);
} catch (TransformerException e) {
throw new JspException(e);
}
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxCalloutTag.java 0000644 0001750 0001750 00000005621 11300773740 031101 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.Tag;
/**
* Tag handler for the callout AJAX tag.
*
* @author Darren Spurgeon
* @version $Revision: 86 $ $Date: 2007/08/05 14:11:00 $ $Author: jenskapitza $
*/
public class AjaxCalloutTag extends BaseAjaxTag {
private static final long serialVersionUID = -2356224207093958968L;
private String title;
private String overlib;
private String emptyFunction;
private String openEventType;
private String closeEventType;
public String getCloseEventType() {
return this.closeEventType;
}
public void setCloseEventType(final String closeEvent) {
this.closeEventType = closeEvent;
}
public String getOpenEventType() {
return this.openEventType;
}
public void setOpenEventType(final String openEvent) {
this.openEventType = openEvent;
}
public String getEmptyFunction() {
return this.emptyFunction;
}
public void setEmptyFunction(final String emptyFunction) {
this.emptyFunction = emptyFunction;
}
public String getOverlib() {
return this.overlib;
}
public void setOverlib(final String overlib) {
this.overlib = overlib;
}
public String getTitle() {
return this.title;
}
public void setTitle(final String title) {
this.title = title;
}
@Override
protected String getJsClass() {
return JSCLASS_BASE + "Callout";
}
@Override
protected OptionsBuilder getOptions() {
final OptionsBuilder options = getOptionsBuilder();
options.add("title", this.title, true);
options.add("overlib", this.overlib, true);
options.add("emptyFunction", this.emptyFunction, false);
options.add("openEvent", this.openEventType, true);
options.add("closeEvent", this.closeEventType, true);
return options;
}
@Override
public int doEndTag() throws JspException {
out(buildScript());
return Tag.EVAL_PAGE;
}
@Override
public void releaseTag() {
this.title = null; // NOPMD
this.overlib = null; // NOPMD
this.emptyFunction = null; // NOPMD
this.openEventType = null; // NOPMD
this.closeEventType = null; // NOPMD
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxHtmlContentTag.java 0000644 0001750 0001750 00000002253 11300773736 031740 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
/**
* Tag handler for the HTML Content AJAX tag.
*
* @author Darren Spurgeon
* @version $Revision: 86 $ $Date: 2007/07/08 18:18:52 $ $Author: jenskapitza $
*/
public class AjaxHtmlContentTag extends BaseAjaxTag {
private static final long serialVersionUID = -2633087429107457075L;
@Override
protected String getJsClass() {
return JSCLASS_BASE + "HtmlContent";
}
@Override
public int doEndTag() throws JspException {
out(buildScript());
return EVAL_PAGE;
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxTabPanelTag.java 0000644 0001750 0001750 00000005311 11300773740 031160 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
import net.sourceforge.ajaxtags.helpers.DIVElement;
/**
* Tag handler for AJAX tabbed panel.
*
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/06/20 20:55:56 $ $Author: jenskapitza $
*/
public class AjaxTabPanelTag extends BaseAjaxBodyTag {
private static final long serialVersionUID = 4008240512963947567L;
private static final char PAGES_DELIMITER = ',';
// TODO refactor with List?
private StringBuilder pages = new StringBuilder();
@Override
protected void initParameters() throws JspException {
pages = new StringBuilder();
}
@Override
protected String getJsClass() {
return JSCLASS_BASE + "TabPanel";
}
@Override
protected OptionsBuilder getOptions() {
final OptionsBuilder options = getOptionsBuilder();
options.add("id", getId(), true);
options.add("pages", getPages(), false);
return options;
}
@Override
public int doEndTag() throws JspException {
// tabs
if (pages.length() == 0) {
throw new JspException("No tabs added to tab panel.");
}
final DIVElement div = new DIVElement(getId());
div.append(buildScript());
out(div);
return EVAL_PAGE;
}
@Override
public void releaseTag() {
this.pages = null; // NOPMD
}
/**
* Add one tab to panel.
*
* @param ajaxTabPageTag
* tab
*/
public final void addPage(final AjaxTabPageTag ajaxTabPageTag) {
if (pages.length() > 0) {
// append delimiter after previous tabs
pages.append(PAGES_DELIMITER);
}
pages.append(ajaxTabPageTag.toString());
}
/**
* Get list of tabs as JavaScript array (JSON).
*
* @return JSON string with array of tabs
*/
protected String getPages() {
/*if (pages.length() > 0 && pages.charAt(pages.length() - 1) == PAGES_DELIMITER) {
pages.deleteCharAt(pages.length() - 1);
}*/
return "[" + pages.toString() + "]";
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxEditorTag.java 0000644 0001750 0001750 00000011466 11300773740 030730 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
import net.sourceforge.ajaxtags.helpers.JavaScript;
/**
* Wraps the scriptaculous' in-place editor
* (http://github.com/madrobby/scriptaculous/wikis/ajax-inplaceeditor).
*
* @author Musachy Barroso
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/06/20 20:55:56 $ $Author: jenskapitza $
*/
public class AjaxEditorTag extends BaseAjaxTag {
private static final long serialVersionUID = -1129699932287300119L;
private String showAcceptButton;
private String acceptText;
private String showCancelLink;
private String cancelText;
private String savingText;
private String mouseOverText;
private String formId;
private String rows;
private String columns;
private String highlightColor;
@Override
protected void releaseTag() {
showAcceptButton = null; // NOPMD
acceptText = null; // NOPMD
showCancelLink = null; // NOPMD
cancelText = null; // NOPMD
savingText = null; // NOPMD
mouseOverText = null; // NOPMD
formId = null; // NOPMD
rows = null; // NOPMD
columns = null; // NOPMD
highlightColor = null; // NOPMD
}
@Override
public int doEndTag() throws JspException {
final OptionsBuilder options = getOptionsBuilder();
options.add("okControl", this.showAcceptButton, false);
options.add("okText", this.acceptText, true);
options.add("cancelControl", this.showCancelLink, false);
options.add("cancelText", this.cancelText, true);
options.add("savingText", this.savingText, true);
options.add("clickToEditText", this.mouseOverText, true);
// -- is wrong!
// options.add("callback", getPreFunction(), false);
// externalControl, externalControlOnly, submitOnBlur, ajaxOptions
options.add("formId", this.formId, true);
options.add("rows", this.rows, true);
options.add("cols", this.columns, true);
options.add("highlightcolor", this.highlightColor, true);
final JavaScript script = new JavaScript();
setVar("$editor_" + getTarget());
script.append(getJSVariable());
script.append("new Ajax.InPlaceEditor(\"");
script.append(getTarget());
script.append("\", \"");
script.append(getBaseUrl());
script.append("\", {\n");
script.append(options.toString());
script.append("});\n");
out(script);
return EVAL_PAGE;
}
public String getAcceptText() {
return acceptText;
}
public void setAcceptText(final String acceptText) {
this.acceptText = acceptText;
}
public String getCancelText() {
return cancelText;
}
public void setCancelText(final String cancelText) {
this.cancelText = cancelText;
}
public String getColumns() {
return columns;
}
public void setColumns(final String columns) {
this.columns = columns;
}
public String getHighlightColor() {
return highlightColor;
}
public void setHighlightColor(final String highlightColor) {
this.highlightColor = highlightColor;
}
public String getMouseOverText() {
return mouseOverText;
}
public void setMouseOverText(final String mouseOverText) {
this.mouseOverText = mouseOverText;
}
public String getRows() {
return rows;
}
public void setRows(final String rows) {
this.rows = rows;
}
public String getSavingText() {
return savingText;
}
public void setSavingText(final String savingText) {
this.savingText = savingText;
}
public String getShowAcceptButton() {
return showAcceptButton;
}
public void setShowAcceptButton(final String showAcceptButton) {
this.showAcceptButton = showAcceptButton;
}
public String getShowCancelLink() {
return showCancelLink;
}
public void setShowCancelLink(final String showCancelLink) {
this.showCancelLink = showCancelLink;
}
public String getFormId() {
return formId;
}
public void setFormId(final String formId) {
this.formId = formId;
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/BaseAjaxBodyTag.java 0000644 0001750 0001750 00000025166 11301001504 031153 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import static org.apache.commons.lang.StringUtils.trimToNull;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.BodyTagSupport;
import net.sourceforge.ajaxtags.helpers.JavaScript;
import net.sourceforge.ajaxtags.servlets.AjaxActionHelper.HMTLAjaxHeader;
/**
*
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/06/20 20:55:56 $ $Author: jenskapitza $
*/
public abstract class BaseAjaxBodyTag extends BodyTagSupport {
public static final String HEADER_FLAG = "X-Requested-With";
public static final String HEADER_FLAG_VALUE = "XMLHttpRequest";
public static final String AJAX_VOID_URL = "javascript://nop";
/**
* Common prefix for all JavaScript class names.
*/
public static final String JSCLASS_BASE = "AjaxJspTag.";
private static final long serialVersionUID = 2128368408391947139L;
/**
* True if the body should be ignored.
*/
private boolean skipBody;
private String styleClass;
private String source;
private String target;
private String baseUrl;
private String parser;
private String parameters;
private String preFunction;
private String postFunction;
private String errorFunction;
private String var;
private String attachTo;
private String sourceClass;
private String eventType;
protected HttpServletRequest getHttpServletRequest() {
return (HttpServletRequest) pageContext.getRequest();
}
protected HttpServletResponse getHttpServletResponse() {
return (HttpServletResponse) pageContext.getResponse();
}
protected boolean isHttpRequestHeader(final String headerName, final String headerValue) {
return headerValue.equalsIgnoreCase(getHttpRequestHeader(headerName));
}
protected String getHttpRequestHeader(final String headerName) {
return getHttpServletRequest().getHeader(headerName);
}
/**
* Detect if the client does an AJAX call or not.
*
* @return true only if the client send the header with XMLHttpRequest
*/
protected boolean isAjaxRequest() {
return isHttpRequestHeader(HEADER_FLAG, HEADER_FLAG_VALUE);
}
protected void out(final CharSequence csec) throws JspException {
try {
pageContext.getOut().append(csec);
} catch (IOException e) {
throw new JspException(e);
}
}
/**
* Ignore the body of the tag.
*/
protected final void skipBody() {
skipBody = true;
}
@Override
public final int doStartTag() throws JspException {
initParameters(); // EVAL_BODY need to be flushed if it is nested!
// we should set the no cache headers!
// enable the ajaxheaders
for (HMTLAjaxHeader header : HMTLAjaxHeader.values()) {
header.enable(getHttpServletResponse());
}
return skipBody ? SKIP_BODY : EVAL_BODY_BUFFERED;
}
@Override
public final void release() {
setId(null);
this.target = null; // NOPMD
this.baseUrl = null; // NOPMD
this.parser = null; // NOPMD
this.preFunction = null; // NOPMD
this.postFunction = null; // NOPMD
this.errorFunction = null; // NOPMD
this.parameters = null; // NOPMD
this.var = null; // NOPMD
this.attachTo = null; // NOPMD
this.source = null; // NOPMD
this.sourceClass = null; // NOPMD
this.eventType = null; // NOPMD
this.styleClass = null;
releaseTag();
}
public final String getEventType() {
return eventType;
}
public final void setEventType(final String eventType) {
this.eventType = trimToNull(eventType);
}
public final String getSourceClass() {
return sourceClass;
}
public final void setSourceClass(final String sourceClass) {
this.sourceClass = trimToNull(sourceClass);
}
public final String getSource() {
return source;
}
public final void setSource(final String source) {
this.source = trimToNull(source);
}
public final String getVar() {
return var;
}
public final void setVar(final String var) {
this.var = trimToNull(var);
}
public final void setAttachTo(final String attachTo) {
this.attachTo = trimToNull(attachTo);
}
public final String getAttachTo() {
return attachTo;
}
/**
* @return Returns the styleClass.
*/
public final String getStyleClass() {
return this.styleClass;
}
/**
* @param styleClass
* The styleClass to set.
*/
public final void setStyleClass(final String styleClass) {
this.styleClass = trimToNull(styleClass);
}
/**
* Build JavaScript assignment string.
*
* @return String with assignment to variable "var x = " or field "object.field = "
*/
public final String getJSVariable() {
final StringBuilder script = new StringBuilder();
if (this.var != null) {
if (this.attachTo == null) {
script.append("var ");
} else {
script.append(this.attachTo).append(".");
}
script.append(this.var).append(" = ");
}
return script.toString();
}
/**
* Return JavaScript class for JavaScript class corresponding to this tag (e.g.
* "AjaxJspTag.Submit" for AjaxSubmitTag Java tag).
*
* @return String with JavaScript class suffix
*/
protected String getJsClass() {
throw new UnsupportedOperationException(
"You must implement getJsClass() in your tag class to use buildScript().");
}
/**
* Options for JavaScript generation.
*
* @return default options
*/
protected OptionsBuilder getOptions() {
return getOptionsBuilder();
}
/**
* Generate JavaScript for tag.
*
* @return JavaScript
*/
public JavaScript buildScript() {
return new JavaScript(getJSVariable() + "new " + getJsClass() + "({" + getOptions() + "});");
}
public final String getParameters() {
return parameters;
}
public final void setParameters(final String parameters) {
this.parameters = trimToNull(parameters);
}
public final String getErrorFunction() {
return errorFunction;
}
public final void setErrorFunction(final String errorFunction) {
this.errorFunction = trimToNull(errorFunction);
}
public final String getPostFunction() {
return postFunction;
}
public final void setPostFunction(final String postFunction) {
this.postFunction = trimToNull(postFunction);
}
public final String getPreFunction() {
return preFunction;
}
public final void setPreFunction(final String preFunction) {
this.preFunction = trimToNull(preFunction);
}
public final String getParser() {
return parser;
}
public final void setParser(final String parser) {
this.parser = trimToNull(parser);
}
public final String getBaseUrl() {
return baseUrl;
}
public final void setBaseUrl(final String baseUrl) {
this.baseUrl = trimToNull(baseUrl);
}
/**
* @return Returns the target.
*/
public final String getTarget() {
return this.target;
}
/**
* @param target
* The target to set.
*/
public final void setTarget(final String target) {
this.target = trimToNull(target);
}
protected void initParameters() throws JspException {
}
/**
* Never call release() from releaseTag() -> ends in loop.
*/
protected void releaseTag() {
}
/**
* @return the OptionsBuilder with default options
*/
protected OptionsBuilder getOptionsBuilder() {
return getOptionsBuilder(false);
}
protected OptionsBuilder getOptionsBuilder(final boolean empty) {
final OptionsBuilder builder = OptionsBuilder.getOptionsBuilder();
if (empty) {
return builder;
}
builder.add("baseUrl", getBaseUrl(), true);
builder.add("parser", getParser(), false);
builder.add("target", getTarget(), true);
builder.add("source", getSource(), true);
builder.add("sourceClass", getSourceClass(), true);
builder.add("eventType", getEventType(), true);
builder.add("parameters", getParameters(), true);
builder.add("onCreate", this.preFunction, false);
builder.add("onComplete", this.postFunction, false);
builder.add("onFailure", this.errorFunction, false);
return builder;
}
/**
* Helper to define new AJAX updater for onclick attribute.
*
* @param target
* the target to request
* @param href
* the URL
* @param opt
* options for javascript library
* @return the javascript code to do AJAX update
*/
protected final String getOnclickAjax(final String target, final String href,
final OptionsBuilder opt) {
final OptionsBuilder options = OptionsBuilder.getOptionsBuilder(opt);
// copy all options
options.add("target", target, true);
options.add("baseUrl", href, true);
options.add("eventBase", "this", false);
options.add("requestHeaders", "['" + AjaxAreaTag.TARGET_HEADER + "', '" + target + "']",
false);
// TODO with JavaScript class
final StringBuilder onclick = new StringBuilder("new AjaxJspTag.OnClick({");
onclick.append(options.toString());
onclick.append("}); return false;");
return onclick.toString();
}
protected String getBody() {
final BodyContent body = this.getBodyContent();
if (body == null) {
return null;
}
return body.getString();
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxPortletTag.java 0000644 0001750 0001750 00000010516 11300773740 031126 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
import net.sourceforge.ajaxtags.helpers.DIVElement;
/**
* Tag handler for the portlet AJAX tag.
*
* @author Darren Spurgeon
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/06/28 21:50:35 $ $Author: jenskapitza $
*/
public class AjaxPortletTag extends BaseAjaxTag {
private static final long serialVersionUID = -8528089710699925100L;
private boolean startMinimize;
private String classNamePrefix;
private String title;
private String imageClose;
private String imageMaximize;
private String imageMinimize;
private String imageRefresh;
private String refreshPeriod;
private boolean executeOnLoad;
public void setStartMinimize(final boolean startMinimize) {
this.startMinimize = startMinimize;
}
public boolean getStartMinimize() {
return this.startMinimize;
}
public String getClassNamePrefix() {
return classNamePrefix;
}
public void setClassNamePrefix(final String classNamePrefix) {
this.classNamePrefix = classNamePrefix;
}
public String getImageClose() {
return imageClose;
}
public void setImageClose(final String imageClose) {
this.imageClose = imageClose;
}
public boolean getExecuteOnLoad() {
return executeOnLoad;
}
public void setExecuteOnLoad(final boolean executeOnLoad) {
this.executeOnLoad = executeOnLoad;
}
public String getImageMaximize() {
return imageMaximize;
}
public void setImageMaximize(final String imageMaximize) {
this.imageMaximize = imageMaximize;
}
public String getImageMinimize() {
return imageMinimize;
}
public void setImageMinimize(final String imageMinimize) {
this.imageMinimize = imageMinimize;
}
public String getImageRefresh() {
return imageRefresh;
}
public void setImageRefresh(final String imageRefresh) {
this.imageRefresh = imageRefresh;
}
public String getRefreshPeriod() {
return refreshPeriod;
}
public void setRefreshPeriod(final String refreshPeriod) {
this.refreshPeriod = refreshPeriod;
}
public String getTitle() {
return title;
}
public void setTitle(final String title) {
this.title = title;
}
@Override
protected String getJsClass() {
return JSCLASS_BASE + "Portlet";
}
@Override
protected OptionsBuilder getOptions() {
final OptionsBuilder options = getOptionsBuilder();
options.add("classNamePrefix", this.classNamePrefix, true);
options.add("title", this.title, true);
options.add("imageClose", this.imageClose, true);
options.add("imageMaximize", this.imageMaximize, true);
options.add("imageMinimize", this.imageMinimize, true);
options.add("imageRefresh", this.imageRefresh, true);
options.add("refreshPeriod", this.refreshPeriod, true);
options.add("executeOnLoad", this.executeOnLoad);
options.add("startMinimize", this.startMinimize);
return options;
}
@Override
public int doEndTag() throws JspException {
final DIVElement div = new DIVElement(getSource());
div.setBody(buildScript());
out(div);
return EVAL_PAGE;
}
@Override
protected void releaseTag() {
this.startMinimize = false;
this.classNamePrefix = null; // NOPMD
this.title = null; // NOPMD
this.imageClose = null; // NOPMD
this.imageMaximize = null; // NOPMD
this.imageMinimize = null; // NOPMD
this.imageRefresh = null; // NOPMD
this.refreshPeriod = null; // NOPMD
this.executeOnLoad = false;
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxTreeTag.java 0000644 0001750 0001750 00000005410 11300773736 030376 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
import net.sourceforge.ajaxtags.helpers.DIVElement;
/**
* Tag handler for the tree AJAX tag.
*
* @author Musachy Barroso
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/06/20 20:55:56 $ $Author: jenskapitza $
*/
public class AjaxTreeTag extends BaseAjaxTag {
private static final long serialVersionUID = -1607090849231461287L;
private String collapsedClass;
private String expandedClass;
private String nodeClass;
private String treeClass;
public String getTreeClass() {
return treeClass;
}
public void setTreeClass(final String treeClass) {
this.treeClass = treeClass;
}
public String getNodeClass() {
return nodeClass;
}
public void setNodeClass(final String nodeClass) {
this.nodeClass = nodeClass;
}
public String getCollapsedClass() {
return collapsedClass;
}
public void setCollapsedClass(final String collapsedClass) {
this.collapsedClass = collapsedClass;
}
public String getExpandedClass() {
return expandedClass;
}
public void setExpandedClass(final String expandedClass) {
this.expandedClass = expandedClass;
}
@Override
protected String getJsClass() {
return JSCLASS_BASE + "Tree";
}
@Override
protected OptionsBuilder getOptions() {
final OptionsBuilder options = getOptionsBuilder();
options.add("target", getId(), true);
options.add("collapsedClass", this.collapsedClass, true);
options.add("expandedClass", this.expandedClass, true);
options.add("treeClass", this.treeClass, true);
options.add("nodeClass", this.nodeClass, true);
return options;
}
@Override
public int doEndTag() throws JspException {
final DIVElement div = new DIVElement(getId());
div.setBody(buildScript());
out(div);
return EVAL_PAGE;
}
@Override
protected void releaseTag() {
collapsedClass = null; // NOPMD
expandedClass = null; // NOPMD
nodeClass = null; // NOPMD
treeClass = null; // NOPMD
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxSelectTag.java 0000644 0001750 0001750 00000005326 11300773740 030717 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
/**
* Tag handler for the select AJAX tag.
*
* @author Darren Spurgeon
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/07/08 17:52:30 $ $Author: jenskapitza $
*/
public class AjaxSelectTag extends BaseAjaxTag {
private static final long serialVersionUID = -686763601190277341L;
private String emptyOptionValue;
private String emptyOptionName;
private boolean executeOnLoad;
private String defaultOptions;
public void setEmptyOptionName(final String emptyOptionName) {
this.emptyOptionName = emptyOptionName;
}
public String getEmptyOptionName() {
return emptyOptionName;
}
public void setEmptyOptionValue(final String emptyOptionValue) {
this.emptyOptionValue = emptyOptionValue;
}
public String getEmptyOptionValue() {
return emptyOptionValue;
}
public boolean getExecuteOnLoad() {
return executeOnLoad;
}
public void setExecuteOnLoad(final boolean executeOnLoad) {
this.executeOnLoad = executeOnLoad;
}
public String getDefaultOptions() {
return defaultOptions;
}
public void setDefaultOptions(final String defaultOptions) {
this.defaultOptions = defaultOptions;
}
@Override
protected String getJsClass() {
return JSCLASS_BASE + "Select";
}
@Override
protected OptionsBuilder getOptions() {
final OptionsBuilder options = getOptionsBuilder();
options.add("executeOnLoad", this.executeOnLoad);
options.add("defaultOptions", this.defaultOptions, true);
options.add("emptyOptionValue", emptyOptionValue, true);
options.add("emptyOptionName", emptyOptionName, true);
return options;
}
@Override
public int doEndTag() throws JspException {
out(buildScript());
return EVAL_PAGE;
}
@Override
public void releaseTag() {
this.executeOnLoad = false;
this.defaultOptions = null; // NOPMD
this.emptyOptionName = null; // NOPMD
this.emptyOptionValue = null; // NOPMD
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxAreaTag.java 0000644 0001750 0001750 00000007174 11301002212 030327 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import net.sourceforge.ajaxtags.helpers.DIVElement;
/**
* Wraps any area on the page (with a DIV element) so that actions within that area refresh/load
* inside the defined DIV region rather than inside the whole browser window.
*
* @author Darren Spurgeon
* @author Jens Kapitza
*/
public class AjaxAreaTag extends AjaxAnchorsTag {
/**
* The header we are seraching to detect the ajax call. This should match the id of this tag.
*/
public static final String TARGET_HEADER = "x-request-target";
private static final long serialVersionUID = -7940387487602588115L;
/**
* flag if we should <a> tags be rewritte to use ajaxlinks
*/
private boolean ajaxAnchors;
/**
* @return Returns true if we answering to AJAX request: request has proper "X-Requested-With"
* and "x-request-target" headers.
*/
@Override
public final boolean isAjaxRequest() {
return super.isAjaxRequest() && isHttpRequestHeader(TARGET_HEADER, getId());
}
/**
* @return Returns the ajaxAnchors.
*/
public final boolean isAjaxAnchors() {
return this.ajaxAnchors;
}
/**
* @param ajaxAnchors
* The ajaxAnchors to set.
*/
public final void setAjaxAnchors(final boolean ajaxAnchors) {
this.ajaxAnchors = ajaxAnchors;
}
/**
* Clear page content before start of tag if we are processing AJAX request.
*
* @throws JspException
* when HTTP response cannot be reset (has already had its status code and headers
* written)
*/
@Override
public void initParameters() throws JspException {
if (isAjaxRequest()) {
try {
pageContext.getOut().clearBuffer();
} catch (IOException e) {
throw new JspException(e);
}
}
}
/**
* Write body. Skip the rest of the page if we are processing AJAX request.
*
* @return SKIP_PAGE for AJAX request, EVAL_PAGE for usual request
* @throws JspException
* on errors
*/
@Override
public int doEndTag() throws JspException {
final DIVElement div = new DIVElement(getId());
div.append(processContent(getBody()));
if (getStyleClass() != null) {
div.setClassName(getStyleClass());
}
out(isAjaxRequest() ? div.getBody() : div);
return isAjaxRequest() ? SKIP_PAGE : EVAL_PAGE;
}
/**
* @see javax.servlet.jsp.tagext.Tag#release()
*/
@Override
public void releaseTag() {
this.ajaxAnchors = false;
}
/**
* Process content.
*
* @param content
* @return processed content
* @throws JspException
* @throws Exception
*/
protected String processContent(final String content) throws JspException {
return isAjaxAnchors() ? ajaxAnchors(content, getId(), getSourceClass()) : content;
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/OptionsBuilder.java 0000644 0001750 0001750 00000012421 11300773740 031174 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import org.apache.commons.lang.StringUtils;
/**
* Helper class to assist in building options passed to JavaScript method. This class makes no
* guarantees as to the order of the options; in particular, it does not guarantee that the order
* will remain constant over time.
*
* @author Darren Spurgeon
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/06/20 20:55:56 $ $Author: jenskapitza $
*/
public final class OptionsBuilder {
private String optionsDelimiter = ", "; // ",\n"
private final SortedMap parameters = new TreeMap();
private OptionsBuilder() {
}
private OptionsBuilder(final OptionsBuilder opt) {
if (opt != null) {
this.parameters.putAll(opt.parameters);
}
}
/**
* Get new OptionsBuilder with initial options.
*
* @param opt
* initial options
* @return new empty OptionsBuilder
*/
public static OptionsBuilder getOptionsBuilder(final OptionsBuilder opt) {
return new OptionsBuilder(opt);
}
/**
* Get new empty OptionsBuilder.
*
* @return new empty OptionsBuilder
*/
public static OptionsBuilder getOptionsBuilder() {
return getOptionsBuilder(null);
}
/**
* @return the optionsDelimiter
*/
public String getOptionsDelimiter() {
return optionsDelimiter;
}
/**
* @param optionsDelimiter
* the optionsDelimiter to set
*/
public void setOptionsDelimiter(final String optionsDelimiter) {
this.optionsDelimiter = optionsDelimiter;
}
/**
* Add boolean option. Option with given name is added only once.
*
* @param parameter
* name of option
* @param value
* value of option
* @return updated OptionsBuilder
*/
public OptionsBuilder add(final String parameter, final boolean value) {
return add(parameter, String.valueOf(value), false);
}
/**
* Add integer option. Option with given name is added only once.
*
* @param parameter
* name of option
* @param value
* value of option
* @return updated OptionsBuilder
*/
public OptionsBuilder add(final String parameter, final int value) {
return add(parameter, String.valueOf(value), false);
}
/**
* Add option. Option is added only once. If {@link OptionsBuilder} already contains option with
* given name, it will stay unchanged.
*
* @param parameter
* name of option
* @param value
* value of option
* @param quoted
* true if value must be surrounded with quotes
* @return updated OptionsBuilder
*/
public OptionsBuilder add(final String parameter, final String value, final boolean quoted) {
if (value != null && !this.parameters.containsKey(parameter)) {
if (quoted) {
this.parameters.put(parameter, "\"" + value + "\"");
} else {
this.parameters.put(parameter, value);
}
}
return this;
}
/**
* Add option. Overwrite previous value if it exists.
*
* @param parameter
* name of option
* @param value
* value of option
* @param quoted
* true if value must be surrounded with quotes
* @param forceWrite
* boolean flag to indicate that previous value must be overwritten
* @return updated OptionsBuilder
*/
public OptionsBuilder add(final String parameter, final String value, final boolean quoted,
final boolean forceWrite) {
if (this.parameters.containsKey(parameter)) {
this.parameters.remove(parameter);
}
return add(parameter, value, quoted);
}
/**
* Remove option.
*
* @param parameter
* name of option
* @return updated OptionsBuilder
*/
public OptionsBuilder remove(final String parameter) {
this.parameters.remove(parameter);
return this;
}
/**
* Create string representation of options (in JSON format).
*
* @return options as string
*/
@Override
public String toString() {
final List options = new ArrayList();
for (Map.Entry e : parameters.entrySet()) {
options.add(e.getKey() + ": " + e.getValue());
}
return StringUtils.join(options, optionsDelimiter);
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxFormFieldTag.java 0000644 0001750 0001750 00000004020 11300773736 031342 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
/**
* Tag handler for the form field AJAX tag.
*
* @author Darren Spurgeon
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/06/20 20:55:56 $ $Author: jenskapitza $
*/
public class AjaxFormFieldTag extends BaseAjaxTag {
private static final long serialVersionUID = -7774526024294932262L;
private String action;
private boolean valueUpdateByName;
public String getAction() {
return action;
}
public void setAction(final String action) {
this.action = action;
}
@Override
protected String getJsClass() {
return JSCLASS_BASE + "UpdateField";
}
@Override
protected OptionsBuilder getOptions() {
final OptionsBuilder options = getOptionsBuilder();
options.add("action", this.action, true);
options.add("valueUpdateByName", String.valueOf(this.valueUpdateByName), false);
return options;
}
@Override
public int doEndTag() throws JspException {
out(buildScript());
return EVAL_PAGE;
}
@Override
public void releaseTag() {
this.valueUpdateByName = false;
this.action = null; // NOPMD
}
public boolean getValueUpdateByName() {
return valueUpdateByName;
}
public void setValueUpdateByName(final boolean valueUpdateByName) {
this.valueUpdateByName = valueUpdateByName;
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxToggleTag.java 0000644 0001750 0001750 00000015106 11300773736 030723 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import static org.apache.commons.lang.StringUtils.trimToNull;
import javax.servlet.jsp.JspException;
import net.sourceforge.ajaxtags.helpers.DIVElement;
/**
* Tag handler for the toggle (on/off, true/false) AJAX tag.
*
* @author Darren Spurgeon
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/06/20 20:55:56 $ $Author: jenskapitza $
*/
public class AjaxToggleTag extends BaseAjaxTag {
private static final long serialVersionUID = 6877730352175914711L;
private static final String AVOID_URL_START = "";
private String ratings;
private String defaultRating;
private String state;
private boolean onOff;
private String containerClass;
private String messageClass;
private String selectedClass;
private String selectedOverClass;
private String selectedLessClass;
private String overClass;
private String updateFunction;
public String getUpdateFunction() {
return updateFunction;
}
public void setUpdateFunction(final String updateFunction) {
this.updateFunction = updateFunction;
}
public String getContainerClass() {
return containerClass;
}
public void setContainerClass(final String containerClass) {
this.containerClass = containerClass;
}
public String getDefaultRating() {
return defaultRating;
}
public void setDefaultRating(final String defaultRating) {
this.defaultRating = trimToNull(defaultRating);
}
public String getMessageClass() {
return messageClass;
}
public void setMessageClass(final String messageClass) {
this.messageClass = messageClass;
}
public String getOnOff() {
return Boolean.toString(onOff);
}
public void setOnOff(final String onOff) {
this.onOff = Boolean.parseBoolean(onOff);
}
public String getOverClass() {
return overClass;
}
public void setOverClass(final String overClass) {
this.overClass = overClass;
}
public String getRatings() {
return ratings;
}
public void setRatings(final String ratings) {
this.ratings = trimToNull(ratings);
}
public String getSelectedClass() {
return selectedClass;
}
public void setSelectedClass(final String selectedClass) {
this.selectedClass = selectedClass;
}
public String getSelectedLessClass() {
return selectedLessClass;
}
public void setSelectedLessClass(final String selectedLessClass) {
this.selectedLessClass = selectedLessClass;
}
public String getSelectedOverClass() {
return selectedOverClass;
}
public void setSelectedOverClass(final String selectedOverClass) {
this.selectedOverClass = selectedOverClass;
}
public String getState() {
return state;
}
public void setState(final String state) {
this.state = state;
}
@Override
protected String getJsClass() {
return JSCLASS_BASE + "Toggle";
}
@Override
protected OptionsBuilder getOptions() {
final OptionsBuilder options = getOptionsBuilder();
options.add("ratings", this.ratings, true);
options.add("containerClass", this.containerClass, true);
options.add("selectedClass", this.selectedClass, true);
options.add("selectedOverClass", this.selectedOverClass, true);
options.add("selectedLessClass", this.selectedLessClass, true);
options.add("overClass", this.overClass, true);
options.add("messageClass", this.messageClass, true);
options.add("state", this.state, true);
// options.add("onOff", this.onOff, true);
options.add("defaultRating", this.defaultRating, true);
options.add("updateFunction", this.updateFunction, false);
return options;
}
@Override
public int doEndTag() throws JspException {
// final boolean xOnOff = Boolean.parseBoolean(onOff);
// write opening div
final DIVElement div = new DIVElement(getSource());
div.setClassName(getRatingDivClass(onOff, getContainerClass()));
// TODO write this in javascript
// XXX write this in javascript!!!!
// write links
final String[] ratingValues = getRatingValues();
if (onOff) {
div.append(AVOID_URL_START);
if (ratingValues.length > 0) {
final String val = ratingValues[0];
if (defaultRating != null && defaultRating.equalsIgnoreCase(val)) {
div.append(val).append("\" class=\"").append(selectedClass);
} else {
div.append(ratingValues[1]);
}
}
div.append(AVOID_URL_END);
} else {
for (String val : ratingValues) {
div.append(AVOID_URL_START).append(val);
if (val.equalsIgnoreCase(defaultRating)) {
div.append("\" class=\"").append(selectedClass);
}
div.append(AVOID_URL_END);
}
}
// write script
div.append(buildScript());
out(div);
return EVAL_PAGE;
}
private String[] getRatingValues() {
return ratings == null ? new String[0] : ratings.split(",");
}
private String getRatingDivClass(final boolean onOff, final String containerClass) {
return onOff ? containerClass + " onoff" : containerClass;
}
@Override
public void releaseTag() {
this.ratings = null; // NOPMD
this.defaultRating = null; // NOPMD
this.state = null; // NOPMD
this.onOff = false;
this.containerClass = null; // NOPMD
this.messageClass = null; // NOPMD
this.selectedClass = null; // NOPMD
this.selectedOverClass = null; // NOPMD
this.selectedLessClass = null; // NOPMD
this.overClass = null; // NOPMD
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxTabPageTag.java 0000644 0001750 0001750 00000004302 11300773740 030774 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.tags;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
/**
* Tag handler for individual page within a AJAX tabbed panel.
*
* @author Darren Spurgeon
* @version $Revision: 86 $ $Date: 2007/06/20 20:55:56 $ $Author: jenskapitza $
*/
public class AjaxTabPageTag extends BaseAjaxTag {
private static final long serialVersionUID = 2438025605821348018L;
private String caption;
private String defaultTab;
public final String getCaption() {
return caption;
}
public final void setCaption(final String caption) {
this.caption = caption;
}
public final String getDefaultTab() {
return defaultTab;
}
public final void setDefaultTab(final String defaultTab) {
this.defaultTab = String.valueOf(defaultTab);
}
@Override
public String toString() {
final OptionsBuilder options = getOptionsBuilder(true); // clean one
options.add("caption", getCaption(), true);
options.add("baseUrl", getBaseUrl(), true);
options.add("parameters", getParameters(), true);
options.add("defaultTab", getDefaultTab(), false);
return "{" + options.toString() + "}";
}
@Override
public int doEndTag() throws JspException {
final AjaxTabPanelTag parent = (AjaxTabPanelTag) TagSupport.findAncestorWithClass(this,
AjaxTabPanelTag.class);
parent.addPage(this);
return EVAL_PAGE;
}
@Override
public void releaseTag() {
this.caption = null; // NOPMD
this.defaultTab = null; // NOPMD
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/xml/ 0000755 0001750 0001750 00000000000 11250754334 025233 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/xml/AjaxValueListXmlBuilder.java 0000644 0001750 0001750 00000005771 11300773740 032612 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.xml;
import net.sourceforge.ajaxtags.helpers.ValueItem;
/**
* Helper class to build valid XML for ajax with more than one value.
*
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/07/22 16:29:16 $ $Author: jenskapitza $
*/
public abstract class AjaxValueListXmlBuilder extends BaseXmlBuilder {
/**
* Add an Item.
*
* @param name
* the name
* @param asCdata
* true if so else false
* @param value
* a list of values
* @return the XML builder
*
*/
public AjaxValueListXmlBuilder addItem(final String name, final boolean asCdata,
final String... value) {
getList().add(new ValueItem(name, asCdata, value));
return this;
}
/**
* Add an Item with asCdata = false.
*
* @param name
* the name
* @param value
* a list of values
* @return the XML builder
*/
public AjaxValueListXmlBuilder addItem(final String name, final String... value) {
return addItem(name, false, value);
}
/**
* Build the node.
*
* @param item
* the item
* @return XML string for this item
*/
private static String valueToString(final ValueItem item) {
final StringBuilder xml = new StringBuilder("");
if (item.isAsCData()) {
xml.append(CDATA_START);
}
xml.append(item.getName());
if (item.isAsCData()) {
xml.append(CDATA_END);
}
xml.append("");
for (String value : item.getValue()) {
xml.append("");
if (item.isAsCData()) {
xml.append(CDATA_START);
}
xml.append(value);
if (item.isAsCData()) {
xml.append(CDATA_END);
}
xml.append("");
}
return xml.toString();
}
/**
* Build the XML string.
*
* @see BaseXmlBuilder#getXMLString()
*/
@Override
protected String getXMLString() {
final StringBuilder xml = new StringBuilder(RESPONSE_START);
for (ValueItem item : getItems()) {
xml.append("");
xml.append(valueToString(item));
xml.append("");
}
xml.append(RESPONSE_END);
return xml.toString();
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/xml/AjaxTreeXmlBuilder.java 0000644 0001750 0001750 00000017533 11301073340 031566 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.xml;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import net.sourceforge.ajaxtags.helpers.TreeItem;
import net.sourceforge.ajaxtags.helpers.TreeItem.TreeAttribute;
/**
* Helper class to build valid XML, for the AjaxTreeTag, typically returned in a response to the
* client.
*
* @author Musachy Barroso
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/07/24 12:21:13 $ $Author: jenskapitza $
*/
public final class AjaxTreeXmlBuilder extends BaseXmlBuilder {
/**
* Add tree item to XML builder.
*
* @param name
* name
* @param value
* value
* @return AjaxTreeXmlBuilder XML builder
*/
public AjaxTreeXmlBuilder addItem(final String name, final String value) {
return addItem(name, value, null);
}
/**
* Add tree item to XML builder.
*
* @param name
* name
* @param value
* value
* @return AjaxTreeXmlBuilder XML builder
*/
public AjaxTreeXmlBuilder addItemAsCData(final String name, final String value) {
return addItemAsCData(name, value, null);
}
/**
* Add tree item to XML builder.
*
* @param name
* name
* @param value
* value
* @param attributes
* attributes
* @return AjaxTreeXmlBuilder XML builder
*/
public AjaxTreeXmlBuilder addItemAsCData(final String name, final String value,
final Map attributes) {
return addItem(name, value, true, attributes);
}
/**
* Add tree item to XML builder.
*
* @param name
* name
* @param value
* value
* @param attributes
* attributes
* @return AjaxTreeXmlBuilder XML builder
*/
public AjaxTreeXmlBuilder addItem(final String name, final String value,
final Map attributes) {
return addItem(name, value, false, attributes);
}
/**
* Add tree item to XML builder.
*
* @param name
* name
* @param value
* value
* @param asCData
* true if item must be present as CDATA
* @param attributes
* item attributes
* @return AjaxTreeXmlBuilder XML builder
*/
public AjaxTreeXmlBuilder addItem(final String name, final String value, final boolean asCData,
final Map, String> attributes) {
getList().add(new TreeItem(name, value, asCData, attributes));
return this;
}
/**
* Add tree item to XML builder.
*
* @param name
* name
* @param value
* value
* @param url
* URL
* @param asCData
* true if item must be present as CDATA
* @return AjaxTreeXmlBuilder XML builder
*/
public AjaxTreeXmlBuilder addItem(final String name, final String value, final String url,
final boolean asCData) {
return addItem(name, value, false, url, asCData);
}
/**
* Add tree item to XML builder.
*
* @param name
* name
* @param value
* value
* @param collapsed
* true if subtree is initially collapsed
* @param url
* URL
* @return AjaxTreeXmlBuilder XML builder
*/
public AjaxTreeXmlBuilder addItem(final String name, final String value,
final boolean collapsed, final String url) {
return addItem(name, value, collapsed, url, false);
}
/**
* Add tree item to XML builder.
*
* @param name
* name
* @param value
* value
* @param collapsed
* true if subtree is initially collapsed
* @param url
* URL
* @param asCData
* true if item must be present as CDATA
* @return AjaxTreeXmlBuilder XML builder
*/
public AjaxTreeXmlBuilder addItem(final String name, final String value,
final boolean collapsed, final String url, final boolean asCData) {
final Map data = new HashMap();
data.put(TreeAttribute.URL, url);
data.put(TreeAttribute.COLLAPSED, String.valueOf(collapsed));
return addItem(name, value, asCData, data);
}
/**
* Add tree item to XML builder.
*
* @param name
* name
* @param value
* value
* @param collapsed
* true if subtree is initially collapsed
* @param url
* URL
* @return AjaxTreeXmlBuilder XML builder
*/
public AjaxTreeXmlBuilder addItemAsCData(final String name, final String value,
final boolean collapsed, final String url) {
final Map data = new HashMap();
data.put(TreeAttribute.URL, url);
data.put(TreeAttribute.COLLAPSED, String.valueOf(collapsed));
return addItem(name, value, true, data);
}
public interface PropertyReader {
String getName();
boolean isCollapsed();
String getURL();
boolean isLeaf();
String getValue();
boolean isCData();
}
public AjaxTreeXmlBuilder addItems(final Collection collection) {
for (PropertyReader element : collection) {
addItem(element);
}
return this;
}
public AjaxTreeXmlBuilder addItem(final PropertyReader element) {
final Map data = new HashMap();
data.put(TreeAttribute.URL, element.getURL());
data.put(TreeAttribute.COLLAPSED, String.valueOf(element.isCollapsed()));
data.put(TreeAttribute.LEAF, String.valueOf(element.isLeaf()));
addItem(element.getName(), element.getValue(), element.isCData(), data);
return this;
}
/**
* Build an XML body to describe TreeItem.
*
* @see BaseXmlBuilder#getXMLString()
*/
@Override
protected String getXMLString() {
final StringBuilder xml = new StringBuilder(RESPONSE_START);
for (TreeItem item : getItems()) {
xml.append("");
if (item.isAsCData()) {
xml.append(CDATA_START);
}
xml.append(item.getName());
if (item.isAsCData()) {
xml.append(CDATA_END);
}
xml.append("");
if (item.isAsCData()) {
xml.append(CDATA_START);
}
xml.append(item.getValue());
if (item.isAsCData()) {
xml.append(CDATA_END);
}
xml.append("");
for (Object attr : item.getAttributeKeySet()) {
final String tagName = attr.toString().toLowerCase(Locale.getDefault());
xml.append('<').append(tagName).append('>');
xml.append(item.getAttributeValue(attr));
xml.append("").append(tagName).append('>');
}
xml.append("");
}
xml.append(RESPONSE_END);
return xml.toString();
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/xml/BaseXmlBuilder.java 0000644 0001750 0001750 00000006776 11300773740 030756 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.xml;
import java.util.ArrayList;
import java.util.List;
/**
* Helper class to build valid XML as a base for all XML builders.
*
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/07/22 16:58:28 $ $Author: jenskapitza $
* @param
* type of list elements (Item, TreeItem)
*/
public abstract class BaseXmlBuilder {
/**
* AJAX response opening tags.
*/
static final String RESPONSE_START = "";
/**
* AJAX response closing tags.
*/
static final String RESPONSE_END = "";
/**
* Starting CDATA sequence.
*/
static final String CDATA_START = "";
private List list = new ArrayList();
/**
* Default encoding is UTF-8.
*/
private String encoding = "UTF-8";
protected List getList() {
return this.list;
}
protected void setList(final List list) {
this.list = list;
}
/**
* @return the XML encoding
*/
public String getEncoding() {
return this.encoding;
}
/**
* Set the XML encoding.
*
* @param encoding
* the XML encoding
*/
public void setEncoding(final String encoding) {
this.encoding = encoding;
}
/**
*
* @return the item list
*/
protected List getItems() {
return getList();
}
/**
* @return the XML body, XML encoding is added by {@link #toString()}
*/
protected abstract String getXMLString();
/**
* @return the full XML document
*/
@Override
public String toString() {
final StringBuilder xml = new StringBuilder("");
xml.append(getXMLString());
return xml.toString();
}
/**
* Add item to list.
*
* @param item
* the item to add
* @return BaseXmlBuilder
* @see ArrayList#add(Object)
*/
public BaseXmlBuilder add(final V item) {
this.list.add(item);
return this;
}
/**
* Delete all items.
*/
public void clear() {
this.list.clear();
}
/**
* Return the item at index.
*
* @param index
* the index
* @return the item at index
*/
public V get(final int index) {
return this.list.get(index);
}
/**
* Check if list contains no elements (is empty).
*
* @return true if it is empty else false
*/
public boolean isEmpty() {
return this.list.isEmpty();
}
/**
* @return the item count
*/
public int size() {
return this.list.size();
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/xml/AjaxXmlBuilder.java 0000644 0001750 0001750 00000005015 11300773736 030755 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.xml;
import java.util.Collection;
/**
* Helper class to build valid XML typically returned in a response to the client.
*
* @author Darren Spurgeon
* @author Jens Kapitza
* @version $Revision: 86 $ $Date: 2007/07/22 16:29:16 $ $Author: jenskapitza $
*/
public final class AjaxXmlBuilder extends AjaxValueListXmlBuilder {
/**
* Add item to XML.
*
* @param name
* The name of the item
* @param value
* The value of the item
* @return the XML builder
*/
public AjaxXmlBuilder addItem(final String name, final String value) {
return addItem(name, value, false);
}
/**
* Add item wrapped with inside a CDATA element.
*
* @param name
* The name of the item
* @param value
* The value of the item
* @return the XML builder
*/
public AjaxXmlBuilder addItemAsCData(final String name, final String value) {
return addItem(name, value, true);
}
/**
* Add item to XML.
*
* @param name
* The name of the item
* @param value
* The value of the item
* @param asCData
* add as CData
* @return the XML builder
*/
public AjaxXmlBuilder addItem(final String name, final String value, final boolean asCData) {
super.addItem(name, asCData, value);
return this;
}
public interface PropertyReader {
String getName();
String getValue();
boolean isCData();
}
public AjaxXmlBuilder addItems(final Collection extends PropertyReader> collection) {
for (PropertyReader element : collection) {
addItem(element);
}
return this;
}
public AjaxXmlBuilder addItem(final PropertyReader element) {
addItem(element.getName(), element.getValue(), element.isCData());
return this;
}
}
ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/helpers/ 0000755 0001750 0001750 00000000000 11262371154 026073 5 ustar twerner twerner ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/helpers/AbstractHTMLElement.java 0000644 0001750 0001750 00000014267 11300773736 032517 0 ustar twerner twerner /*
* Copyright 2009 AjaxTags-Team
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package net.sourceforge.ajaxtags.helpers;
import java.util.Locale;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Map.Entry;
/**
* This class should help to write HTML-Tags we will have a simple append operation and a easy use
* in connection with strings.
*
* @author jenskapitza
*/
public abstract class AbstractHTMLElement implements CharSequence, Appendable {
/**
* A simple enum holding some HMTL-Attributes we are using.
*
* @author Jens Kapitza
*/
public static enum HTMLAttribute {
CLASS, ID;
}
/**
* Name of element. For start and end of tag.
*/
private String name;
/**
* Body.
*/
private CharSequence body;
/**
* Store the attributes of HTML element.
*/
private SortedMap