Author: rfelden
Date: Thu Nov 8 17:41:00 2007
New Revision: 19075
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19075&repname=
=3Djahia
Log:
new tag library : JahiaComponents (jahia-components.tld)
and
new navigation menu tag
(used in the new corp v3)
Added:
branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
menus/
branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
menus/NavMenuTag.java
branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/etc/taglibs/j=
ahia-components.tld
Modified:
branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/web.xml
Added: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/ht=
ml/menus/NavMenuTag.java
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/menus/NavMenuTag.j=
ava&rev=3D19075&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-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
menus/NavMenuTag.java (added)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/java/org/jahia/taglibs/html/=
menus/NavMenuTag.java Thu Nov 8 17:41:00 2007
@@ -0,0 +1,368 @@
+/*
+ * Copyright 2002-2006 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.html.menus;
+
+import org.jahia.data.JahiaData;
+import org.jahia.data.beans.ContainerBean;
+import org.jahia.data.beans.ContainerListBean;
+import org.jahia.data.beans.ContentBean;
+import org.jahia.data.beans.RequestBean;
+import org.jahia.data.containers.JahiaContainer;
+import org.jahia.data.containers.JahiaContainerList;
+import org.jahia.exceptions.JahiaException;
+import org.jahia.gui.GuiBean;
+import org.jahia.gui.HTMLToolBox;
+import org.jahia.params.ProcessingContext;
+import org.jahia.registries.ServicesRegistry;
+import org.jahia.services.acl.JahiaACLManagerService;
+import org.jahia.services.acl.JahiaBaseACL;
+import org.jahia.services.pages.JahiaPage;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import java.io.IOException;
+import java.util.Enumeration;
+
+/**
+ * <p>Title: Tag that generates the HTML for the action menu GUI interface=
</p>
+ * <p>Description: this tag is for the moment not very generic but it is
+ * here to help template developers to include easily all the actions for
+ * a given content object without having to know all the possible actions =
for
+ * a specific content object. It also generates the GUI for the locking
+ * information.</p>
+ * <p>Warning: this tag supposses the use of some Javascript functions that
+ * must be declared in the page for this menu to work !</p>
+ * <p>Copyright: Copyright (c) 2002</p>
+ * <p>Company: Jahia Ltd</p>
+ *
+ * @author Serge Huber
+ * @version 1.0
+ * <p/>
+ * jsp:tag name=3D"actionMenu" body-content=3D"tagdependent"
+ * description=3D"Displays the GUI interface for actions on the s=
elected Jahia content object.
+ * <p/>
+ * <p><attriInfo>This tag is for the moment not very generic but =
it is
+ * here to help template developers to easily include all the act=
ions for
+ * a given content object without having to know all the possible=
actions for
+ * a specific content object.
+ * <p>It also generates the GUI for the workflow information.
+ * Content objects may go through intermediate stages of workflow=
before being published live. Usually a
+ * new content object will first go to a \"staging\" state, then =
a \"waiting for validation\" state, and finally
+ * to a \"live\" state if it was accepted, or back to \"staging\"=
state if it was refused.
+ * <p>It also generates the GUI for the locking information.
+ * Content objects are locked to prevent editing either if anothe=
r user is
+ * currently already modifying the same object, or if the object =
or one of it's ancestors is in the \"waiting for validation\"
+ * workflow state.
+ * <p>If the user is not in Edit mode, the GUI interface isn't di=
splay.</p>
+ * <p>Warning: this tag assumes the use of some Javascript functi=
ons pre-declared
+ * in the page for this menu to work !</p>
+ * <p/>
+ * <p><b>Example :</b>
+ * <p/>
+ * <p/>
+ * <p/>
+ * <content:containerList name=3D\"myContainer\" id=3D\"myCont=
ainerList\"> <br>
+ * <content:container id=3D\"myContainer\"=
> <br>
+ * <b> <jahiaHtml:actionMenu=
name=3D\"myContainer\" namePostFix=3D\"\" resourceBundle=3D\"jahiatemplate=
s.Phal_litemplates\"> </b> <br>
+ * <content=
:textField name=3D\"myAuthor\" defaultValue=3D\"\" diffActive=3D\"true\"/&g=
t; | <br>
+ * <content=
:textField name=3D\"myTel\" defaultValue=3D\"\" diffActive=3D\"true\"/>&=
lt;br/> <br>
+ * <br>
+ * </jahiaHtml:actionMenu>=
; <br>
+ * </content:container> <br>
+ * <logic:equal name=3D\"myContainerList\" p=
roperty=3D\"size\" value=3D\"0\"> <br>
+ * <content:addContainerURL =
id=3D\"addmyContainerURL\" display=3D\"false\"/> <br>
+ * <logic:present name=3D\"a=
ddmyContainerURL\"> <br>
+ * <br/>&=
lt;a href=3D\"<bean:write name=3D'addmyContainerURL'/>\">add</a=
> <br>
+ * </logic:present> <br>
+ * </logic:equal> <br>
+ * </content:containerList> <br>
+ * <br> ... <br>
+ * <content:applicationField name=3D\"applicationTest\" id=3D\=
"applicationBean\" /> <br>
+ * <logic:present name=3D\"applicationBean\"> <br>
+ * <logic:present name=3D\"applicationBean\" p=
roperty=3D\"object\"> <br>
+ * <bean:define name=3D\"appli=
cationBean\" property=3D\"object\" id=3D\"portletWindowBean\" /> <br>
+ * <jahiaHtmlportletModes name=
=3D\"portletWindowBean\" /> <br>
+ * <jahiaHtml:windowStates nam=
e=3D\"portletWindowBean\" /> <br>
+ * </logic:present> <br>
+ * </logic:present> <br>
+ * <br /> <br>
+ * <b><jahiaHtml:actionMenu name=3D\"applicationBean\" namePos=
tFix=3D\"\"
+ * resourceBundle=3D\"jahiatemplates.Corporate_portal_templates\"=
useFieldSet=3D\"false\"/></b> <br>
+ * <p/>
+ * </attriInfo>"
+ */
+
+public class NavMenuTag extends BodyTagSupport {
+
+ private static final org.apache.log4j.Logger logger =3D
+ org.apache.log4j.Logger.getLogger(org.jahia.taglibs.html.menus=
.NavMenuTag.class);
+
+ private JahiaData jData =3D null ;
+ private String containerListName =3D null;
+ private String pageFieldName =3D null;
+ private int startLevel =3D -1 ;
+ private int maxDepth =3D -1 ;
+ private int dispNumber =3D -1 ;
+ private boolean expandOnlyPageInPath =3D true ;
+ private boolean onlyTop =3D false ;
+ private String bundleKey =3D null;
+ private String containerListNamePostFix =3D null;
+ private String containerNamePostFix =3D null;
+ private String containerListLabel =3D null ;
+ private int reqLevel =3D -1 ;
+
+ private boolean editMode ;
+
+ public NavMenuTag() {
+ }
+
+ public String getContainerListName() {
+ return containerListName;
+ }
+
+ public void setContainerListName(String containerListName) {
+ this.containerListName =3D containerListName;
+ }
+
+ public String getPageFieldName() {
+ return pageFieldName;
+ }
+
+ public void setPageFieldName(String pageFieldName) {
+ this.pageFieldName =3D pageFieldName;
+ }
+
+ public int getStartLevel() {
+ return startLevel;
+ }
+
+ public void setStartLevel(int startLevel) {
+ this.startLevel =3D startLevel;
+ }
+
+ public int getMaxDepth() {
+ return maxDepth;
+ }
+
+ public void setMaxDepth(int maxDepth) {
+ this.maxDepth =3D maxDepth;
+ }
+
+ public int getDispNumber() {
+ return dispNumber;
+ }
+
+ public void setDispNumber(int dispNumber) {
+ this.dispNumber =3D dispNumber;
+ }
+
+ public boolean isExpandOnlyPageInPath() {
+ return expandOnlyPageInPath;
+ }
+
+ public void setExpandOnlyPageInPath(boolean expandOnlyPageInPath) {
+ this.expandOnlyPageInPath =3D expandOnlyPageInPath;
+ }
+
+ public boolean isOnlyTop() {
+ return onlyTop;
+ }
+
+ public void setOnlyTop(boolean onlyTop) {
+ this.onlyTop =3D onlyTop;
+ }
+
+ public String getBundleKey() {
+ return bundleKey;
+ }
+
+ public void setBundleKey(String bundleKey) {
+ this.bundleKey =3D bundleKey;
+ }
+
+ public String getContainerListNamePostFix() {
+ return containerListNamePostFix;
+ }
+
+ public void setContainerListNamePostFix(String containerListNamePostFi=
x) {
+ this.containerListNamePostFix =3D containerListNamePostFix;
+ }
+
+ public String getContainerNamePostFix() {
+ return containerNamePostFix;
+ }
+
+ public void setContainerNamePostFix(String containerNamePostFix) {
+ this.containerNamePostFix =3D containerNamePostFix;
+ }
+
+ public String getContainerListLabel() {
+ return containerListLabel;
+ }
+
+ public void setContainerListLabel(String containerListLabel) {
+ this.containerListLabel =3D containerListLabel;
+ }
+
+ public int doStartTag() {
+ final RequestBean requestBean =3D (RequestBean) pageContext.findAt=
tribute("currentRequest");
+ ServletRequest request =3D pageContext.getRequest();
+ jData =3D (JahiaData) request.getAttribute("org.jahia.data.JahiaDa=
ta");
+ editMode =3D requestBean.isEditMode() ;
+ try {
+ defaultSettings(jData.gui());
+ getPageSubTree(jData, jData.gui().getLevelID(startLevel), star=
tLevel);
+ } catch (JahiaException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return EVAL_BODY_BUFFERED;
+ }
+
+ private void defaultSettings(GuiBean gui) throws JahiaException {
+ reqLevel =3D gui.getLevel() ;
+ logger.debug("reqLevel =3D " + reqLevel);
+ // if the startLevel parameter is not specified, try to find a sim=
ilar
+ // containerList in the parent page
+ if (startLevel =3D=3D -1) {
+ if (reqLevel =3D=3D 1) {
+ startLevel =3D reqLevel ;
+ } else {
+ JahiaContainerList linkContainerList =3D jData.containers(=
).getAbsoluteContainerList(containerListName, jData.gui().getLevelID(reqLev=
el-1)) ;
+ if (linkContainerList !=3D null) {
+ startLevel =3D reqLevel - 1 ;
+ } else {
+ startLevel =3D reqLevel ;
+ }
+ }
+ }
+ /*if (dispNumber =3D=3D -1)
+ dispNumber =3D 1 ;
+ if (maxDepth =3D=3D -1)
+ maxDepth =3D 1 ;*/
+ }
+
+ private void getPageSubTree(JahiaData jData, int pageId, int level) th=
rows JahiaException, IOException {
+ if (pageId =3D=3D -1) return ; // TODO handle this case better
+
+ JspWriter out =3D pageContext.getOut();
+
+ ProcessingContext jParams =3D jData.getProcessingContext() ;
+ JahiaContainerList linkContainerList =3D jData.containers().getAbs=
oluteContainerList(containerListName, pageId) ;
+ =
+ Enumeration linkContainerEnum =3D linkContainerList.getContainers(=
);
+ boolean begin =3D true ;
+
+ // don't display the links if they are supposed to be hidden (live=
mode)
+ boolean hide =3D (dispNumber !=3D -1 && level !=3D startLevel && =
level !=3D reqLevel && level + dispNumber < reqLevel && !editMode) ;
+
+ //
+ if (maxDepth =3D=3D -1 || level <=3D startLevel + maxDepth) {
+ while (linkContainerEnum.hasMoreElements()) {
+ logger.debug("level =3D " + level);
+ JahiaContainer linkContainer =3D (JahiaContainer) linkCont=
ainerEnum.nextElement();
+ JahiaPage link =3D (JahiaPage) linkContainer.getFieldObjec=
t(pageFieldName);
+
+
+
+ if (link !=3D null) {
+ if (!hide) {
+ if (begin) {
+ out.println("<ul>");
+ begin =3D false ;
+ }
+ String cssClass =3D " class=3D'navmenu_standard'";
+ if (jData.gui().isPageInPath(link.getID()))
+ if (level =3D=3D reqLevel-1) {
+ cssClass =3D " class=3D'navmenu_selected'"=
;
+ } else {
+ cssClass =3D " class=3D'navmenu_inpath'" ;
+ }
+ StringBuffer sbf =3D new StringBuffer() ;
+ sbf.append("<li").append(cssClass).append("><a hre=
f=3D'").append(link.getURL(jParams)).append("'");
+ sbf.append(" title=3D'").append(link.getTitle()).a=
ppend("' >");
+ sbf.append("<span>").append(link.getHighLightDiffT=
itle(jParams)).append("</span></a>");
+ out.println(sbf.toString()) ;
+ if (editMode) {
+ jData.gui().html().drawBeginActionMenu(new Con=
tainerBean(linkContainer,jParams),
+ null, null, false, "", bundleKey, null, ou=
t);
+ }
+ }
+
+ // displays sub links
+ if (!onlyTop && (!expandOnlyPageInPath || jData.gui().=
isPageInPath(link.getID()))) {
+ getPageSubTree(jData, link.getID(), level+1);
+ }
+ if (!hide) out.println("</li>");
+
+ } else { // TODO OOOOOO
+ // no navlink
+ if (editMode) {
+ if (begin) {
+ out.println("<ul>");
+ begin =3D false ;
+ }
+ out.println("<li>");
+ out.print("<a href=3D'' class=3D'link" + level + "=
'>n.d.</a>");
+ jData.gui().html().drawBeginActionMenu(new Contain=
erBean(linkContainer,jParams),
+ null, null, false, containerNamePostFix, bundl=
eKey, "add.navigationLinks", out);
+ out.println("</li>");
+ }
+ }
+ }
+ }
+
+ if (editMode) {
+ if (begin) {
+ out.print(new StringBuffer().append("<ul class=3D'nav").ap=
pend((level =3D=3D 1) ? "2edit" : "3").append("'>").toString());
+ }
+ out.print("<li>");
+ jData.gui().html().drawBeginActionMenu(new ContainerListBean(l=
inkContainerList,jData.params()),
+ null, null, false, containerListNamePostFix, bundleKey, co=
ntainerListLabel, out);
+ out.println(new StringBuffer("</li>").append((begin?"</ul>":""=
)).toString());
+ }
+
+ if (!begin && !hide) {
+ out.println("</ul>");
+ }
+
+
+
+ }
+
+ public int doEndTag() throws JspException {
+ // let's reinitialize the tag variables to allow tag object reuse =
in
+ // pooling.
+ expandOnlyPageInPath =3D true ;
+ onlyTop =3D false ;
+ reqLevel =3D -1 ;
+ startLevel =3D -1 ;
+ dispNumber =3D -1 ;
+ maxDepth =3D -1 ;
+ jData =3D null ;
+ containerListName =3D null;
+ pageFieldName =3D null;
+ bundleKey =3D null;
+ containerListNamePostFix =3D null;
+ containerNamePostFix =3D null;
+ return EVAL_PAGE;
+ }
+}
\ No newline at end of file
Added: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/etc/taglib=
s/jahia-components.tld
URL: https://svndev.jahia.net/websvn/filedetails.php?path=3D/branches/JAHIA=
-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/etc/taglibs/jahia-components.tl=
d&rev=3D19075&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-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/etc/taglibs/j=
ahia-components.tld (added)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/etc/taglibs/j=
ahia-components.tld Thu Nov 8 17:41:00 2007
@@ -0,0 +1,84 @@
+<?xml version=3D"1.0" encoding=3D"ISO-8859-1" ?>
+<!DOCTYPE taglib
+ PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
+ "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
+
+<!-- a tag library descriptor -->
+
+<taglib>
+<!-- after this the default space is
+"http://java.sun.com/j2ee/dtds/jsptaglibrary_1_2.dtd"
+-->
+
+ <tlibversion>2.0</tlibversion>
+ <jspversion>1.1</jspversion>
+ <shortname>Jahia Components Tag Library</shortname>
+ <info>
+ Provides a tag library for Jahia UI components
+ </info>
+
+ <tag>
+ <name>navmenu</name>
+ <tagclass>org.jahia.taglibs.html.menus.NavMenuTag</tagclass>
+ <info>display a navigation menu</info>
+
+ <attribute>
+ <name>containerListName</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>pageFieldName</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>startLevel</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>maxDepth</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>dispNumber</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>expandOnlyPageInPath</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>onlyTop</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>bundleKey</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>containerListNamePostFix</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>containerNamePostFix</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>containerListLabel</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+
+
+ </tag>
+
+</taglib>
\ No newline at end of file
Modified: branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/web.xml
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-INCLUD=
E-TAG-BRANCH/core/src/webapp/WEB-INF/web.xml&rev=3D19075&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-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/web.xml (orig=
inal)
+++ branches/JAHIA-INCLUDE-TAG-BRANCH/core/src/webapp/WEB-INF/web.xml Thu N=
ov 8 17:41:00 2007
@@ -1326,6 +1326,10 @@
<taglib-location>/WEB-INF/etc/taglibs/jahia-html.tld</taglib-locat=
ion>
</taglib>
<taglib>
+ <taglib-uri>jahiaComponentsLib</taglib-uri>
+ <taglib-location>/WEB-INF/etc/taglibs/jahia-components.tld</taglib=
-location>
+ </taglib>
+ <taglib>
<taglib-uri>ajaxLib</taglib-uri>
<taglib-location>/WEB-INF/etc/taglibs/ajax.tld</taglib-location>
</taglib>
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list