Jahia DX > tags in jahia

0 (0 Good)
0 (0 Bad)

tags in jahia

by  oumina »  2013/07/13 10:48

how to developp or extends jahia  tags 

  (oumina)

Number of messages  6
Registration date
0 (0 Good)
0 (0 Bad)

issue dependencies maven for jahia tags

by  oumina »  2013/07/13 10:58

Hello ,

 

when we developp  a tag  jahia for workflows

class   java  of  a tag :  

public class TasksForUser extends AbstractJahiaTag {  }
a tld file :
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                            http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<description>Provides tags for workflows in saril</description>
<display-name>Saril Workflow Tag Library</display-name>
<tlib-version>1.0</tlib-version>
<short-name>taches</short-name>
<uri>http://www.saril.lorraine.eu/tags/taches</uri>
<tag>
<tag>
<description>Exposes the possible tasks for the specified user</description>
<name>tasksdeuser</name>
<tag-class>com.taches.taglib.TasksForUserTag</tag-class>
<body-content>empty</body-content>
<attribute>
<name>user</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<type>org.jahia.services.usermanager.JahiaUser</type>
</attribute>
<attribute>
<name>var</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>locale</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib >
 
 

to  avoid  this  issue  in jahia developpement tags :

Caused by: java.lang.VerifyError: (class: org/apache/jsp/errors/error_005f401_jsp, method: _jspx_meth_ui_005floginArea_005f0 signature: (Ljavax/servlet/jsp/PageContext;)Z) Incompatible argument to function
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
        at java.lang.Class.getConstructor0(Class.java:2699)
        at java.lang.Class.newInstance0(Class.java:326)
        at java.lang.Class.newInstance(Class.java:308)
        at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:150)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 you should  add  in pom.xml this :
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
 
good luck .

  (oumina)

Number of messages  6
Registration date
0 (0 Good)
0 (0 Bad)

tag jahia to display a tasks of an user

by  oumina »  2013/07/13 11:02

Hello,

for  developping  your own taglib to display workflows of an user .

this  is a class of a tag

 

package com.taches.taglib;
 
import org.slf4j.Logger;
import org.apache.taglibs.standard.tag.common.core.Util;
import org.jahia.services.usermanager.JahiaUser;
import org.jahia.services.workflow.*;
import org.jahia.taglibs.AbstractJahiaTag;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import java.util.List;
import java.util.Locale;
 
public class WorkflowsParUserTag extends AbstractJahiaTag {
    private final static Logger logger = org.slf4j.LoggerFactory.getLogger(WorkflowsParUserTag.class);
    private JahiaUser user ;
    private String var;
    private int scope = PageContext.PAGE_SCOPE;
    private Locale locale;
 
    public int doEndTag() throws JspException {
        List<Workflow> wfs = WorkflowService.getInstance().getWorkflowsForUser(user,  locale != null ? locale : getUILocale());
        pageContext.setAttribute(var, wfs, scope);
        user = null;
        var = null;
        scope = PageContext.PAGE_SCOPE;
        return super.doEndTag();
    }
 
   public void setUser(JahiaUser user) {
       this.user = user;
   }
 
    public void setVar(String var) {
        this.var = var;
    }
 
    public void setScope(String scope) {
        this.scope = Util.getScope(scope);
    }
 
    public void setLocale(Locale locale) {
        this.locale = locale;
    }
}

a   tags.tld 

<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                            http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
        version="2.0">
    <description>Provides tags for workflows in saril</description>
    <display-name>exemple Workflow Tag Library</display-name>
    <tlib-version>1.0</tlib-version>
    <short-name>taches</short-name>
    <uri>http://com.ensa.ma/tags/tags</uri>
    <tag>
        <description>Exposes the active workflows for the specified user.</description>
        <name>workflowParUser</name>
        <tag-class>com.taches.taglib.WorkflowsParUserTag</tag-class>
        <body-content>empty</body-content>
        <attribute>
            <name>user</name>
            <required>false</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>var</name>
            <required>true</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>scope</name>
            <required>false</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
        <attribute>
            <name>locale</name>
            <required>false</required>
            <rtexprvalue>true</rtexprvalue>
        </attribute>
    </tag>
</taglib>

in my page  jsp i have this :

<taches:workflowParUser user="${renderContext.user}" var="userWorkflows"  locale="${currentResource.locale}" />
<c:forEach items="${userWorkflows}" var="currentuserWorkflow">
    ${currentuserWorkflow}
</c:forEach>
good luck
 

 

  (oumina)

Number of messages  6
Registration date
Contact
Share
Feedback

Get in touch

Whether you are a current user or if you are just evaluating Jahia, we are here to help.

Contact us

Share this page