ajaxtags-1.5.1/0000777000175000017500000000000011305026660013261 5ustar twernertwernerajaxtags-1.5.1/pom.xml0000644000175000017500000002241711305024400014566 0ustar twernertwerner 4.0.0 ajaxtags ajaxtags-doc 1.5.1 AjaxTags DOC pom 2005 ajaxtags ajaxtags-resources ajaxtags-demo http://ajaxtags.sourceforge.net/ SourceForge Tracker http://sourceforge.net/tracker/?group_id=140499 jenskapitza Jens Kapitza jenskapitza [at] users.sourceforge.net Project Manager Developer Michael Osipov http://sourceforge.net/project/memberlist.php?group_id=140499 Developer Darren Spurgeon http://sourceforge.net/project/memberlist.php?group_id=140499 Project Manager Developer sunshine Developer http://sourceforge.net/project/memberlist.php?group_id=140499 jluix Developer http://sourceforge.net/project/memberlist.php?group_id=140499 musachy Developer http://sourceforge.net/project/memberlist.php?group_id=140499 Pablo Developer http://sourceforge.net/project/memberlist.php?group_id=140499 Jose E. Gonzalez Developer http://sourceforge.net/project/memberlist.php?group_id=140499 Charles H Developer http://sourceforge.net/project/memberlist.php?group_id=140499 Serge Knystautas Developer http://sourceforge.net/project/memberlist.php?group_id=140499 Sudheer Developer http://sourceforge.net/project/memberlist.php?group_id=140499 The Apache Software License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 manual 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 team http://ajaxtags.sourceforge.net/ package org.mortbay.jetty maven-jetty-plugin org.apache.maven.plugins maven-jar-plugin org.apache.maven.plugins maven-compiler-plugin 1.5 1.5 on on utf-8 org.apache.maven.plugins maven-surefire-plugin org.apache.maven.plugins maven-site-plugin org.apache.maven.plugins maven-assembly-plugin src/main/assembly/bin.xml src/main/assembly/src.xml ajaxtags-${pom.version} com.google.code.maven-license-plugin maven-license-plugin 1.4.0 false
${basedir}/header.txt
**/**.java **/**.jsp **/**.css **/ajaxtags.js true SLASHSTAR_STYLE DYNASCRIPT_STYLE JAVADOC_STYLE JAVADOC_STYLE 2009
check
javax.servlet servlet-api 2.5 provided junit junit 4.5 test javax.servlet.jsp jsp-api 2.1 provided net.sourceforge.maven-taglib maven-taglib-plugin org.apache.maven.plugins maven-javadoc-plugin UTF-8 true org.apache.maven.plugins maven-pmd-plugin 1.5 UTF-8 org.apache.maven.plugins maven-project-info-reports-plugin org.apache.maven.plugins maven-changes-plugin 2.1 false %URL%/%ISSUE% ${basedir}/src/site/changes.xml org.apache.maven.plugins maven-surefire-report-plugin org.apache.maven.plugins maven-checkstyle-plugin ${basedir}/../checkstyle.xml false org.codehaus.mojo findbugs-maven-plugin 1.2 true
ajaxtags-1.5.1/ajaxtags/0000777000175000017500000000000011305026660015063 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/pom.xml0000644000175000017500000000131211305024442016365 0ustar twernertwerner ajaxtags-doc ajaxtags 1.5.1 4.0.0 ajaxtags ajaxtags jar 1.5.1 AjaxTags commons-lang commons-lang 2.4 ajaxtags-1.5.1/ajaxtags/src/0000755000175000017500000000000011265146022015646 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/test/0000755000175000017500000000000011240372226016625 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/test/java/0000755000175000017500000000000011240372226017546 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/test/java/net/0000755000175000017500000000000011240372226020334 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/0000755000175000017500000000000011240372226022657 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/0000755000175000017500000000000011253742240024462 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/0000755000175000017500000000000011262371154025422 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/AjaxSubmitTagTest.java0000644000175000017500000000612411300773740031633 0ustar twernertwerner/* * 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.java0000644000175000017500000000656311300773736032035 0ustar twernertwerner/* * 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.java0000644000175000017500000000773011252743562032103 0ustar twernertwerner/* * 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.java0000644000175000017500000001126711300773740032062 0ustar twernertwerner/* * 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.java0000644000175000017500000002225611300773736031251 0ustar twernertwerner/* * 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 = "
Text
link to " + "itself" + "
Text
"; final String expected = "
before tag" + "
" + "
Text
link to " + "itself" + "
Text
" + "
" + "after tag
"; 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 = "
Text
link to " + "itself" + "
Text
"; final String expected = "
" + "
Text
link to " + "itself" + "
Text
" + "
"; 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 = "
content
"; assertEquals("simple content", XMLUtils.format(expected), tag.processContent(html)); html = " content "; expected = "
content
"; assertEquals("trimming whitespace", XMLUtils.format(expected), tag.processContent(html)); tag.setId(TAG_ID); tag.setStyleClass(TAG_CLASS); tag.setAjaxAnchors(true); html = "
Text
link to " + "itself" + "
Text
"; expected = "
" + "
Text
link to " + "itself" + "
Text
" + "
"; assertEquals(XMLUtils.format(expected), tag.processContent(html)); } } ajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/tags/AjaxAnchorsTagTest.java0000644000175000017500000001260711300773740031770 0ustar twernertwerner/* * 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 + "
" + "testDoEndTag" + "
"; 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 + "
HTML content
";// + IOUtils.LINE_SEPARATOR; assertEquals("HTML w/o links", XMLUtils.format(expected), tag.ajaxAnchors(html, "target", null)); html = "html link"; expected = HEADER + "
html link" + "
"; assertEquals("HTML with empty link", XMLUtils.format(expected), tag.ajaxAnchors(html, "target", null)); html = "html testAjaxAnchors"; expected = HEADER + "
html testAjaxAnchors" + "
"; 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.java0000644000175000017500000002030111300773740031602 0ustar twernertwerner/* * 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/0000755000175000017500000000000011250754334025266 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/xml/AjaxTreeXmlBuilderTest.java0000644000175000017500000001204511301073050032450 0ustar twernertwerner/* * 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.java0000644000175000017500000000354511300773740031651 0ustar twernertwerner/* * 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.java0000644000175000017500000001222311300773736030344 0ustar twernertwerner/* * 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.java0000644000175000017500000001726411300773740031765 0ustar twernertwerner/* * 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.java0000644000175000017500000001077711300773736030367 0ustar twernertwerner/* * 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/0000755000175000017500000000000011253742424026130 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/test/java/net/sourceforge/ajaxtags/helpers/DIVElementTest.java0000644000175000017500000000422611253742424031573 0ustar twernertwerner/* * 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.java0000644000175000017500000000137511300773740027543 0ustar twernertwerner/* * 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.java0000644000175000017500000000343311252743562032130 0ustar twernertwerner/* * 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.java0000644000175000017500000001074211300773736032132 0ustar twernertwerner/* * 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/0000755000175000017500000000000011265436614016623 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/site/site.xml0000644000175000017500000000025511276326504020311 0ustar twernertwerner ajaxtags-1.5.1/ajaxtags/src/main/0000755000175000017500000000000011240372226016572 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/main/java/0000755000175000017500000000000011240372226017513 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/main/java/net/0000755000175000017500000000000011240372226020301 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/0000755000175000017500000000000011240372226022624 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/0000755000175000017500000000000011240372226024426 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/0000755000175000017500000000000011262371154025367 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/tags/AjaxSubmitTag.java0000644000175000017500000000267311300773740030745 0ustar twernertwerner/* * 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.java0000644000175000017500000001144211300777764031103 0ustar twernertwerner/* * 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.java0000644000175000017500000000521511300773740032136 0ustar twernertwerner/* * 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.java0000644000175000017500000000204611252743562030353 0ustar twernertwerner/* * 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.java0000644000175000017500000001123511300773736031106 0ustar twernertwerner/* * 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.java0000644000175000017500000000562111300773740031101 0ustar twernertwerner/* * 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.java0000644000175000017500000000225311300773736031740 0ustar twernertwerner/* * 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.java0000644000175000017500000000531111300773740031160 0ustar twernertwerner/* * 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.java0000644000175000017500000001146611300773740030730 0ustar twernertwerner/* * 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.java0000644000175000017500000002516611301001504031153 0ustar twernertwerner/* * 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.java0000644000175000017500000001051611300773740031126 0ustar twernertwerner/* * 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.java0000644000175000017500000000541011300773736030376 0ustar twernertwerner/* * 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.java0000644000175000017500000000532611300773740030717 0ustar twernertwerner/* * 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.java0000644000175000017500000000717411301002212030327 0ustar twernertwerner/* * 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.java0000644000175000017500000001242111300773740031174 0ustar twernertwerner/* * 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.java0000644000175000017500000000402011300773736031342 0ustar twernertwerner/* * 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.java0000644000175000017500000001510611300773736030723 0ustar twernertwerner/* * 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.java0000644000175000017500000000430211300773740030774 0ustar twernertwerner/* * 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/0000755000175000017500000000000011250754334025233 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/xml/AjaxValueListXmlBuilder.java0000644000175000017500000000577111300773740032612 0ustar twernertwerner/* * 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.java0000644000175000017500000001753311301073340031566 0ustar twernertwerner/* * 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 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("'); } xml.append(""); } xml.append(RESPONSE_END); return xml.toString(); } } ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/xml/BaseXmlBuilder.java0000644000175000017500000000677611300773740030756 0ustar twernertwerner/* * 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.java0000644000175000017500000000501511300773736030755 0ustar twernertwerner/* * 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 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/0000755000175000017500000000000011262371154026073 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/helpers/AbstractHTMLElement.java0000644000175000017500000001426711300773736032517 0ustar twernertwerner/* * 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 attributes; /** * Create a HTML element. * * @param name * name of start and endtag * @param id * id of element * @param body * content */ protected AbstractHTMLElement(final String name, final String id, final String body) { this.name = name; this.body = body; // if value is null then exception is thrown attributes = new TreeMap(); if (id != null) { setId(id); } } /** * Create a HTML element. * * @param name * the tag name */ protected AbstractHTMLElement(final String name) { this(name, null); } /** * Create a HTML element. * * @param name * the tag name * @param id * the id attribute */ protected AbstractHTMLElement(final String name, final String id) { this(name, id, null); } /** * @return the map of attributes */ protected final SortedMap getAttributes() { return attributes; } /** * @return the tag name */ protected final String getName() { return name; } /** * @return the body content or empty string if body is null */ public final String getBody() { return body == null ? "" : body.toString(); } /** * Set the body content. * * @param body * the body content */ public final void setBody(final CharSequence body) { this.body = body; } /** * @return the class name attribute */ public final String getClassName() { return attributes.get(HTMLAttribute.CLASS); } /** * Set the class name attribute. * * @param className * the class attribute value */ public final void setClassName(final String className) { attributes.put(HTMLAttribute.CLASS, className); } /** * @return the id attribute */ public final String getId() { return attributes.get(HTMLAttribute.ID); } /** * Set the id attribute. * * @param id * the id attribute value */ public final void setId(final String id) { attributes.put(HTMLAttribute.ID, id); } /** * @return the length */ public final int length() { return toString().length(); } /** * @see CharSequence#charAt(int) * @param index * the index * @return the char at index */ public final char charAt(final int index) { return toString().charAt(index); } /** * @see CharSequence#subSequence(int, int) * @param start * the start index * @param end * the end index * @return the substring from start to end */ public final CharSequence subSequence(final int start, final int end) { return toString().subSequence(start, end); } /** * cleaning the Attributes. This method do nothing per default. */ protected void cleanAttributes() { } /** * @return the string representation of this HTML element */ @Override public final String toString() { final StringBuilder s = new StringBuilder("<"); s.append(getName()); cleanAttributes(); for (Entry e : getAttributes().entrySet()) { // if we do have a ENUM Object we try to get it in a lower case // type. toString should ensure the value is valid as key in HTML s.append(" ").append(e.getKey().toString().toLowerCase(Locale.getDefault())).append( "=\""); s.append(e.getValue().replaceAll("\"", "\\\"")).append("\""); } s.append(">"); s.append(getBody()); s.append(""); return s.toString(); } /** * Append {@link CharSequence} to this object. * * @param string * the data to append * @return self */ public final AbstractHTMLElement append(final CharSequence string) { setBody(getBody() + string); return this; } /** * Append a char. * * @param c * the char to append * @return self */ public final AbstractHTMLElement append(final char c) { return append(String.valueOf(c)); } /** * @param csq * the char sequence * @param start * the start index * @param end * the end index * @return self */ public final AbstractHTMLElement append(final CharSequence csq, final int start, final int end) { return append(csq.subSequence(start, end)); } } ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/helpers/JavaScript.java0000644000175000017500000000246011300773736031013 0ustar twernertwerner/* * 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; /** * HTML JavaScript element. This will help building javascript. * * @author Jens Kapitza */ public final class JavaScript extends AbstractHTMLElement { /** * Create a script element. */ public JavaScript() { super("script"); } /** * Constructor. * * @param script * initial script content */ public JavaScript(final String script) { this(); append(script); } /** * Just allow type attribute. All others are dropped. */ @Override protected void cleanAttributes() { getAttributes().clear(); getAttributes().put("type", "text/javascript"); } } ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/helpers/AbstractItem.java0000644000175000017500000001242511300773736031331 0ustar twernertwerner/* * 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.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; import java.util.Map.Entry; /** * A generic item class, basically representing a name-value pair. * * @author Darren L. Spurgeon * @author Jens Kapitza */ public abstract class AbstractItem { /** * The name. */ private String name; /** * The value. */ private Object value; /** * CDATA is used to flag the value and force the writer to nest the value in an CDATA TAG. */ private boolean asCData; /** * All other attributes. Using a TreeMap cause of JUnit tests. */ private final SortedMap attributes = new TreeMap(); /** * Constructor for Item. * * @param name * the name for the item * @param value * the value * @param asCData * response as CDATA */ protected AbstractItem(final String name, final Object value, final boolean asCData) { this(); setName(name); setValue(value); setAsCData(asCData); } /** * Constructor for Item. */ protected AbstractItem() { super(); } /** * Set all attributes. * * @param attributes * the attributes to set * @param evenIfNull * set the attribute even if value is null */ public final void setAllAttributes(final Map attributes, final boolean evenIfNull) { if (attributes != null) { for (Entry e : attributes.entrySet()) { setAttributes(e.getKey(), e.getValue(), evenIfNull); } } } /** * Set all attributes. * * @param attributes * the attributes to set */ public final void setAllAttributes(final Map attributes) { setAllAttributes(attributes, false); } /** * List all attribute-names. * * @return the key set of the attributes */ public Set getAttributeKeySet() { return attributes.keySet(); } /** * Removes an attribute. * * @param name * the name of attribute */ public final void removeAttribute(final String name) { attributes.remove(name); } /** * Clear the attributes. */ public final void clearAttribute() { attributes.clear(); } /** * Set an attribute to extend the item. This just invoke * {@link #setAttributes(String, String, boolean)} with false as third parameter. * * @param name * the name for the attribute * @param value * the value for the attribute * @see #setAttributes(String, String, boolean) */ public final void setAttributes(final Object name, final String value) { setAttributes(name, value, false); } /** * Set an attribute to extend the item. * * @param name * the name for the attribute * @param value * the value for the attribute * @param evenIfNull * set attribute even if it is null */ public final void setAttributes(final Object name, final String value, final boolean evenIfNull) { if (value != null || evenIfNull) { // don't change the name here, we should do this // in the Map implementation or never! attributes.put(name, value); } } /** * Read the attribute value. * * @param name * the attribute name * @return the value of attribute name */ public String getAttributeValue(final Object name) { return attributes.get(name); } /** * @return Returns the name. */ public String getName() { return this.name; } /** * Set the Name. * * @param name * The name to set. */ public final void setName(final String name) { this.name = name; } /** * The type depends on the child-class. * * @return Returns the value. */ public Object getValue() { return this.value; } /** * @param value * The value to set. */ public final void setValue(final Object value) { this.value = value; } /** * @return Returns the asCData. */ public boolean isAsCData() { return this.asCData; } /** * @param asCData * The asCData to set. */ public final void setAsCData(final boolean asCData) { this.asCData = asCData; } } ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/helpers/XMLUtils.java0000644000175000017500000001712111304776014030422 0ustar twernertwerner/* * 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.io.IOException; import java.io.StringReader; import java.io.StringWriter; import javax.xml.namespace.QName; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** * Some helper functions for XML. * * @author jenskapitza */ public final class XMLUtils { private static final String TRANSFORMER_YES = "yes"; /*--------------------------------- SOME THREAD HELPER IMPLEMENTATIONS ------------------------------------------*/ private static final ThreadLocal transformerFactory = new ThreadLocal() { @Override protected TransformerFactory initialValue() { return TransformerFactory.newInstance(); } }; private static final ThreadLocal docFactory = new ThreadLocal() { @Override protected DocumentBuilderFactory initialValue() { final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); dbf.setIgnoringElementContentWhitespace(true); return dbf; }; }; private static final ThreadLocal xPathFactory = new ThreadLocal() { @Override protected XPathFactory initialValue() { return XPathFactory.newInstance(); } }; /*--------------------------------- END THREAD HELPER IMPLEMENTATIONS ------------------------------------------*/ /** * Never instance this class. */ private XMLUtils() { } /** * Evaluate XPath expression and return list of nodes. * * @param expression * XPath expression * @param node * DOM node * @return list of DOM nodes * @throws XPathExpressionException * if expression cannot be evaluated */ public static NodeList evaluateXPathExpression(final String expression, final Node node) throws XPathExpressionException { return (NodeList) evaluateXPathExpression(expression, node, XPathConstants.NODESET); } /** * Evaluate XPath expression. * * @param expression * XPath expression * @param node * DOM node * @param returnValue * the desired return type * @return result of evaluating an XPath expression as an Object of returnType * @throws XPathExpressionException * if expression cannot be evaluated */ public static Object evaluateXPathExpression(final String expression, final Node node, final QName returnValue) throws XPathExpressionException { return getNewXPath().evaluate(expression, node, returnValue == null ? XPathConstants.NODE : returnValue); } /** * create and return a new {@link XPath} object from {@link ThreadLocal} * @return a new {@link XPath} object. */ public static XPath getNewXPath(){ return xPathFactory.get().newXPath(); } /** * @return DocumentBuilder * @throws ParserConfigurationException * if a DocumentBuilder cannot be created which satisfies the configuration * requested */ private static DocumentBuilder getNewDocumentBuilder() throws ParserConfigurationException { return docFactory.get().newDocumentBuilder(); } /** * Parse string with XML content to {@link org.w3c.dom.Document}. * * @param xml * string with XML content * @return Document * @throws SAXException * if any parse errors occur */ public static Document getXMLDocument(final String xml) throws SAXException { try { return getNewDocumentBuilder().parse(new InputSource(new StringReader(xml))); } catch (IOException e) { throw new SAXException(e); } catch (ParserConfigurationException e) { throw new SAXException(e); } } /** * Create a new {@link org.w3c.dom.Document}. * * @return an empty document * @throws ParserConfigurationException * if a DocumentBuilder cannot be created */ public static Document createDocument() throws ParserConfigurationException { return getNewDocumentBuilder().newDocument(); } /** * Parse string as XML document and return string with reformatted document. * * @param xml * string with XML content * @return reformatted content * @throws TransformerException * if it is not possible to transform document to string * @throws SAXException * if any parse errors occur */ public static String format(final String xml) throws TransformerException, SAXException { return toString(getXMLDocument(xml)); } /** * Transform document to string representation. * * @param document * XHTML document * @return string representation of document * @throws TransformerException * if it is not possible to create a Transformer instance or to transform document */ public static String toString(final Document document) throws TransformerException { final StringWriter stringWriter = new StringWriter(); final StreamResult streamResult = new StreamResult(stringWriter); final Transformer transformer = transformerFactory.get().newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, TRANSFORMER_YES); // set ident for XML transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2"); // not all JavaSE have the same implementation transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); // transformer.setOutputProperty(OutputKeys.METHOD, "html"); // html method transforms
into
, which cannot be re-parsed // transformer.setOutputProperty(OutputKeys.METHOD, "xhtml"); // xhtml method does not work for my xalan transformer transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, TRANSFORMER_YES); transformer.transform(new DOMSource(document.getDocumentElement()), streamResult); return stringWriter.toString(); } } ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/helpers/DIVElement.java0000644000175000017500000000222411300773736030677 0ustar twernertwerner/* * 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; /** * HTML <div> element. Try to avoid building HTML code in TAGs or Servlets. With String * concat. * * @author Jens Kapitza */ public final class DIVElement extends AbstractHTMLElement { /** * Create a HTML <div> element. * * @param id * the id for the div element */ public DIVElement(final String id) { super("div", id, null); } /** * Create a HTML <div> element with no ID */ public DIVElement() { this(null); } } ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/helpers/ValueItem.java0000644000175000017500000000647211300773736030647 0ustar twernertwerner/* * 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.ArrayList; import java.util.Arrays; import java.util.List; /** * Holding the data for ValueListXmlBuilder. * * @author Jens Kapitza */ public class ValueItem extends AbstractItem { private static final long serialVersionUID = -5641651833544439174L; /** * Build a SimpleNode. * * @param tagName * name * @param asCData * true if is cdate or false otherwise */ public ValueItem(final String tagName, final boolean asCData) { this(tagName, null, asCData); } /** * Build a SimpleNode. * * @param tagName * name * @param value * add one value * @param asCData * true if is CDATA or false otherwise */ public ValueItem(final String tagName, final String value, final boolean asCData) { this(tagName, asCData, value); } /** * Build a SimpleNode. * * @param tagName * name * @param asCData * true if is CDATA or false otherwise * @param value * a list of values */ public ValueItem(final String tagName, final boolean asCData, String... value) { super(tagName, new ArrayList(), asCData); getValue().addAll(Arrays.asList(value)); } /** * Try to find the index of value. * * @param value * the value to find * @return the index of this value * @see ArrayList#indexOf(Object) */ public int indexOfValue(final String value) { return getValue().indexOf(value); } /** * Add values to this valueitem. * * @param values * the value */ public void addValue(String... values) { getValue().addAll(Arrays.asList(values)); } /** * Add values to this valueitem. * * @param values * the value */ public void addValue(final List values) { getValue().addAll(values); } /** * Add a value to this valueitem. * * @param value * the value */ public void addValue(final String value) { getValue().add(String.valueOf(value)); } /** * Removes an item at specified index. * * @param index * the index to remove * @return the removed item */ public String remove(final int index) { return getValue().remove(index); } /** * The list of values. * * @return the list of values */ @SuppressWarnings("unchecked") @Override public List getValue() { return (List) super.getValue(); } } ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/helpers/TreeItem.java0000644000175000017500000001020511300773740030452 0ustar twernertwerner/* * 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.Map; /** * Extend Item to easily have a tree item with more options. * * @author Musachy Barroso * @author Jens Kapitza */ public class TreeItem extends AbstractItem { /** * All known tree-elements for the parser.
* This is just a subset of what we can do. * * @author Jens Kapitza */ public static enum TreeAttribute { /** * Key to set node or a leaf flag. */ LEAF, /** * Key to set collapsed flag. */ COLLAPSED, /** * Key to set URL flag. */ URL; } /** * Constructor for TreeItem. */ public TreeItem() { this(null, null, false, null); } /** * Create an item. * * @param name * name * @param value * value * @param asData * true if value must be set as CDATA */ public TreeItem(final String name, final String value, final boolean asData) { this(name, value, false, null, asData); } /** * Create an item. * * @param name * name * @param value * value */ public TreeItem(final String name, final String value) { this(name, value, false, null, false); } /** * Create an item. * * @param name * name * @param value * value * @param collapsed * true if item is collapsed * @param url * URL * @param asData * true if value must be set as CDATA */ public TreeItem(final String name, final String value, final boolean collapsed, final String url, final boolean asData) { this(name, value, asData, null); setCollapsed(collapsed); setUrl(url); } /** * Create an item. * * @param name * name * @param value * value * @param asData * true if value must be set as CDATA * @param attributes * additional attributes */ public TreeItem(final String name, final String value, final boolean asData, final Map attributes) { super(name, value, asData); setAllAttributes(attributes); } /** * Check if this item is a leaf or not. * * @return true if this is a leaf else false */ public final boolean isLeaf() { return Boolean.parseBoolean(getAttributeValue(TreeAttribute.LEAF)); } /** * Set node to leaf or not. * * @param leaf * true if it is leaf else false */ public final void setLeaf(final boolean leaf) { setAttributes(TreeAttribute.LEAF, String.valueOf(leaf)); } /** * @return Returns the collapsed value */ public final boolean isCollapsed() { return Boolean.parseBoolean(getAttributeValue(TreeAttribute.COLLAPSED)); } /** * @param collapsed * The collapsed value to be set */ public final void setCollapsed(final boolean collapsed) { setAttributes(TreeAttribute.COLLAPSED, String.valueOf(collapsed)); } /** * @return Return the URL */ public final String getUrl() { return getAttributeValue(TreeAttribute.URL); } /** * @param url * The URL to be set */ public final void setUrl(final String url) { setAttributes(TreeAttribute.URL, url); } } ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/servlets/0000755000175000017500000000000011252733056026302 5ustar twernertwernerajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/servlets/BaseAjaxXmlAction.java0000644000175000017500000000333411300777014032441 0ustar twernertwerner/* * 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.servlets; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Simple Action which can be invoked by AjaxActionHelper. * * @author Jens Kapitza */ public interface BaseAjaxXmlAction { /** * Each child class should override this method to generate the specific XML content necessary * for each AJAX action. * * @param request * the HttpServletRequest object * @param response * the HttpServletResponse object * @return a String representation of the XML response/content * @throws ServletException * any errors * @throws IOException * any IO error */ String getXmlContent(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException; /** * Each child class should override this method to set the specific XML encoding. * * @return the XML encoding for the AJAX action */ String getXMLEncoding(); } ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/servlets/BaseAjaxServlet.java0000644000175000017500000000460211300777076032176 0ustar twernertwerner/* * 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.servlets; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.GenericServlet; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * An abstract class from which each servlet extends. This class wraps the XML creation (delegated * to the child servlet class) and submission back through the HTTP response. * * @author Jens Kapitza */ public abstract class BaseAjaxServlet extends GenericServlet implements BaseAjaxXmlAction { private static final long serialVersionUID = -1772422788542156185L; /** * Get information about servlet. * * @return information about servlet */ @Override public String getServletInfo() { return "Ajax Servlet (AjaxTags)"; } /** * Invoke the {@link #getXmlContent(HttpServletRequest, HttpServletResponse)} method. * * @param request * the {@link ServletRequest} * @param response * the {@link ServletResponse} * @throws ServletException * any errors * @throws IOException * any IO error */ @Override public final void service(final ServletRequest request, final ServletResponse response) throws ServletException, IOException { final String xml = AjaxActionHelper.invoke(this, (HttpServletRequest) request, (HttpServletResponse) response); final PrintWriter pw = response.getWriter(); pw.write(xml); pw.flush(); // send all } /** * @return the encoding default to UTF-8 */ public String getXMLEncoding() { return "UTF-8"; } } ajaxtags-1.5.1/ajaxtags/src/main/java/net/sourceforge/ajaxtags/servlets/AjaxActionHelper.java0000644000175000017500000001011711300776724032331 0ustar twernertwerner/* * 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.servlets; import java.io.IOException; import java.io.UnsupportedEncodingException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.NotImplementedException; /** * This is a helper class to avoid caching problems and duplicated code. Later we will write a * action class to make the use in strutts much easier. * * @author Jens Kapitza */ public final class AjaxActionHelper { /** * Some HMTL-Header wich can be easily enabled * * @author Jens Kapitza * */ public static enum HMTLAjaxHeader { /** * Set HTTP/1.1 no-cache headers. */ CACHE_CONTROL("Cache-Control", "no-store, max-age=0, no-cache, must-revalidate, post-check=0, pre-check=0"), /** * Set standard HTTP/1.0 no-cache header. */ PRAGMA("Pragma", "no-cache"); /** * Store the header name. */ private String headerName; /** * Store the header value. */ private String headerValue; /** * Create the Headerpair. This is a easy usage holding static header information. * * @param name * the header name. * @param value * the header value. */ private HMTLAjaxHeader(final String name, final String value) { this.headerName = name; this.headerValue = value; } /** * enable the header in the {@link HttpServletResponse} * * @param response * the {@link HttpServletResponse} where we should write the header to. */ public void enable(HttpServletResponse response) { response.setHeader(headerName, headerValue); } /** * disable the header. This is not yet implemented. * * @param response * the {@link HttpServletResponse} */ public void disable(HttpServletResponse response) { throw new NotImplementedException("This is not implemented yet."); } } /** * do not create an object */ private AjaxActionHelper() { } /** * Invoke the AJAX action and setup the request and response. * * @param action * the BaseAjaxXmlAction implementation * @param request * the request * @param response * the response * @return the XML content from action * @throws ServletException * for any errors */ public static String invoke(final BaseAjaxXmlAction action, final HttpServletRequest request, final HttpServletResponse response) throws ServletException { // prepare CALL try { request.setCharacterEncoding(action.getXMLEncoding()); } // we will use UTF-8 catch (UnsupportedEncodingException e) { throw new ServletException(e); } // Set content to XML response.setContentType("text/xml; charset=" + action.getXMLEncoding()); // enable the ajaxheaders for (HMTLAjaxHeader header : HMTLAjaxHeader.values()) { header.enable(response); } try { return action.getXmlContent(request, response); } catch (IOException e) { throw new ServletException(e); } } } ajaxtags-1.5.1/ajaxtags/src/main/resources/0000755000175000017500000000000011240372226020604 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-resources/0000777000175000017500000000000011305026660017073 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-resources/pom.xml0000644000175000017500000000303211305024456020403 0ustar twernertwerner ajaxtags-doc ajaxtags 1.5.1 4.0.0 ajaxtags ajaxtags-resources jar 1.5.1 AjaxTags Resources Here are the javascript files, the images and the CSS files. You can provide this resources with simple the SourceLoader Servlet or on your own way org.apache.maven.plugins maven-assembly-plugin src/main/assembly/bin.xml ajaxtags-resources-${pom.version} ajaxtags ajaxtags ${version} ajaxtags-1.5.1/ajaxtags-resources/src/0000755000175000017500000000000011240372226017656 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-resources/src/main/0000755000175000017500000000000011240372226020602 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-resources/src/main/java/0000755000175000017500000000000011240372226021523 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-resources/src/main/java/net/0000755000175000017500000000000011240372226022311 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-resources/src/main/java/net/sourceforge/0000755000175000017500000000000011240372226024634 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-resources/src/main/java/net/sourceforge/ajaxtags/0000755000175000017500000000000011240372226026436 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-resources/src/main/java/net/sourceforge/ajaxtags/servlets/0000755000175000017500000000000011250754334030312 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-resources/src/main/java/net/sourceforge/ajaxtags/servlets/SourceLoader.java0000644000175000017500000000740211252757630033553 0ustar twernertwerner/* * 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.servlets; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.servlet.GenericServlet; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import static org.apache.commons.lang.StringUtils.trimToNull; /** * this class loads the frameworks, javascript files and css files from the jar file changes to the * javascript or css files can only be done by repacking the ajaxtags.jar * * @author Jens Kapitza * @since 1.5 */ public final class SourceLoader extends GenericServlet { private static final long serialVersionUID = 4621190060172885624L; private String prefix = null; private static final int BUFFER = 1024; /** * this is the base where we can find the source wich sould be loaded */ public static final String BASE = "/net/sourceforge/ajaxtags"; /** * write the content from the jarfile to the client stream use bufferedwriter to handel newline * the filename is found in the requestURI the contextpath is excluded and replaced with the * base package name * * @param req * the request * @param resp * the response * @throws ServletException * any errors * @throws IOException * any io errors */ public void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final String res = req.getRequestURI(); final OutputStream stream = resp.getOutputStream(); final byte[] buffer = new byte[BUFFER]; String loadPath = res.substring(req.getContextPath().length()); if (prefix != null && loadPath.startsWith(prefix)) { loadPath = loadPath.substring(prefix.length()); } InputStream in = null; try { in = getClass().getResourceAsStream(SourceLoader.BASE + loadPath); if (in == null) { throw new IOException("resource not found"); } int read = -1; while ((read = in.read(buffer)) != -1) { stream.write(buffer, 0, read); } } finally { if (in != null) { in.close(); } stream.flush(); stream.close(); } } /** * warp to http request and response * * @param req0 * the request * @param resp0 * the response * @throws ServletException * any errors * @throws IOException * any io errors */ @Override public void service(final ServletRequest req0, final ServletResponse resp0) throws ServletException, IOException { service((HttpServletRequest) req0, (HttpServletResponse) resp0); } /** * check the configuration if we do have a prefix. * */ @Override public void init() throws ServletException { prefix = trimToNull(getInitParameter("prefix")); } } ajaxtags-1.5.1/ajaxtags-resources/src/main/assembly/0000755000175000017500000000000011240372226022421 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-resources/src/main/assembly/bin.xml0000644000175000017500000000045111240372226023713 0ustar twernertwerner all zip src/main/resources/net/sourceforge/ajaxtags ** ajaxtags-1.5.1/ajaxtags-resources/src/main/resources/0000755000175000017500000000000011240372226022614 5ustar twernertwernerajaxtags-1.5.1/checkstyle.xml0000644000175000017500000001227711250754334016153 0ustar twernertwerner ajaxtags-1.5.1/src/0000755000175000017500000000000011240372226014044 5ustar twernertwernerajaxtags-1.5.1/src/site/0000755000175000017500000000000011265440216015012 5ustar twernertwernerajaxtags-1.5.1/src/site/site.xml0000644000175000017500000000442011276326634016511 0ustar twernertwerner ajaxtags-1.5.1/src/site/fml/0000755000175000017500000000000011240372226015566 5ustar twernertwernerajaxtags-1.5.1/src/site/fml/faq.fml0000644000175000017500000001366511240372226017050 0ustar twernertwerner Why is the ajax:autocomplete dropdown not positioned correctly?

At present the ajax:autocomplete tag writes a DIV HTML element to the page to act as a placeholder for the dropdown or suggest list. Normally, you are free to put the ajax:autocomplete tag anywhere on the page (between the BODY tags).

However, if your page contains complex CSS positioning which surrounds the location of the ajax:autocomplete tag, you may get unexpected results. That is, the dropdown won't appear directly beneath the input field.

Solution: place the ajax:autocomplete tag outside any elements using CSS positioning, or simply the last element before the closing BODY tag. A future release of the tag library may resolve this issue.

Report courtesy of Keith Sherwood (Bright House Networks)

The ajax:callout tag requires a class definition. How do define a class for an element that already has a class assigned?

CSS allows you to assign multiple style classes to a single element. For example:

Link to nowhere]]>
Can I include special characters in the AJAX XML response?

In short, yes you can. However, you must remember to properly encode the response sent back to the Ajax client. We recommend you set the XML encoding to UTF-8 or UTF-16 because to our knowledge, they are the only two encodings mandated by the XML spec. Also, it is wise to set the page encoding and character set on the response to match that set in the XML file.

For more information, see the following:

Are there any plans to add a validation tag?

No. There are currently no plans to support AJAX-based form validation. As with all open source, if anyone wants to contribute a solution, we're open to that possibility.

Why does the ajax:autocomplete tag submit the form when I press Enter to select a value from the list?

This is a known issue with the tag's JavaScript. The way in which the ajax:autocomplete tag binds itself to key events is a bit problematic. When you use the mouse to make a selection from the suggestion list, everything works properly. However, if you use the Enter key to make your selection, the enclosing HTML form will submit itself if a submit button is present. We know it's odd, but we just haven't been able to lick this problem.

Fortunately, we have a solution. Instead of using submit button, simply replace it with a button field and use the onclick event to submit the form.

For example:

]]>
Why aren't my tags working with Struts forms?

