Author: sshyrkov
Date: Wed Jan 23 17:22:22 2008
New Revision: 19571
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19571&repname=
=3Djahia
Log:
Added <jcr:node-types/> tag for iterating over all available node types
Added:
branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/jcr/file/NodeTypesTag.java
Modified:
branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/webapp/WEB-INF/etc/=
taglibs/jcr.tld
Added: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/t=
aglibs/jcr/file/NodeTypesTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/taglibs/jcr/file/NodeT=
ypesTag.java&rev=3D19571&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/jcr/file/NodeTypesTag.java (added)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/tagl=
ibs/jcr/file/NodeTypesTag.java Wed Jan 23 17:22:22 2008
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2002-2007 Jahia Ltd
+ *
+ * Licensed under the JAHIA COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (J=
CDDL), =
+ * Version 1.0 (the "License"), or (at your option) any later version; you=
may =
+ * not use this file except in compliance with the License. You should hav=
e =
+ * received a copy of the License along with this program; if not, you may=
obtain =
+ * a copy of the License at =
+ *
+ * http://www.jahia.org/license/
+ *
+ * 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 org.jahia.taglibs.jcr.file;
+
+import java.util.Iterator;
+
+import javax.jcr.RepositoryException;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+
+import org.jahia.registries.ServicesRegistry;
+
+/**
+ * Tag iterates over all available node types.
+ * =
+ * @author Sergiy Shyrkov
+ */
+public class NodeTypesTag extends BodyTagSupport {
+
+ private String id =3D "type";
+
+ private Iterator<String> typeIterator;
+
+ @Override
+ public int doAfterBody() throws JspException {
+ if (!typeIterator.hasNext()) {
+ return SKIP_BODY;
+ }
+
+ putNextItem();
+
+ return EVAL_BODY_AGAIN;
+ }
+
+ @Override
+ public int doEndTag() throws JspException {
+ id =3D "type";
+ typeIterator =3D null;
+
+ return EVAL_PAGE;
+ }
+
+ @Override
+ public int doStartTag() throws JspException {
+ try {
+ typeIterator =3D ServicesRegistry.getInstance().getJCRStoreSer=
vice()
+ .getMainStoreProvider().getAvailableTypes().iterator();
+ } catch (RepositoryException e) {
+ throw new JspException(e);
+ }
+
+ if (!typeIterator.hasNext()) {
+ return SKIP_BODY;
+ }
+
+ putNextItem();
+
+ return EVAL_BODY_INCLUDE;
+ }
+
+ private void putNextItem() throws JspException {
+ try {
+ pageContext.setAttribute(id, ServicesRegistry.getInstance()
+ .getJCRStoreService().getMainStoreProvider().getNodeTy=
pe(
+ typeIterator.next()));
+ } catch (RepositoryException e) {
+ throw new JspException(e);
+ }
+ }
+
+ public void setId(String id) {
+ this.id =3D id;
+ }
+
+}
Modified: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/webapp/WEB-IN=
F/etc/taglibs/jcr.tld
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-3-=
DMS-JACKRABBIT-BRANCH/core/src/webapp/WEB-INF/etc/taglibs/jcr.tld&rev=3D195=
71&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/webapp/WEB-INF/etc/=
taglibs/jcr.tld (original)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/webapp/WEB-INF/etc/=
taglibs/jcr.tld Wed Jan 23 17:22:22 2008
@@ -67,6 +67,17 @@
</attribute>
</tag>
=
+ <tag>
+ <name>node-types</name>
+ <tagclass>org.jahia.taglibs.jcr.file.NodeTypesTag</tagclass>
+ <info>Iterates over all available node types</info>
+ <attribute>
+ <name>id</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+ =
<tag>
<name>node-type</name>
<tagclass>org.jahia.taglibs.jcr.file.NodeTypeTag</tagclass>
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list