cancel
Showing results for 
Search instead for 
Did you mean: 

[solved]use DialogManager bean properties with taglibs

ethan
Champ in-the-making
Champ in-the-making
Hi Smiley Happy

I created an action with a dialog which is supposed to load a graphic timeline component (from the ZK framework). the component must load xml files which are named according to the Space the action is triggered on. I wanted to use the #{DialogManager.bean.name} as I already did for other dialogs but the taglib of the ZK framework doesn't read the value from it.

Here is the code of my jsp page :


<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
<%@ taglib prefix="z" uri="http://www.zkoss.org/jsp/zul'%>

<f:verbatim>
<div id="width:100%; margin-bottom: 20px;"></f:verbatim>
   <h:outputText value="Timeline for the folder : #{DialogManager.bean.name}"/>
<f:verbatim>
</div>
<div></f:verbatim>
   <h:outputLink value="/alfresco/charts/timeline/#{DialogManager.bean.zulFile}" target="_blank"><h:outputText value="Click here to load the timeline."/></h:outputLink>
<f:verbatim>
</div>
</f:verbatim>

<z:page>
   <z:window>
      <z:timeline id="tl1" height="600px" width="850px">
         <z:bandinfo width="7%" id="b2" intervalUnit="year" intervalPixels="50"
            syncWith="b1">
            <z:attribute name="eventSourceUrl">
               /alfresco/charts/timeline/${DialogManager.bean.spacexmlfile}
            </z:attribute>
         </z:bandinfo>         
      </z:timeline>
   </z:window>
</z:page>

the #{DialogManager.bean.name} works fine with the <hSmiley SurprisedutputText> tag but the #{DialogManager.bean.spacexmlfile} is displayed as it (and not its value) inside the <z:attribute> tag.

So I wanted to know if there was a way to convert the #{DialogManager.bean.spacexmlfile} into a jsp variable or if there was a way to use java code inside my jsp page to get the value of the spacexmlfile variable ? Is there a class that could allow me to access the bean properties inside the jsp page?

Thank you Smiley Happy
3 REPLIES 3

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
<z:page>
   <z:window>
      <z:timeline id="tl1" height="600px" width="850px">
         <z:bandinfo width="7%" id="b2" intervalUnit="year" intervalPixels="50"
            syncWith="b1">
<%
DialogManager  dialogManager=(DialogManager) FacesHelper.getmenagedBean("DialogManager");
//you can do it too with, see what works.
YOURDIALOG CLASS  dialogManager=(YOURDIALOG CLASS ) FacesHelper.getmenagedBean("YOURDIALOG FACES NAME");
%>
            <z:attribute name="eventSourceUrl">
               /alfresco/charts/timeline/<%=(dialogManager.getBean.getSpacexmlfile();%>              //this is typed with no eclipse on hand, so sorry if it has some errors , but you get the drill 🙂
            </z:attribute>
         </z:bandinfo>        
      </z:timeline>
   </z:window>
</z:page>

ethan
Champ in-the-making
Champ in-the-making
Thank you for your help Smiley Happy

I think it might work but unfortunately, I discovered the <z:attribute> tag does not allow script and jsp declaration u_u… I read on their website that I could use the <z:zscript> tag to use java code and create variables. Now I have to find how does it work… I'll tell you if I succeed to make it work Smiley Happy

ethan
Champ in-the-making
Champ in-the-making
Hi there Smiley Happy

I finally succeeded in making the code work. Here is the solution (in fact, I had to use the ZK <z:zscript> to make the java code usable by the ZK taglib…) :


<zk:page zscriptLanguage="java">   
    <zk:window>   
      <zk:zscript>
         import java.lang.String;
         import org.alfresco.web.app.servlet.FacesHelper;
         import org.alfresco.web.bean.dialog.DialogManager;
         import javax.faces.context.FacesContext;
         import org.alfresco.custom.dialogs.ShowTimelineDialog;

         FacesContext fc = FacesContext.getCurrentInstance();
         DialogManager dialogManager=(DialogManager) FacesHelper.getManagedBean(fc, "DialogManager");
         ShowTimelineDialog myBean = (ShowTimelineDialog)dialogManager.getBean();
         String eventSourceRes = "/charts/timeline/" + myBean.getEventSourceRes();
         String eventSource = "/charts/timeline/" + myBean.getEventSource();
      </zk:zscript>
      
      <zk:timeline id="tl1" height="600px" width="850px" >
         <zk:bandinfo width="15%" id="b2" intervalUnit="year" intervalPixels="50"
            syncWith="b1" eventSourceUrl="${eventSourceRes}" />
         
         <zk:bandinfo width="85%" id="b1" intervalUnit="month" intervalPixels="100"
            eventSourceUrl="${eventSource}" />
      </zk:timeline>
    </zk:window>
</zk:page>

Thank you for your help, again Smiley Happy