Don't forget to set the styleId attribute.

]]>
Can I save having to write the XML on the server side?

There is a helper class to assist in building the XML if you don't want to do it by hand...see the Advanced Usage section for more information.

Why is Struts Validator breaking with AjaxTags/Prototype?

There appears to be a conflict between Struts' client-side validator and the Prototype framework. Essentially, Prototype extends the JavaScript Object class, which in turn breaks the way Struts Validator handles it's arrays. There is a workaround, but it has not been verified by the AjaxTags team. According to one user, you should add the following to every JavaScript validator:

For a complete discussion of the problem, visit the following forum post.

How can I prevent the response from being cached on IE?

Several people have reported that their responses are being cached under IE, but not Firefox. To explicitly tell IE not to cache responses, you need to set a response header as follows in your servlet or JSP:

ajaxtags-1.5.1/src/site/apt/0000755000175000017500000000000011262371406015577 5ustar twernertwernerajaxtags-1.5.1/src/site/apt/usage.apt0000644000175000017500000012721011265145752017422 0ustar twernertwernerUsage ~~~~~ * Base URL ~~~~~~~~~~~ The <<>> property is used by the tag to make a request to the server side. The responding resource (e.g., servlet, JSP, etc.) is responsible for returning the response in the appropriate format (plain text, HTML, XML, etc.). This take is used as a normal URL you are able to append parameters. ** Parameters ~~~~~~~~~~~~~ Each tag has a common <<>> property, composed of name-value pairs that eventually get passed to the URL specified in the <<>> property. You may specify multiple name-value pairs by separating them with commas. Within each pair, you can also indicate that you want a certain form field value to be inserted at the time the request is made by surrounding the value with curly brackets. Let's look at an example. Assume we want to pass two parameters on the URL, one indicating the make of our automobile and another that is a plain text constant. The value of the make parameter will be inserted at request time. In this case, we assume the makeId form field contains a value of "Honda". +------------------------------------------------------------------------+ parameters="make={makeId},q=someConstantValue" +------------------------------------------------------------------------+ ...will be replaced at request time with... +------------------------------------------------------------------------+ parameters="make=Honda,q=someConstantValue" +------------------------------------------------------------------------+ *** Implicit Parameters ~~~~~~~~~~~~~~~~~~~~~~~ The ajax:htmlContent and ajax:callout tags will accept an implicit parameter in place of the value of the source element. For instance, if you want to include the value of the source element on the querystring when making the AJAX call, simply define the parameters attribute as follows: +------------------------------------------------------------------------+ parameters="someId={ajaxParameter}" +------------------------------------------------------------------------+ ** Pre- / Post- and Error Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you will invoke a JavaScript function before the request is started for example to modify the <> you can use the <>. If you've wondered how to either chain AJAX tags together by having one execute after another has completed then you'll like this. The <<>> attribute allows you do just that. This attribute expects a JavaScript function name to be passed. The AJAX JavaScript will execute the function you define after it has finished its work. In addition to post-functions, you may also define functions to be executed when the AJAX request could not be completed (e.g., invalid URL, server exception). You simply enter the name of the user-defined JavaScript function into the optional <<>> tag attribute. * ajax:anchors ~~~~~~~~~~~~~~ The anchors tag will convert any HTML anchor tags (\) within it's area to be AJAX-enabled. Essentially the href is removed and its contents placed within an onclick event for the anchor, thus forcing the resource to be accessed through AJAX instead. The response will then be loaded in any area on the page you define. +------------------------------------------------------------------------+ Refresh first area
+------------------------------------------------------------------------+ *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* target | The target region on the page where the AJAX response will be written, often a DIV tag | yes *---------------------+------------------------------------------------------------+-------------* * ajax:area ~~~~~~~~~~~ The area tag lets you wrap a piece of the webpage and force all links and resources to be loaded inside of it instead of refreshing the entire page. If you use ajaxAnchors your content have to be xhtml conform. +------------------------------------------------------------------------+ This is the first area and should be refreshed only when the first link or the link inside itself is clicked: It may include a link to itself +------------------------------------------------------------------------+ *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* id | Name of ID used for enclosing DIV tag written by tag | yes *---------------------+------------------------------------------------------------+-------------* styleClass | CSS class name to use | no *---------------------+------------------------------------------------------------+-------------* ajaxAnchors | Whether to rewrite HTML anchor tags with an onclick event | no *---------------------+------------------------------------------------------------+-------------* * ajax:autocomplete ~~~~~~~~~~~~~~~~~~~ The autocomplete tag allows one to retrieve a list of probable values from a backend servlet (or other server-side control) and display them in a dropdown beneath an HTML text input field. The user may then use the cursor and ENTER keys or the mouse to make a selection from that list of labels, which is then populated into the text field. This JSP tag also allows for a second field to be populated with the value or ID of the item in the dropdown. +------------------------------------------------------------------------+
Make: Model:
+------------------------------------------------------------------------+ <> *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* var | Name of the JavaScript object created | no *---------------------+------------------------------------------------------------+-------------* attachTo | Name of the JavaScript object to which autocompleter will attach. You must define 'var' for this to work. | no *---------------------+------------------------------------------------------------+-------------* baseUrl | URL of server-side action or servlet that processes search and returns list of values used in autocomplete dropdown; expression language (EL) is supported for this field | yes *---------------------+------------------------------------------------------------+-------------* source | Text field where label of autocomplete selection will be populated; also the field in which the user types out the search string | yes *---------------------+------------------------------------------------------------+-------------* target | Text field where value of autocomplete selection will be populated; you may set this to the same value as the source field | yes *---------------------+------------------------------------------------------------+-------------* parameters | A comma-separated list of parameters to pass to the server-side action or servlet | yes *---------------------+------------------------------------------------------------+-------------* className | CSS class name to apply to the popup autocomplete dropdown | yes *---------------------+------------------------------------------------------------+-------------* indicator | ID of indicator region that will show during Ajax request call | no *---------------------+------------------------------------------------------------+-------------* minimumCharacters | Minimum number of characters needed before autocomplete is executed | no *---------------------+------------------------------------------------------------+-------------* appendSeparator | The separator to use for the target field when values are appended [default=space]. If appendValue is not set or is set to "false", this parameter has no effect. | no *---------------------+------------------------------------------------------------+-------------* preFunction | Function to execute before Ajax is begun | no *---------------------+------------------------------------------------------------+-------------* postFunction | Function to execute after Ajax is finished, allowing for a chain of additional functions to execute | no *---------------------+------------------------------------------------------------+-------------* errorFunction | Function to execute if there is a server exception (non-200 HTTP response) | no *---------------------+------------------------------------------------------------+-------------* parser | The response parser to implement [default=ResponseHtmlParser] | no *---------------------+------------------------------------------------------------+-------------* * ajax:callout ~~~~~~~~~~~~~~ The callout tag is an easy way to attach a callout or popup balloon to any HTML element supporting an onclick event. The style of this callout is fairly flexible, but generally has a header/title, a close link ('X'), and the content itself, of course. All of this (since AjaxTags 1.2) is handled by the OverLIBMWS JavaScript library. See {{http://www.macridesweb.com/oltest/}} for complete instructions on using OverLIBMWS. +------------------------------------------------------------------------+

The Hitchhiker's Guide to the Galaxy is a science fiction series written by Douglas Adams (1952 - 2001). The series follows the adventures of Arthur Dent, a hapless Englishman who escapes the destruction of Earth by an alien race called the Vogons with his friend Ford Prefect, an alien from a small planet somewhere in the vicinity of Betelgeuse and researcher for the eponymous guide.

+------------------------------------------------------------------------+ <> *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* var | Name of the JavaScript object created | no *---------------------+------------------------------------------------------------+-------------* attachTo | Name of the JavaScript object to which callout will attach. You must define 'var' for this to work. | no *---------------------+------------------------------------------------------------+-------------* baseUrl | URL of server-side action or servlet that processes a simple command | yes *---------------------+------------------------------------------------------------+-------------* source | ID of the element to which the callout will be attached | either source or sourceClass must be defined *---------------------+------------------------------------------------------------+-------------* sourceClass | CSS class name of the elements to which the callout will be attached | either source or sourceClass must be defined *---------------------+------------------------------------------------------------+-------------* parameters | A comma-separated list of parameters to pass to the server-side action or servlet | yes *---------------------+------------------------------------------------------------+-------------* title | Title for callout's box header. If <<>> and no title is specified, then the <<>> attribute of the returned XML will be used as the title. | no *---------------------+------------------------------------------------------------+-------------* overlib | Options for OverLib | no *---------------------+------------------------------------------------------------+-------------* preFunction | Function to execute before Ajax is begun | no *---------------------+------------------------------------------------------------+-------------* postFunction | Function to execute after Ajax is finished, allowing for a chain of additional functions to execute | no *---------------------+------------------------------------------------------------+-------------* errorFunction | Function to execute if there is a server exception (non-200 HTTP response) | no *---------------------+------------------------------------------------------------+-------------* * ajax:displayTag ~~~~~~~~~~~~~~~~~ The displayTag is similar to the area tag, but it specifically tailored to the Display Tag. It wraps DisplayTag ajaxing pagination and sorting. If you use this tag your content have to be xhtml conform. +------------------------------------------------------------------------+ ${row.make} Web Page www.${row.make}.com +------------------------------------------------------------------------+ *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* id | Name of ID used for enclosing DIV tag written by tag | yes *---------------------+------------------------------------------------------------+-------------* pagelinksClass | CSS class name of the DisplayTag's navigation links [default="pagelinks"] | no *---------------------+------------------------------------------------------------+-------------* columnClass | The CSS class of the TD within the THEAD of the table that should have their HREFs rewritten [default="sortable"] | no *---------------------+------------------------------------------------------------+-------------* postFunction | Function to execute after Ajax is finished, allowing for a chain of additional functions to execute | no *---------------------+------------------------------------------------------------+-------------* parameters | A comma-separated list of parameters to pass to the server-side action or servlet | false *---------------------+------------------------------------------------------------+-------------* * ajax:htmlContent ~~~~~~~~~~~~~~~~~~ The HTML content tag allows you to fill a region on the page (often a DIV tag) with any HTML content pulled from another webpage. The AJAX action may be activated by attaching it to an anchor link or form field. This tag expects an HTML response instead of XML and the AJAX function will not parse it as XML; it will simply insert the content of the response as is. +------------------------------------------------------------------------+

Select by ANCHOR link.

+------------------------------------------------------------------------+ <> *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* var | Name of the JavaScript object created | no *---------------------+------------------------------------------------------------+-------------* attachTo | Name of the JavaScript object to which htmlContent will attach. You must define 'var' for this to work. | no *---------------------+------------------------------------------------------------+-------------* baseUrl | URL of server-side action or servlet that processes a simple command | yes *---------------------+------------------------------------------------------------+-------------* source | ID of the element to which the event will be attached | either source or sourceClass must be defined *---------------------+------------------------------------------------------------+-------------* sourceClass | The CSS class name of the elements to which the event will be attached | either source or sourceClass must be defined *---------------------+------------------------------------------------------------+-------------* target | ID of DIV tag or other element that will be filled with the response's HTML | yes *---------------------+------------------------------------------------------------+-------------* parameters | A comma-separated list of parameters to pass to the server-side action or servlet | yes *---------------------+------------------------------------------------------------+-------------* eventType | Specifies the event type to attach to the source field(s) | no *---------------------+------------------------------------------------------------+-------------* preFunction | Function to execute before Ajax is begun | no *---------------------+------------------------------------------------------------+-------------* postFunction | Function to execute after Ajax is finished, allowing for a chain of additional functions to execute | no *---------------------+------------------------------------------------------------+-------------* errorFunction | Function to execute if there is a server exception (non-200 HTTP response) | no *---------------------+------------------------------------------------------------+-------------* * ajax:portlet ~~~~~~~~~~~~~~ The portlet tag simulates a JSR-168 style portlet by allowing you to define a portion of the page that pulls content from another location using Ajax with or without a periodic refresh. This tag expects an HTML response instead of XML and the AJAX function will not parse it as XML; it will simply insert the content of the response as is. +------------------------------------------------------------------------+ +------------------------------------------------------------------------+ *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* var | Name of the JavaScript object created | no *---------------------+------------------------------------------------------------+-------------* attachTo | Name of the JavaScript object to which portlet will attach. You must define 'var' for this to work. | no *---------------------+------------------------------------------------------------+-------------* baseUrl | URL of server-side action or servlet that processes a simple command | yes *---------------------+------------------------------------------------------------+-------------* source | ID of the portlet | yes *---------------------+------------------------------------------------------------+-------------* parameters | A comma-separated list of parameters to pass to the server-side action or servlet | no *---------------------+------------------------------------------------------------+-------------* classNamePrefix | CSS class name prefix to use for the portlet's 'Box', 'Tools', 'Refresh', 'Size', 'Close', 'Title', and 'Content' elements | yes *---------------------+------------------------------------------------------------+-------------* title | Title for portlet header | yes *---------------------+------------------------------------------------------------+-------------* imageClose | Image used for the close icon | no *---------------------+------------------------------------------------------------+-------------* imageMaximize | Image used for the maximize icon | no *---------------------+------------------------------------------------------------+-------------* imageMinimize | Image used for the minimize icon | no *---------------------+------------------------------------------------------------+-------------* imageRefresh | Image used for the refresh icon | no *---------------------+------------------------------------------------------------+-------------* refreshPeriod | The time (in seconds) the portlet waits before automatically refreshing its content. If no period is specified, the portlet will not refresh itself automatically, but must be commanded to do so by clicking the refresh image/link (if one is defined). Lastly, the refresh will not occur until after the first time the content is loaded, so if executeOnLoad is set to false, the refresh will not begin until you manually refresh the first time. | no *---------------------+------------------------------------------------------------+-------------* executeOnLoad | Indicates whether the portlet's content should be retrieved when the page loads [default=true] | no *---------------------+------------------------------------------------------------+-------------* preFunction | Function to execute before Ajax is begun | no *---------------------+------------------------------------------------------------+-------------* postFunction | Function to execute after Ajax is finished, allowing for a chain of additional functions to execute | no *---------------------+------------------------------------------------------------+-------------* errorFunction | Function to execute if there is a server exception (non-200 HTTP response) | no *---------------------+------------------------------------------------------------+-------------* * ajax:select ~~~~~~~~~~~~~ The select tag allows one to retrieve a list of values from a backend servlet (or other server-side control) and display them in another HTML select box. +------------------------------------------------------------------------+
Make: Model:
+------------------------------------------------------------------------+ <> *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* var | Name of the JavaScript object created | no *---------------------+------------------------------------------------------------+-------------* attachTo | Name of the JavaScript object to which select will attach. You must define 'var' for this to work. | no *---------------------+------------------------------------------------------------+-------------* baseUrl | URL of server-side action or servlet that processes a simple command | yes *---------------------+------------------------------------------------------------+-------------* source | The initial select field that will form the basis for the search via AJAX | yes *---------------------+------------------------------------------------------------+-------------* target | Select field where value of AJAX search will be populated | yes *---------------------+------------------------------------------------------------+-------------* parameters | A comma-separated list of parameters to pass to the server-side action or servlet | no *---------------------+------------------------------------------------------------+-------------* eventType | Specifies the event type to attach to the source field(s) | no *---------------------+------------------------------------------------------------+-------------* executeOnLoad | Indicates whether the target select/dropdown should be populated when the object is initialized (this is essentially when the form loads) [default=false] | no *---------------------+------------------------------------------------------------+-------------* defaultOptions | A comma-seperated list of values of options to be marked as selected by default if they exist in the new set of options | no *---------------------+------------------------------------------------------------+-------------* preFunction | Function to execute before Ajax is begun | no *---------------------+------------------------------------------------------------+-------------* postFunction | Function to execute after Ajax is finished, allowing for a chain of additional functions to execute | no *---------------------+------------------------------------------------------------+-------------* errorFunction | Function to execute if there is a server exception (non-200 HTTP response) | no *---------------------+------------------------------------------------------------+-------------* parser | The response parser to implement [default=ResponseHtmlParser] | no *---------------------+------------------------------------------------------------+-------------* * ajax:tabPanel ~~~~~~~~~~~~~~~ Provides a tabbed page view of content from different resources +------------------------------------------------------------------------+ +------------------------------------------------------------------------+ ** ajax:tabPanel ~~~~~~~~~~~~~~~~ *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* id | ID of the tab panel | yes *---------------------+------------------------------------------------------------+-------------* preFunction | Function to execute before Ajax is begun | no *---------------------+------------------------------------------------------------+-------------* postFunction | Function to execute after Ajax is finished, allowing for a chain of additional functions to execute | no *---------------------+------------------------------------------------------------+-------------* errorFunction | Function to execute if there is a server exception (non-200 HTTP response) | no *---------------------+------------------------------------------------------------+-------------* parser | The response parser to implement [default=ResponseHtmlParser] | no *---------------------+------------------------------------------------------------+-------------* ** ajax:tab ~~~~~~~~~~ *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* baseUrl | The URL to use for the AJAX action, which will return content for this tab | yes *---------------------+------------------------------------------------------------+-------------* caption | The caption for this tab | yes *---------------------+------------------------------------------------------------+-------------* defaultTab | Indicates whether this tab is the initial one loaded [true|false] | no *---------------------+------------------------------------------------------------+-------------* parameters | A comma-separated list of parameters to pass to the server-side action or servlet | no *---------------------+------------------------------------------------------------+-------------* * ajax:toggle ~~~~~~~~~~~~~ The toggle tag uses a single image to represent the display of the ratings with the help of CSS to manage the mouseover/mouseout. Additionally, you may supply the tag with a form field to hold the value of the selected rating. +------------------------------------------------------------------------+

AJAX Rating System [${toggleRating}]

+------------------------------------------------------------------------+ <> *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* var | Name of the JavaScript object created | no *---------------------+------------------------------------------------------------+-------------* attachTo | Name of the JavaScript object to which toggle will attach. You must define 'var' for this to work. | no *---------------------+------------------------------------------------------------+-------------* baseUrl | URL of server-side action or servlet that processes a simple command from a toggle action; responds with a single option value and label | yes *---------------------+------------------------------------------------------------+-------------* source | A unique ID for each toggle tag | yes *---------------------+------------------------------------------------------------+-------------* ratings | Comma-delimited list of rating values | yes *---------------------+------------------------------------------------------------+-------------* defaultRating | The default rating to use from the 'ratings' list | yes *---------------------+------------------------------------------------------------+-------------* state | ID of hidden form field used to hold the current state | yes *---------------------+------------------------------------------------------------+-------------* onOff | Whether this is a simple on/off (two-value) rating [default=false] | no *---------------------+------------------------------------------------------------+-------------* containerClass | CSS style class for the container wrapping the toggle | yes *---------------------+------------------------------------------------------------+-------------* messageClass | CSS style class for the message displayed as you mouseover each toggle image | no *---------------------+------------------------------------------------------------+-------------* selectedClass | CSS style class for the rating that's selected | yes *---------------------+------------------------------------------------------------+-------------* selectedLessClass | CSS style class for the rating that is less than the selected one as you mouseover | yes *---------------------+------------------------------------------------------------+-------------* selectedOverClass | CSS style class for the rating that is greater than the selected one as you mouseover | yes *---------------------+------------------------------------------------------------+-------------* overClass | CSS style class for the rating that is greater than the selected one | yes *---------------------+------------------------------------------------------------+-------------* parameters | A comma-separated list of parameters to pass to the server-side action or servlet | rating={ajaxParameter} *---------------------+------------------------------------------------------------+-------------* preFunction | Function to execute before Ajax is begun | no *---------------------+------------------------------------------------------------+-------------* postFunction | Function to execute after Ajax is finished, allowing for a chain of additional functions to execute | no *---------------------+------------------------------------------------------------+-------------* errorFunction | Function to execute if there is a server exception (non-200 HTTP response) | no *---------------------+------------------------------------------------------------+-------------* parser | The response parser to implement [default=ResponseHtmlParser] | no *---------------------+------------------------------------------------------------+-------------* * ajax:updateField ~~~~~~~~~~~~~~~~~~ Builds the JavaScript required to update one or more form fields based on the value of another single field. +------------------------------------------------------------------------+
Velocity Conversion
+------------------------------------------------------------------------+ <> *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* var | Name of the JavaScript object created | no *---------------------+------------------------------------------------------------+-------------* attachTo | Name of the JavaScript object to which updateField will attach. You must define 'var' for this to work. | no *---------------------+------------------------------------------------------------+-------------* baseUrl | URL of server-side action or servlet that processes a simple command | yes *---------------------+------------------------------------------------------------+-------------* source | The form field that will hold the parameter passed to the servlet | yes *---------------------+------------------------------------------------------------+-------------* target | A comma-delimited list of form field IDs that will be populated with results | yes *---------------------+------------------------------------------------------------+-------------* action | ID of form button or image tag that will fire the onclick event | yes *---------------------+------------------------------------------------------------+-------------* parameters | A comma-separated list of parameters to pass to the server-side action or servlet | no *---------------------+------------------------------------------------------------+-------------* eventType | Specifies the event type to attach to the source field(s) | no *---------------------+------------------------------------------------------------+-------------* preFunction | Function to execute before Ajax is begun | no *---------------------+------------------------------------------------------------+-------------* postFunction | Function to execute after Ajax is finished, allowing for a chain of additional functions to execute | no *---------------------+------------------------------------------------------------+-------------* errorFunction | Function to execute if there is a server exception (non-200 HTTP response) | no *---------------------+------------------------------------------------------------+-------------* parser | The response parser to implement [default=ResponseHtmlParser] | no *---------------------+------------------------------------------------------------+-------------* * ajax:tree ~~~~~~~~~~~~~~~~~~ Builds the JavaScript required to create a tree +------------------------------------------------------------------------+ +------------------------------------------------------------------------+ <> *---------------------+------------------------------------------------------------+-------------* <> | <> | <> *---------------------+------------------------------------------------------------+-------------* baseUrl | URL of server-side action or servlet that processes a simple command | yes *---------------------+------------------------------------------------------------+-------------* action | ID of form button or image tag that will fire the onclick event | yes *---------------------+------------------------------------------------------------+-------------* parameters | A comma-separated list of parameters to pass to the server-side action or servlet | yes *---------------------+------------------------------------------------------------+-------------* id | The ID of the tree | yes *---------------------+------------------------------------------------------------+-------------* preFunction | Function to execute before Ajax is begun | no *---------------------+------------------------------------------------------------+-------------* postFunction | Function to execute after Ajax is finished, allowing for a chain of additional functions to execute | no *---------------------+------------------------------------------------------------+-------------* errorFunction | Function to execute if there is a server exception (non-200 HTTP response) | no *---------------------+------------------------------------------------------------+-------------* parser | The response parser to implement [default=ResponseXmlToHtmlLinkListParser] | no *---------------------+------------------------------------------------------------+-------------* collapsedClass | CSS style class for the node's image(when collapsed) | no *---------------------+------------------------------------------------------------+-------------* expandedClass | CSS style class for the node's image(when expanded) | no *---------------------+------------------------------------------------------------+-------------* treeClass | CSS style class for the unsorted list(each node is hosted on one) | no *---------------------+------------------------------------------------------------+-------------* nodeClass | CSS style class for the node's link | no *---------------------+------------------------------------------------------------+-------------* ajaxtags-1.5.1/src/site/apt/advanced.apt0000644000175000017500000002541411266022546020062 0ustar twernertwernerAdvanced Techniques ~~~~~~~~~~~~~~~~~~~ * Chaining ~~~~~~~~~~ Multiple fields can be hooked together in a way that implies dependencies between fields. The most common use case is when using multiple select or dropdown fields. For example, let's say we want to have the user select a make, model, and year of car. The form may look like this: +-----------------------------------------------------------------------------+
Make: Model: Year:
+-----------------------------------------------------------------------------+ In this case, we're not defining any values for model or year because we'll have our AJAX component populate them when the user selects a make and model, respectively. Now, we need to define two ajax:select tags. The first will link the make and model fields. The second will link the model and year fields. +-----------------------------------------------------------------------------+ +-----------------------------------------------------------------------------+ * Pre- and Post-Functions ~~~~~~~~~~~~~~~~~~~~~~~~~ Let's face it, every framework has limitations. So, in order to provide you with some way to incorporate your existing JavaScript with these tags, the concept of pre- and post-functions was developed. A pre-function is a JavaScript function that is called the XMLHttpRequest (i.e., to your backend action servlet) is executed. A post-function is, naturally, one called the XMLHttpRequest is completed. So, for those of you only reading bullets. <>: * <> AJAX executes. * <> AJAX tag's base function completes. [] Let's say we're using the ajax:select tag to help populate a list of automobile model names when the user selects an automobile make. This is the same example used in the demo application. However, we want to take it a step further and display an image of the auto maker's logo when that first selection is made. For instance, if the user selects "Ford" from the list of makes, we not only populate the second dropdown field with names of Ford models but we also get that classic Ford emblem displayed on the page. This second action merely requires a bit of JavaScript to replace a blank placeholder image with that of the auto maker's. Because we AJAX JSP Tag authors didn't anticipate such fantastic uses for web interfaces, we provided the means to attach a post-function to the AJAX tags so that you more creative developers could tackle these harsh, real-world problems. Observe... +------------------------------------------------------------------------+
+------------------------------------------------------------------------+ * Helper Classes ~~~~~~~~~~~~~~~~ ** org.ajaxtags.helpers.AjaxXmlBuilder ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The AjaxXmlBuilder class will help you construct a valid, well-formed XML string to pass back to the client. You can either add items selectively or add an entire collections. *** Passing a Collection ~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------------------------------------------------------+ // Get maker from your service bean CarService service = new CarService(); List list = service.getModelsByMake(make); return new AjaxXmlBuilder().addItems(list, "model", "make").toString(); +------------------------------------------------------------------------+ ...returns... +------------------------------------------------------------------------+ Expedition Ford Focus Ford ... +------------------------------------------------------------------------+ *** Adding Individual Items ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +------------------------------------------------------------------------+ // Get maker from your service bean CarService service = new CarService(); List list = service.getModelsByMake(make); AjaxXmlBuilder builder = new AjaxXmlBuilder(); for (Iterator iter = list.iterator(); iter.hasNext();) { Car car = (Car) iter.next(); builder.addItem(car.getModel(), car.getMake()); } return builder.toString(); +------------------------------------------------------------------------+ ...returns the same as in the collections example above. * BaseAjaxServlet and BaseAjaxAction ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ** org.ajaxtags.servlets.BaseAjaxServlet ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AJAX functions require a backend resource to handle and respond to requests. We've created an abstract class to help you with that task. Simply extend the BaseAjaxServlet and implement the <<>> method. ** org.ajaxtags.servlets.BaseAjaxAction ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is very similar to the BaseAjaxServlet, providing a Struts-based implementation. * Cascading StyleSheets ~~~~~~~~~~~~~~~~~~~~~~~ While most of the features in AjaxTags comes from JavaScript, there is a heavy reliance on CSS for the visual parts. This is both a blessing and curse. On the one hand, you have a great range of flexibility to create your own visual appearance for the tags. However, if you forget to set up the CSS (either with your own definitions or via our handy sample ones), you may get quite an unexpected look. We don't claim to be CSS experts. <> Anyway, it should be easy enough to start with the sample CSS that's included in both the distribution and demo application. We would like to provide more examples or skins, so please submit them and we'll consider adding them to the samples. * Custom Response Parsers ~~~~~~~~~~~~~~~~~~~~~~~~~ One of the latest additions to the AjaxTags is the delegation of response parsing to separate JavaScript functions. What this means to you is that you have the ability of write your own parser to suit the needs of any formatted response you decide to send from the backend. We provide several default ones for you. ** Generic Structure ~~~~~~~~~~~~~~~~~~~~ Your parser should extend the AbstractResponseParser (JavaScript) class. You can do this using the Protoype framework's Object.extend method as shown in the example below. +------------------------------------------------------------------------+ ResponseTextParser = Class.create(); ResponseTextParser.prototype = Object.extend(new AbstractResponseParser(), { }); +------------------------------------------------------------------------+ You must implement at least two methods: initialize and load. Think of the initialize method as a pseudo-constructor. The load method is called by each AjaxTag to perform the parsing of the response. It takes the XMLHttpRequest object as the only parameter. +------------------------------------------------------------------------+ ResponseTextParser = Class.create(); ResponseTextParser.prototype = Object.extend(new AbstractResponseParser(), { initialize: function() { }, load: function(request) { } }); +------------------------------------------------------------------------+ In the default parsers, the initialize function only serves to set a type property to a meaningful descriptor for the parser. For example: +------------------------------------------------------------------------+ ResponseTextParser = Class.create(); ResponseTextParser.prototype = Object.extend(new AbstractResponseParser(), { initialize: function() { this.type = "text"; }, load: function(request) { } }); +------------------------------------------------------------------------+ The load method pulls the response content and parses it. In the case of the ResponseTextParser shown below, we call a separate function called split to parse the comma-delimited text response. +------------------------------------------------------------------------+ ResponseTextParser = Class.create(); ResponseTextParser.prototype = Object.extend(new AbstractResponseParser(), { initialize: function() { this.type = "text"; }, load: function(request) { this.content = request.responseText; this.split(); }, split: function() { this.itemList = new Array(); var lines = this.content.split('\n'); for (var i=0; i +------------------------------------------------------------------------+ ajaxtags-1.5.1/src/site/apt/install.apt0000644000175000017500000001271611265031104017751 0ustar twernertwernerInstallation ~~~~~~~~~~~~ * Requirements ~~~~~~~~~~~~~~ * JDK 1.5+ * Servlet container running Servlets 2.5+ and JSP 2.1+, cause you need flush=false if you use include with areaTag. For all other things you can use JSP 2.0. * {{{dependencies.html}AjaxTags dependencies}} * Maven 2 (If you intend to build from the source) * Installation and Set Up ~~~~~~~~~~~~~~~~~~~~~~~~~ ** Step 1: Copy AjaxTags jar file ~~~~~~~~~~~~~~~~~~~ Copy the <<>> into your <<>> directory. ** Step 2: Create Server-side Handler ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There must be a server-side handler that will process the AJAX request. This could be a servlet, Struts action, another JSP, or even a non-Java, server-side component. The only requirement of this component is that it return an XML file that represents a list of results based on the query passed to it from the client-side AJAX functions. There are helper classes to assist in building the XML if you don't want to do it by hand...see the {{{advanced.html}advanced guide}} for more information. *** XML Response ~~~~~~~~~~~~~~~ +------------------------------------------------------------------------+ Record 1 1 Record 2 2 Record 3 3 +------------------------------------------------------------------------+ *** Text Response ~~~~~~~~~~~~~~~~ +------------------------------------------------------------------------+ Record 1,1 Record 2,2 Record 3,3 +------------------------------------------------------------------------+ *** Javascript Response ~~~~~~~~~~~~~~~~~~~~~~~ +-----------------------------+ var i=10; for (;i>0;i--){ doStuff(i); } +-----------------------------+ *** HTML Response ~~~~~~~~~~~~~~~~~~~ +-----------------------------+

Simple test

Bold +-----------------------------+ ** Step 3: Declare TLD Reference on JSP ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For each JSP in which you wish to use the AJAX tag, simply define it as with any other tag library. +------------------------------------------------------------------------+ <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax" %> +------------------------------------------------------------------------+ ** Step 4: Do the Servlet Mapping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Map the resources which are stored in jar file to an url +------------------------------------------------------------------------+ sourceloader net.sourceforge.ajaxtags.servlets.SourceLoader prefix /ajaxtags sourceloader /ajaxtags/js/* sourceloader /img/* sourceloader /css/* +------------------------------------------------------------------------+ ** Step 5: Include JavaScript Core ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ With AJAX, you'll need JavaScript. Fortunately, everything you'll need is included with a javascript loader file. Incidentally, the reason why a (bulky) JavaScript source file was chosen versus having each JSP tag generate only what it needs is because it's assumed that most browsers cache external resources like stylesheets, images, and JavaScript files. This should increase performance slightly. Besides, this core JavaScript is generic enough to use for other purposes that the tag library does not yet provide. +------------------------------------------------------------------------+ +------------------------------------------------------------------------+ ** Step 6: Define CSS Styles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Many tags rely heavily on CSS to help visually represent their function. For example, in the case of the ajax:autocomplete tag, CSS transforms a simple unordered list (i.e., <<
    LI>>> tags) into a dropdown list. +------------------------------------------------------------------------+ +------------------------------------------------------------------------+ * Next: Usage ~~~~~~~~~~~~~ Once everything is set up, all that's left is to pick you tag. See {{{usage.html}how they're used}}. ajaxtags-1.5.1/src/site/apt/roadmap.apt0000644000175000017500000000162611240372226017732 0ustar twernertwernerRoadmap ~~~~~~~~ * Documentation ~~~~~~~~ [[1]] write plugins/parser for Ajaxtags [[2]] howto implement/use Ajaxtags in other frameworks [[1]] Struts [[2]] JSP 2.0 / Servlets * Version 1.5 ~~~~~~~~~~~ ** beta-X ~~~~~~~ [[1]] users of this lib are now forced to write xhtml / fallback parser [[2]] skip parsing wrong xhtml code! and throw JSPException DONE [[3]] a bigger demo with more example to show and learn [[5]] portlet changed no cookie is used now DONE (break JSR ???) [] ** stable ~~~~~~~~ [[1]] use of prototype >=(v1.6.0.2) DONE [[2]] use of scriptaculous >=(v1.8.1) DONE [[3]] overlib >=(25.10.2008) DONE [[4]] only CSS style-class in default css file DONE [[5]] SourceLoader for images, Javascript and CSS DONE [[6]] update old JavaScript things (e.g. parsers and controls) DONE [[7]] update documentation to version 1.5 [[8]] wrapper for jericho-html parser. [] ajaxtags-1.5.1/src/site/apt/quickstart.apt0000644000175000017500000000446611265031062020503 0ustar twernertwernerQuick Start ~~~~~~~~~~~ * From AjaxTags 1.3 ~~~~~~~~~~~~~~~~~~~~~ The new version has some big changes. The new API has changed the name-space so you need to check your imports. You need to replace package names from to . Another step is to implement the >BaseAjaxXmlAction> interface You need to make sure that is called this is provieded by and will be provieded again for struts in future release First follow the steps at {{{install.html}install}} page * Prepare JSP View ~~~~~~~~~~~~~~~~~~ Your JSP, of course, is where it all comes together. [[1]] declare the taglib [[2]] include a reference to the JavaScript source [[3]] include a reference to any CSS required [[4]] add your content [[5]] include the AJAX tag you want to use. +------------------------------------------------------------------------+ <%@ taglib uri="http://ajaxtags.org/tags/ajax" prefix="ajax" %> AJAX JSP Tag Library
    Make: Model:
    +------------------------------------------------------------------------+ * Servlet example handler ~~~~~~~~~~~~~~~~~~~~~~~~~ TODO * Next: Usage ~~~~~~~~~~~~~ See {{{usage.html}how they're used}}. ajaxtags-1.5.1/src/site/apt/index.apt0000644000175000017500000001233211263706366017425 0ustar twernertwernerAjax JSP Tag Library ~~~~~~~~~~~~~~~~~~~~ The AJAX Tag Library is a set of JSP tags that simplify the use of Asynchronous JavaScript and XML (AJAX) technology in JavaServer Pages. AJAX is primarily rooted in JavaScript. However, many server-side developers do not have an extensive knowledge of client-side programming in the browser. It's much easier in some cases for J2EE developers, especially, to simply add a JSP tag to the page to gain the function desired. This tag library fills that need by not forcing J2EE developers to write the necessary JavaScript to implement an AJAX-capable web form. The tag library provides support for live form updates for the following use cases: autocomplete based on character input to an input field, select box population based on selections made from another field, callout or balloon popups for highlighting content, refreshing form fields, toggling images and form field states on/off. The implementation is a combination of Java classes and JavaScript source files. The Java code should be OS independent as there are no client side components. However, the Java is dependent on JDK 1.5+ and requires a Servlet container to run at least JSP version 2.0. Just if you need includes with the area Tag you will need JSP version 2.1 (Tomcat6+). The JavaScript should run in at least Firefox 2.0+ and Internet Explorer 6.0+. To get started, check out the {{{install.html}install}} and {{{quickstart.html}quickstart}} guides. While using the tag library please write XHTML code in your WEB application otherwise tag will fail and throw an error. * Tags Available ~~~~~~~~~~~~~~~~ *---------------------+--------------------------------------------------------------------------+ <> | <> *---------------------+--------------------------------------------------------------------------+ Autocomplete | Retrieves a list of values that matches the string entered in a text form field as the user types. *---------------------+--------------------------------------------------------------------------+ Callout | Displays a callout or popup balloon, anchored to an HTML element with an onclick event. *---------------------+--------------------------------------------------------------------------+ HTML Content Replace | Builds the JavaScript required to hook a content area (e.g., DIV tag) to a link, image, or other HTML element's onclick event. *---------------------+--------------------------------------------------------------------------+ Portlet | Portlet-style capability from a AJAX-enabled JSP tag. *---------------------+--------------------------------------------------------------------------+ Select/dropdown | Based on a selection within a dropdown field, a second select field will be populated. *---------------------+--------------------------------------------------------------------------+ Tab Panel / Tab | Enable an AJAX-based set of property pages. *---------------------+--------------------------------------------------------------------------+ Toggle | Uses images to create either a single on/off toggle or a sequential rating system. *---------------------+--------------------------------------------------------------------------+ Update Field | Updates one or more form field values based on response to text entered in another field. *---------------------+--------------------------------------------------------------------------+ Area and Anchor | Shows how to AJAX-enable any area of your page. *---------------------+--------------------------------------------------------------------------+ Ajax DisplayTag | Shows how to AJAX-enable DisplayTag *---------------------+--------------------------------------------------------------------------+ Editor | Create an in-place editor *---------------------+--------------------------------------------------------------------------+ Tree | Create an Tree view *---------------------+--------------------------------------------------------------------------+ * Links ~~~~~ * {{{http://www.adaptivepath.com/publications/essays/archives/000385.php}A New Approach to Web Applications}} * {{{http://sourcelabs.com/ajb/archives/2005/05/ajax_mistakes.html}Ajax Mistakes}} * {{{http://www.sitepoint.com/blog-post-view.php?id=171725}XMLHttpRequest and Javascript Closures}} * {{{http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/7924f6be-c035-411f-acd2-79de7a711b38.asp}XmlHttpRequest IE Spec}} * {{{http://jpspan.sourceforge.net/wiki/doku.php?id=javascript:xmlhttprequest}XmlHttpRequest Intro}} * {{{http://developer.apple.com/internet/webcontent/xmlhttpreq.html}XmlHttpRequest Apple}} * {{{http://dojotoolkit.org/}Dojo browser toolkit}} * {{{http://www.getahead.ltd.uk/dwr/}Direct Web Remoting}} * {{{http://script.aculo.us/}Scriptaculous}} * {{{http://www.prototypejs.org/}Prototype framework}} * {{{http://oss.metaparadigm.com/jsonrpc/}JSON-RPC-Java}} * {{{http://javawebparts.sourceforge.net/}Java Web Parts}} * {{{http://www.ajaxmatters.com/}AJAX Matters}} * {{{http://ajaxpatterns.org/}Tag Ajax Patterns}} * {{{http://ajaxian.com/}Ajaxian}} * {{{http://ajaxblog.com/}Ajax Blog}} ajaxtags-1.5.1/src/site/changes.xml0000644000175000017500000000655111304776122017155 0ustar twernertwerner ]> Changes Jens Kapitza XMLUtils methods updated XML-Ident problem Fixed bug with anchor titles in AjaxToggleTag. New form submit tag. Added 'var' and 'attachTo' attributes to tree tag. Update Documentation Autocompleter popup div is inserted at the top of the DOM hierarchy to prevent overflow. Added default attribute values to AjaxDisplayTag. AjaxDisplayTag with empty attributes will not rewrite links. Fixed AjaxAreaTag. Fixed AjaxJspTag.Toggle. Fixed AjaxJspTag.Base#buildParameterString for checkbox and select-multiple input fields. TLD now validate Remove Reflection usage and refactor to interface Changed Website, and documentation Portlet autorefresh never stops. Now we do break execution if source is not in DOM tree Portlet attribute withBar removed. Depends on JSP-API 2.1 and Servlet-API 2.5, cause flush does not work with area styled tags. we moved to Mercurial. import version 1.3. drop support for java 1.4 and later drop jericho html. and use integrated xml parser. this force the user to write xhtml this version is blacklisted this version was used for testing javascript functions. this version was not compatible. ajaxtags-1.5.1/src/main/0000755000175000017500000000000011240372226014770 5ustar twernertwernerajaxtags-1.5.1/src/main/assembly/0000755000175000017500000000000011240372226016607 5ustar twernertwernerajaxtags-1.5.1/src/main/assembly/src.xml0000644000175000017500000000247211240372226020125 0ustar twernertwerner src zip README* LICENSE* NOTICE* pom.xml . README* *.xml *.license src/** ajaxtags ajaxtags README* *.xml *.license src/** ajaxtags-demo ajaxtags-demo README* *.xml *.license src/** ajaxtags-resources ajaxtags-resources README* *.xml *.license src/** ajaxtags-1.5.1/src/main/assembly/bin.xml0000644000175000017500000000266511265146226020120 0ustar twernertwerner bin zip . README* LICENSE* NOTICE* pom.xml ajaxtags-demo/target *.war *-sources.jar ajaxtags/target *.jar *-sources.jar ajaxtags-resources/target *.jar *.zip *-sources.jar target/site docs ajaxtags/target/site docs/ajaxtags ajaxtags/src/main/resources/META-INF/*.tld docs/tags/ ajaxtags-1.5.1/ajaxtags-demo/0000777000175000017500000000000011305026660016005 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/pom.xml0000644000175000017500000000236411305024426017321 0ustar twernertwerner ajaxtags-doc ajaxtags 1.5.1 4.0.0 ajaxtags ajaxtags-demo war Ajaxtags library examples 1.5.1 Example webapp for the ajaxtags tag library displaytag displaytag 1.2 ajaxtags ajaxtags ${version} ajaxtags ajaxtags-resources ${version} ajaxtags-1.5.1/ajaxtags-demo/src/0000755000175000017500000000000011276326676016611 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/0000755000175000017500000000000011267277642017533 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/java/0000755000175000017500000000000011240372226020435 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/0000755000175000017500000000000011240372226021223 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/0000755000175000017500000000000011240372226023546 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/0000755000175000017500000000000011240372226025350 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/0000755000175000017500000000000011253742240026275 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/CarService.java0000644000175000017500000000724011304776346031204 0ustar twernertwerner/* * 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.demo; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * This class simulate a Car Service. It's not intended to be used as a good example (we recomend * that you use interfaces, etc). * * @author Darren Spurgeon * @author Jens Kapitza */ public class CarService { /** * Hard-coded list of cards, so that we do not have to use a database in the examples. */ private static List cars = new ArrayList(); static { cars.add(new Car("Ford", "Escape")); cars.add(new Car("Ford", "Expedition")); cars.add(new Car("Ford", "Explorer")); cars.add(new Car("Ford", "Focus")); cars.add(new Car("Ford", "Mustang")); cars.add(new Car("Ford", "Thunderbird")); cars.add(new Car("Honda", "Accord")); cars.add(new Car("Honda", "Civic")); cars.add(new Car("Honda", "Element")); cars.add(new Car("Honda", "Ridgeline")); cars.add(new Car("Mazda", "Mazda 3")); cars.add(new Car("Mazda", "Mazda 6")); cars.add(new Car("Mazda", "RX-8")); cars.add(new Car("VW", "Skoda")); cars.add(new Car("VW", "Fox")); cars.add(new Car("VW", "Golf")); cars.add(new Car("VW", "Polo")); } /** * Constructor for CarService. */ public CarService() { super(); } /** * Get all models for a particular car maker. * * @param make * the make of the car * @return a {@link java.util.List} of {@link org.ajaxtags.demo.Car} objects */ public List getModelsByMake(String make) { List l = new ArrayList(); if (make == null) { return l; } for (Car car : cars) { if (car.getMake().equalsIgnoreCase(make)) { l.add(car); } } return l; } /** * Get all models that start with name. * * @param name * the name of the car model * @return a {@link java.util.List} of {@link org.ajaxtags.demo.Car} objects */ public List getModelsByName(String name) { List l = new ArrayList(); if (name == null) { return l; } for (Car car : cars) { if (car.getModel().startsWith(name)) { l.add(car); } } return l; } /** * Get all cars. * * @return a {@link java.util.List} of {@link org.ajaxtags.demo.Car} objects */ public List getAllCars() { return cars; } /** * Read the first char of the model and return a sorted List. * * @return a list of chars. */ public List getModelsFirstChar() { List clist = new ArrayList(); for (Car c : getAllCars()) { char firstChar = c.getModel().charAt(0); if (!clist.contains(firstChar)) { clist.add(firstChar); } } Collections.sort(clist); return clist; } } ajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/0000755000175000017500000000000011262371154027763 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/AutocompleteServlet.javaajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/AutocompleteServlet0000644000175000017500000000453511300773736033730 0ustar twernertwerner/* * 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.demo.servlet; import java.io.IOException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.ajaxtags.demo.Car; import net.sourceforge.ajaxtags.demo.CarService; import net.sourceforge.ajaxtags.servlets.BaseAjaxServlet; import net.sourceforge.ajaxtags.xml.AjaxXmlBuilder; /** * An example servlet that responds to an ajax:autocomplete tag action. This servlet would be * referenced by the baseUrl attribute of the JSP tag. *

    * This servlet should generate XML in the following format: *

    * * * First Item * Second Item * Third Item * ]]> * * @author Darren L. Spurgeon * @version $Revision: 28 $ $Date: 2008-11-09 23:12:33 +0100 (So, 09. Nov 2008) $ */ public class AutocompleteServlet extends BaseAjaxServlet { private static final long serialVersionUID = 1L; /** * @see BaseAjaxServlet#getXmlContent(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ public String getXmlContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String model = request.getParameter("model"); CarService service = new CarService(); List list = service.getModelsByName(model); // Thread.sleep(3000); // sleep 3 seconds // Create xml schema try { return new AjaxXmlBuilder().addItems(list).toString(); } catch (Exception e) { throw new ServletException(e); } } } ajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/ToggleServlet.java0000644000175000017500000000427511300773736033431 0ustar twernertwerner/* * 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.demo.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * An example servlet that responds to an ajax:toggle tag action. This servlet would be referenced * by the baseUrl attribute of the JSP tag. * * @author Darren L. Spurgeon * @version $Revision: 28 $ $Date: 2008-11-09 23:12:33 +0100 (So, 09. Nov 2008) $ */ public class ToggleServlet extends HttpServlet { private static final long serialVersionUID = -394141738706308222L; @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String rating = request.getParameter("rating"); if (rating != null && rating.length() > 0) { if ("2".equals(request.getParameter("type"))) { // request from second toggle sample - on-off request.getSession().setAttribute("toggleRatingOnOff", rating); } else { // request from first toggle sample - star-rating request.getSession().setAttribute("toggleRating", rating); } } else { rating = ""; } PrintWriter pw = response.getWriter(); pw.write(rating); pw.close(); } @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/CalloutServlet.javaajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/CalloutServlet.java0000644000175000017500000000437411300773740033606 0ustar twernertwerner/* * 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.demo.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.ajaxtags.servlets.BaseAjaxServlet; import net.sourceforge.ajaxtags.xml.AjaxXmlBuilder; /** * An example servlet that responds to an ajax:callout tag action. This servlet would be referenced * by the baseUrl attribute of the JSP tag. *

    * This servlet should generate XML in the following format: *

    * * * First Item * Second Item * Third Item * ]]> * * @author Darren L. Spurgeon * @version $Revision: 28 $ $Date: 2008-11-09 23:12:33 +0100 (So, 09. Nov 2008) $ */ public class CalloutServlet extends BaseAjaxServlet { private static final long serialVersionUID = 1L; /** * @see BaseAjaxServlet#getXmlContent(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ public String getXmlContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String param = request.getParameter("q"); if (param == null) { // param = request.getParameter("editorId"); return request.getParameter("value"); } return new AjaxXmlBuilder().addItemAsCData( "Callout Header", "

    This is a test of the 'callout.view'

    You asked about:
    " + param + ".

    ").toString(); } } ajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/NameInput.java0000644000175000017500000000313311253742240032524 0ustar twernertwerner/* * 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.demo.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.ajaxtags.servlets.BaseAjaxServlet; import net.sourceforge.ajaxtags.xml.AjaxXmlBuilder; public class NameInput extends BaseAjaxServlet { private static final long serialVersionUID = 8397661247446643963L; public String getXmlContent(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException { AjaxXmlBuilder xml = new AjaxXmlBuilder(); xml.addItem("name", arg0.getParameter("name")); int age = -1; try { age = Integer.parseInt(arg0.getParameter("age")); } catch (NumberFormatException e) { age = -1; } xml.addItem("age", age == -1 ? "$not a number (" + arg0.getParameter("age") + ") ;)" : String.valueOf(age)); return xml.toString(); } } ajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/TreeServlet.java0000644000175000017500000000624311300773740033077 0ustar twernertwerner/* * 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.demo.servlet; import java.io.IOException; import java.util.Date; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.ajaxtags.helpers.TreeItem; import net.sourceforge.ajaxtags.servlets.BaseAjaxServlet; import net.sourceforge.ajaxtags.xml.AjaxTreeXmlBuilder; /** * An example servlet that responds to an ajax:tree tag action. * * @author Musachy Barroso * @version $Revision: 28 $ $Date: 2008-11-25 21:27:48 +0100 (Di, 25. Nov 2008) $ */ public class TreeServlet extends BaseAjaxServlet { private static final long serialVersionUID = 8050270760189927009L; /** * @see BaseAjaxServlet#getXmlContent(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ public String getXmlContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String action = request.getParameter("action"); String node = request.getParameter("node"); if (action != null && action.equalsIgnoreCase("info")) { return "" + node + " at " + new Date(); // nur den namen liefern } if (node == null) { return "node is null"; } AjaxTreeXmlBuilder treeBuilder = new AjaxTreeXmlBuilder(); if ("cars".equals(node)) { treeBuilder.addItem("American", "American", true, "javascript://nop"); treeBuilder.addItem("Japanese", "Japanese", false, "javascript://nop"); } else if (node.equals("American")) { treeBuilder.addItem("Ford", "Ford", true, "javascript://nop"); } else if (node.equals("Ford")) { TreeItem item = new TreeItem("Mustang", "Mustang", false); item.setLeaf(true); treeBuilder.add(item); item = new TreeItem("FordGT", "FordGT", false); item.setLeaf(true); treeBuilder.add(item); } else if (node.equals("Ford")) { treeBuilder.addItem("Mustang", "Mustang", false, "javascript://nop"); treeBuilder.addItem("FordGT", "FordGT", false, "javascript://nop"); } else if (node.equals("Japanese")) { treeBuilder.addItem("Honda", "Honda", true, "javascript://nop"); } else if (node.equals("Honda")) { treeBuilder.addItem("Civic", "Civic", true, "javascript://nop"); treeBuilder.addItem("Accord", "Accord", true, "javascript://nop"); } return treeBuilder.toString(); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/FormUpdateServlet.javaajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/FormUpdateServlet.j0000644000175000017500000000414511300773740033555 0ustar twernertwerner/* * 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.demo.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.ajaxtags.servlets.BaseAjaxServlet; import net.sourceforge.ajaxtags.xml.AjaxXmlBuilder; /** * An example servlet that responds to an ajax:updateField tag action. This servlet would be * referenced by the baseUrl attribute of the JSP tag. * * @author Darren L. Spurgeon * @version $Revision: 28 $ $Date: 2008-11-09 23:12:33 +0100 (So, 09. Nov 2008) $ */ public class FormUpdateServlet extends BaseAjaxServlet { private static final long serialVersionUID = 1L; private static final double MPH_TO_KPH = 1.609344; private static final double MPH_TO_MPS = 0.44704; /** * @see BaseAjaxServlet#getXmlContent(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ public String getXmlContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { double mph = 0, kph = 0, mps = 0; try { mph = Double.parseDouble(request.getParameter("mph")); } catch (NumberFormatException e) { mph = -1; } kph = mph * FormUpdateServlet.MPH_TO_KPH; mps = mph * FormUpdateServlet.MPH_TO_MPS; return new AjaxXmlBuilder().addItem("kph", Double.toString(kph)).addItem("mps", Double.toString(mps)).toString(); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/DropdownServlet.javaajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/DropdownServlet.jav0000644000175000017500000000410311300773736033631 0ustar twernertwerner/* * 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.demo.servlet; import java.io.IOException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.ajaxtags.demo.Car; import net.sourceforge.ajaxtags.demo.CarService; import net.sourceforge.ajaxtags.servlets.BaseAjaxServlet; import net.sourceforge.ajaxtags.xml.AjaxXmlBuilder; /** * An example servlet that responds to an ajax:select tag action. This servlet would be referenced * by the baseUrl attribute of the JSP tag. * * @author Darren L. Spurgeon * @author Jens Kapitza * @version $Revision: 28 $ $Date: 2008-11-09 23:12:33 +0100 (So, 09. Nov 2008) $ */ public class DropdownServlet extends BaseAjaxServlet { private static final long serialVersionUID = 1L; /** * @see BaseAjaxServlet#getXmlContent(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ public String getXmlContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String make = request.getParameter("make"); // Get maker from your service bean CarService service = new CarService(); List list = service.getModelsByMake(make); AjaxXmlBuilder xml = new AjaxXmlBuilder(); for (Car car : list) { xml.addItem(car.getModel(), true, car.getModel()); } return xml.toString(); } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/HtmlContentServlet.javaajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/servlet/HtmlContentServlet.0000644000175000017500000000436411300773740033577 0ustar twernertwerner/* * 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.demo.servlet; import java.io.IOException; import java.util.Date; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.sourceforge.ajaxtags.demo.Car; import net.sourceforge.ajaxtags.demo.CarService; import net.sourceforge.ajaxtags.servlets.BaseAjaxServlet; /** * An example servlet that responds to an ajax:htmlContent tag action. * * @author Darren L. Spurgeon * @version $Revision: 28 $ $Date: 2008-11-09 23:12:33 +0100 (So, 09. Nov 2008) $ */ public class HtmlContentServlet extends BaseAjaxServlet { private static final long serialVersionUID = 1L; /** * @see org.ajaxtags.demo.servlet.BaseAjaxServlet#getXmlContent(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ public String getXmlContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String make = request.getParameter("make"); if (make == null) { make = ""; } CarService service = new CarService(); List list = service.getModelsByMake(make); StringBuilder html = new StringBuilder(); html.append("

    ").append(make).append("

    Models

      "); for (Car car : list) { html.append("
    • ").append(car.getModel()).append("
    • "); } html.append("
    "); html.append("
    "); html.append("Last Updated: "); html.append(new Date()); html.append(""); return html.toString(); } } ajaxtags-1.5.1/ajaxtags-demo/src/main/java/net/sourceforge/ajaxtags/demo/Car.java0000644000175000017500000000441611300773740027654 0ustar twernertwerner/* * 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.demo; import java.io.Serializable; import net.sourceforge.ajaxtags.xml.AjaxXmlBuilder.PropertyReader; /** * A Car entity with make and model properties. * * @author Darren Spurgeon * @author Jens Kapitza */ public class Car implements Serializable, PropertyReader { private static final long serialVersionUID = 1274650793273603808L; private String make; private String model; /** * Constructor for Car. */ public Car() { this(null, null); } /** * Constructor for Car. * * @param make * @param model */ public Car(String make, String model) { super(); this.make = make; this.model = model; } /** * @return Returns the make. */ public String getMake() { return this.make; } /** * @param make * The make to set. */ public void setMake(String make) { this.make = make; } /** * @return Returns the model. */ public String getModel() { return this.model; } /** * @param model * The model to set. */ public void setModel(String model) { this.model = model; } /** * @return the name of the car e.g. the model */ public String getName() { return getModel(); } /** * @return the value of the car e.g. the make */ public String getValue() { return getMake(); } /** * @return true, cause we should send it as CData to make sure everything works fine if slashes * are included */ public boolean isCData() { return true; } } ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/0000755000175000017500000000000011272632530020774 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/inplaceeditor.jsp0000644000175000017500000000156511252754370024350 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%> Edit me! Edit me! ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/toggle.jsp0000644000175000017500000000451611262371154023002 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    Toggle Tag Demo

    The ajax:toggle tag is the perfect way to implement a rating system or single on/off switch. In addition to the visual, you can also elect to store the value in a hidden form field.

    This tag is fairly simple and could be powerful all at the same time. We envision one could use this in a variety of cases such as checking/unchecking record sets.

    Toggle Using Stars

    AJAX Rating System [${toggleRating}]

    On/Off Toggle [${toggleRatingOnOff}]

    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/displaytag_bug.jsp0000644000175000017500000000350511252754370024520 0ustar twernertwerner<%-- 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. --%> <%@ taglib uri="http://displaytag.sf.net" prefix="display"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%> <%@page import="java.util.Date"%> <%@page import="net.sourceforge.ajaxtags.demo.CarService"%> Last Time Table Refreshed: ${now} ${row.model} ${row.make} Web Page www.${row.make}.com <%-- We just used this for testing. --%>ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/portlet.jsp0000644000175000017500000000424711252754370023217 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    Portlet Tag Demo

    The ajax:portlet tag mimics a true portlet (in the JSR-168 sense) by allowing you to define a portion of the page that pulls content from another location using Ajax with or without a periodic refresh. It expects the resource to return a valid HTML fragment, but not a complete page.

    In the example below, the portlet is set to refresh automatically every 5 seconds. In addition, each of the optional toolbar elements (refresh, sizing, and close) is defined.

    Portlet in Action



    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/formupdate.jsp0000644000175000017500000001030311252754370023662 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    Update Form Field Tag Demo

    The ajax:updateField tag allows you to update one or more form fields based on the value of another single field.

    The example below uses this concept to implement a simple conversion tool.

    Velocity Conversion

    Enter miles per hour and click Calculate

    age and name submit

    Enter your age

    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/WEB-INF/0000755000175000017500000000000011240372226022021 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/WEB-INF/web.xml0000644000175000017500000000731011240372226023321 0ustar twernertwerner AjaxTagsDemo sourceloader net.sourceforge.ajaxtags.servlets.SourceLoader prefix /ajaxtags sourceloader /ajaxtags/js/* sourceloader /img/* sourceloader /css/* autocomplete net.sourceforge.ajaxtags.demo.servlet.AutocompleteServlet 2 autocomplete /autocomplete.view nameinput net.sourceforge.ajaxtags.demo.servlet.NameInput nameinput /nameinput.view dropdown net.sourceforge.ajaxtags.demo.servlet.DropdownServlet 2 dropdown /dropdown.view formupdate net.sourceforge.ajaxtags.demo.servlet.FormUpdateServlet formupdate /formupdate.view callout net.sourceforge.ajaxtags.demo.servlet.CalloutServlet 2 callout /callout.view toggle net.sourceforge.ajaxtags.demo.servlet.ToggleServlet 2 toggle /toggle.view htmlcontent net.sourceforge.ajaxtags.demo.servlet.HtmlContentServlet 2 htmlcontent /htmlcontent.view tree net.sourceforge.ajaxtags.demo.servlet.TreeServlet 2 tree /tree.view index.jsp ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/simple.jsp0000644000175000017500000000160011252754370023005 0ustar twernertwerner<%-- 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. --%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%> <%@page import="java.util.Date" %> <%@page import="net.sourceforge.ajaxtags.demo.CarService"%> Here a simple flush test Last Time Table Refreshed: ${now} ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/bugs/0000755000175000017500000000000011272632612021735 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/bugs/1844205.jsp0000644000175000017500000000502211252754370023305 0ustar twernertwerner<%-- 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. --%> <%-- BUG http://sourceforge.net/tracker/index.php?func=detail&aid=1857214&group_id=140499&atid=746679 --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    Select Tag default selection

    The parameter defaultOptions is now checked in the tag if you didn't pass the selection with the XML file you can set the defaults here with a list like <<Explorer,RX-8>>
    Choose Your Car
    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/bugs/016027.jsp0000644000175000017500000000454211252754370023223 0ustar twernertwerner<%-- 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. --%> <%-- BUG https://developer.berlios.de/bugs/?func=detailbug&bug_id=16027&group_id=10618 --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    AjaxJspTag.Base#buildParameterString

    AjaxJspTag.Base#buildParameterString
    Checkbox with default value
    Checkbox "on"
    Checkbox "true"

    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/bugs/1857214.jsp0000644000175000017500000000345211252754370023316 0ustar twernertwerner<%-- 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. --%> <%-- BUG http://sourceforge.net/tracker/index.php?func=detail&aid=1857214&group_id=140499&atid=746679 --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%> <%@ taglib uri="http://displaytag.sf.net" prefix="display"%> <%@page import="net.sourceforge.ajaxtags.demo.CarService"%> ${row.model} ${row.make} Web Page www.${row.make}.com ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/bugs/index.jsp0000644000175000017500000000745011252754370023574 0ustar twernertwerner<%-- 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. --%> <%-- * Copyright 2008 Jens Kapitza * * 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%> AJAX JSP Tag Library Bugs
    Using Project Version 1.5

    BUGS

    Here are some solutions for some reported bugs

    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/pagearea.jsp0000644000175000017500000000356511252754370023275 0ustar twernertwerner<%-- 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. --%> <%@page language="java" import="java.util.Date"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    Area Tag Demo

    This area should not refresh: Date: ${now}
    Refresh first area >>

    This is the first area and should be refreshed only when the first link or the link inside itself is clicked:
    It include a link to itself
    Date: ${now}


    This area should not refresh: Date: ${now}
    Refresh second area >>

    This is the second area and should be refreshed only when the second link or the link inside itself is clicked:
    Click this link to refresh itself
    Date: ${now}


    This bottom area should not refresh: Date: ${now}
    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/img0/0000755000175000017500000000000011240372226021626 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/img0/honda_logo.gif0000644000175000017500000000257411240372226024436 0ustar twernertwernerGIF89aL  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~!,L H*\ȰÇ#JTXӣ$bԇG67Dvbb$l>w ЯJkp jlBK\0]pADcu#؁Њ vuYA@3hnybG:-Xlđzt_P:1hÔ}3/`&nm٭8L" D5D[lu :U%)X)ylAR0H;MOU[F$$ȓ@^D(1_IX3 A0,ˀ%qG=eNAMA >ٲH &$)$TO:D 5:F39x((CrDĹE\ )G> &8Qb,ȋ;4AԼG:(;Stp?09PLa#ڀ e $)EbP>Q ;CB:Y g15 H-X)8Gp$,Tr Ds0`B @/ F+8"-8԰;ڴ?Tb&k9ʄΜ2[1- ;5)5!;ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/img0/mazda_logo.gif0000644000175000017500000000215611240372226024435 0ustar twernertwernerGIF89aLҿњ@_B?nnma篯{礤0{{{SqqqѼ@/A\\\Aϑ@R@```s"ڝjjjq ժԽMޯCGGGoDݞUUU>?!,L) Ƨ©$F'J )̪ F/پ۪ gn$W,.&MLXGg 2((.=RD s(THS^`DENN@ٰʄ `B8`C `@B:iͤfD@S0A hLP@ & &&L] \H << Ё@-lvQ$< @<=bBC VP``yM 0 #4y@D@r|ԀUfc::aAhИI@ < $T<A- 0Ʀ"%SDQ)T,9e.|2mB@ @N%0B` ؐSdDpH,?QsT 4@JAH1e<t:mTM,% Ι#0@Э9HV`*l0YHtYЃQ 0b6iPIă(@tFGB1D>P0 N!(@,$6J.P H&rj0˷j-#覫.;ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/img0/ford_logo.gif0000644000175000017500000000524011240372226024270 0ustar twernertwernerGIF89aL󇊘KvFõOe&d.}…!]T:%cuy.9i􄘷yVaଶZ Iw|#eEfLJ`z2yk%\*qFmwDfjz7=[im|j8dKPgKkٹ4ßʲU[|'h)yKw:P, G r|bEL2 * 2(&<œ/跣,RN;;a ޘ~sq DL |Cc  ~2 $(CP= ,O2*0F̰0b<8¤2t/p:M( 9!$@ DPX `lw:/< +@(hTs 28K.1܂@$2 2 x@@ЋbDK(A1$r 0B|C;F5+@?q s*c8.1Lr/0|\.QqƄ-vd L/`4XB@#@4fC16G r8c'$2YX,c".|"Pcv0=;C3R$9ava{-0V`ː@ (B xX`o@"ƔO A 46 (p 2@׈\r)0" ؂1^ .1 cF y AT4A R0G;nLJeHP P<j( b]n hs@F 2 uvn@F RԀC0ƈ:6`a@!Ѐ'$0 ddHÁd̃|0@#G C rHX1z @#6 ` F$'pad)!CH@($=01" : MRp !8@,RgSdRB C8^J@ LF X〘J  2 *Mzx 2lB&J4_ PU c r d r E)MZ8@A]@ ]`@DuzX؀4 $A;!, 8.Z3@`  )B 0 7H`Hو͕' !6P'9Z$ %~1[H: IA8S\:W']FoHh-U 9€f7|! @7P%@֧WcWE А<=8ƀЉ\ C Ob=acn(*Xzh^%pP-^{_@ xc'"}4C'3 Đ(zPt 9tЉT_1Pd#؃& PBPdo`aAR ؁P%+P2f]ZDpm,( 6" ;ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/img0/placeholder.gif0000644000175000017500000000156311240372226024604 0ustar twernertwernerGIF89aL  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~!,LM H*\ȰÇ#JHŋ3jȱǏ CIɓ(S\ɲ˗0cʜI͛8sɳϟ@ !;ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/htmlcontent.jsp0000644000175000017500000000616711252754370024070 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    HtmlContent Tag Demo

    The ajax:htmlContent tag fills a content area (e.g., DIV tag) with an HTML fragment from another resource. You may find this tag useful for including blocks of information in a sidebar when the user clicks a link or form field. This tag is a more simplified approach to the ajax:portlet and ajax:tabPanel tags.

    Shown below are three different ways of executing the AJAX event: link, radio button, and select field.

    HtmlContent in Action

    Select by ANCHOR link.

    Select by RADIO option.





    Select by SELECT option.

    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/callout.jsp0000644000175000017500000000357611252754370023175 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    Callout Tag Demo

    The ajax:callout tag is an easy way to attach a callout or popup balloon to any HTML element supporting an onclick event. The style of this callout is fairly flexible, but generally has a header/title, a close link ('X'), and the content itself, of course.

    Callout in Action

    The Hitchhiker's Guide to the Galaxy is a science fiction series written by Douglas Adams (1952 - 2001). The series follows the adventures of Arthur Dent, a hapless Englishman who escapes the destruction of Earth by an alien race called the Vogons with his friend Ford Prefect, an alien from a small planet somewhere in the vicinity of Betelgeuse and researcher for the eponymous guide.

    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/formsubmit.jsp0000644000175000017500000000276411262371154023713 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    Submit Form Tag

    The ajax:submit tag allows you to submit form asynchronously and update page with retrieved answer.

    Velocity Conversion

    Enter miles per hour and click Calculate

    Calculation results
    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/displaytag.jsp0000644000175000017500000000271511252754370023665 0ustar twernertwerner<%-- 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. --%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%> <%@ taglib uri="http://displaytag.sf.net" prefix="display"%> <%@page import="java.util.Date"%>

    DisplayTag Wrapper Demo

    This top area should not refresh:
    Date: ${now}


    No flush here

    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/tree.jsp0000644000175000017500000000221711252754370022460 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>
    You have clicked
    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/css0/0000755000175000017500000000000011240372226021642 5ustar twernertwernerajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/css0/site.css0000644000175000017500000000573011252755026023333 0ustar twernertwerner/** * 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. */ body { margin: 0; font: normal 11pt Verdana, Arial; } a,a:visited { color: #00f; } a:hover { color: #f00; } #header { background-color: #369; padding: 5px; color: #fff; font-weight: bold; } #subheader { font-weight: normal; font-size: 8pt; color: #900; border-bottom: 1px solid #ccc; padding: 1px 5px 2px 5px; } #subheader a,#subheader a:visited { text-decoration: none; color: #900; } #subheader a:hover { text-decoration: underline; color: #000; } #buildVersion { font-weight: normal; font-size: 8pt; color: #999; padding: 1px 5px 1px 5px; } #content { padding: 10px; } h1 { font-size: 1.2em } h2 { font-size: 1.1em } h3 { font-size: 1.0em } h4 { font-size: 0.9em } label { font: bold 1em Verdana; display: block; margin-top: 1em; margin-bottom: 0.25em; } fieldset { width: 500px; border: 1px solid #999; padding: 10px; } legend { padding: 1px 4px; border-color: #999 #ccc #ccc #999; border-style: solid; border-width: 1px; background: #eee; } label { font-size: 0.8em; } input [type="text"] { background-color: #ffd; border-width: 1px; } input [type="button"] { border: 1px solid #999; background-color: #eee; cursor: pointer; color: #000; } #homepageTable { border: 1px solid #ccc; width: 650px; } #homepageTable THEAD TR TH { border-bottom: 2px solid #999; background-color: #eee; } #homepageTable TBODY TR TD:first-child { font-weight: bold; } #homepageTable TBODY TR.description TD { font-size: 90%; font-weight: normal; border-bottom: 1px solid #ccc; padding-bottom: 20px; } FORM.basicForm FIELDSET { width: 80%; border: 1px solid #ccc; padding: 1em; } FORM.basicForm LEGEND { font-size: 0.8em; color: #999; background-color: #eee; border: 1px solid #ccc; padding: 4px 2px; } FORM.basicForm LABEL { display: block; margin-top: 1em; margin-bottom: 0.25em; } FORM.basicForm INPUT { font: normal 12px Verdana, Arial; padding: 3px; } FORM.basicForm INPUT[type="text"] { border: 1px solid #ccc; } FORM.basicForm INPUT[type="text"]:focus { border-color: #000; } #modelDescription { position: absolute; left: 300px; width: 300px; min-height: 100px; background: #ffe; border-style: solid; border-width: 1px; border-color: #666 #ccc #ccc #666; padding: 5px; } #htmlContentForm { width: 350px; } /* --- TAB PANEL CSS --- */ #tabPanelWrapper { width: 600px; } div.textArea { background: #eee; border: 1px dotted silver; } ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/tabpanel.jsp0000644000175000017500000000361611252754370023313 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    Tab Panel Tag Demo

    The ajax:tabPanel tag provides a tabbed page view of content from different resources, typically other JSP or HTML pages. It expects the resource to return a valid HTML fragment, but not a complete page.

    Each panel is defined in a ajax:tab child tag with its own unique URL. The tab panel relies heavily on CSS to structure the panels themselves. The output is generated as an unordered list (<ul>) which works very nicely with the styles cataloged at List-a-Matic.

    Tab Panel in Action

    <%@page import="java.util.Date"%>
    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/dropdown.jsp0000644000175000017500000000544011252754370023356 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    Select Tag Demo

    The ajax:select tag allows one to retrieve a list of values from a backend servlet (or other server-side control) and display them in another HTML select box.

    Here, the example asks the user to select a make from a list of car makers. Once selected, the XMLHttpRequest object calls a servlet to retrieve all models for that make, which are then populated in the second dropdown.

    This example also demonatrates the use of a post-function (written in JavaScript). Post-functions execute after the AJAX piece is finished its work. In this case, we define a post-function to display an image of the car maker.

    Choose Your Car
    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/index.jsp0000644000175000017500000001015611262371154022625 0ustar twernertwerner<%-- 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. --%> <%-- * Copyright 2005 Darren L. Spurgeon * * 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%> <%@page import="java.util.Date"%> AJAX JSP Tag Library Examples
    Using Project Version 1.5

    Demos

    Page loaded at: ${now}

    ajaxtags-1.5.1/ajaxtags-demo/src/main/webapp/autocomplete.jsp0000644000175000017500000000435411252754370024226 0ustar twernertwerner<%-- 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. --%> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="net.sourceforge.ajaxtags.demo.CarService,net.sourceforge.ajaxtags.demo.Car,java.util.Iterator,java.util.List,java.util.ArrayList"%> <%@ taglib uri="http://ajaxtags.sourceforge.net/tags/ajaxtags" prefix="ajax"%>

    Autocomplete Demo

    The ajax:autocomplete tag allows one to retrieve a list of probable values from a backend servlet (or other server-side control) and display them in a dropdown beneath an HTML text input field.

    Enter Car Model

    Available values start with letters: <% for (Iterator it = service.getModelsFirstChar().iterator(); it.hasNext();) { Character firstChar = it.next(); out.append('\'').append(firstChar).append('\''); if (it.hasNext()) { out.append(','); } } %>

    ajaxtags-1.5.1/ajaxtags-demo/src/main/resources/0000755000175000017500000000000011267277642021545 5ustar twernertwerner