cancel
Showing results for 
Search instead for 
Did you mean: 

display document name in dialog?

targa2000
Champ in-the-making
Champ in-the-making
I'm trying to display the document name in a dialog. 

tried different ways, but can't seem to get it.  Any help?

here's what I have tried:

in my .jsp
<hSmiley SurprisedutputText value="Document Name: " />
<hSmiley SurprisedutputText value="#{BrowseBean.document.name}: " />
<hSmiley SurprisedutputText value="Node Name: " />
<hSmiley SurprisedutputText value="#{DialogManager.bean.node_name}: " />

BrowseBean.document.name returns nothing. 

I get an error using DialogManager.bean.node_name.  I overrid the init() in  BaseDialogBean:

   @Override
   public void init(java.util.Map parameters) {   
      // get the space the action will apply to
      node_name = this.browseBean.getDocument().getName();
      
   }

returned java.lang.NullPointerException
6 REPLIES 6

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
I do not understand you too well, but you should add parameter to pass to dialog.

if you have action to initiate dialog you should add
<params>
               <param name="ref">#{actionContext.nodeRef}</param>
            </params>


 public void ethod(ActionEvent actionEvent) {

   UIActionLink link = (UIActionLink) actionEvent.getComponent();
   Map<String, String> params = link.getParameterMap();
   String ref = params.get("ref");
   NodeRef nodeRef = new NodeRef(ref);



    }



   <action id="someid">
            <label-id>domelabel</label-id>
            <image>/images/icons/someimg.gif
            </image>
            <action-listener>#{TetsBean.ethod}
            </action-listener>
<action>dialog:yourdialog</action>
            <params>
               <param name="ref">#{actionContext.nodeRef}</param>
            </params>
         </action>

So how this works:

on click dialog opens, but before action listeer is called and you set values up.

then add in your bean:

String name
getName
setname

and in your jsp put <hSmiley Surprisedutput…. value =#{  DialogManager.bean.name}….

targa2000
Champ in-the-making
Champ in-the-making
Thank you very much for your reply!!

I do not understand you too well

I'm opening a dialog while displaying document details.  I wanted to display the document name from the document properties of the node selected in the dialog that is opened.  


, but you should add parameter to pass to dialog.  if you have action to initiate dialog you should add
<params>
               <param name="ref">#{actionContext.nodeRef}</param>
            </params>

Okay.

 public void ethod(ActionEvent actionEvent) {

   UIActionLink link = (UIActionLink) actionEvent.getComponent();
   Map<String, String> params = link.getParameterMap();
   String ref = params.get("ref");
   NodeRef nodeRef = new NodeRef(ref);



    }



   <action id="someid">
            <label-id>domelabel</label-id>
            <image>/images/icons/someimg.gif
            </image>
            <action-listener>#{TetsBean.ethod}
            </action-listener>
<action>dialog:yourdialog</action>
            <params>
               <param name="ref">#{actionContext.nodeRef}</param>
            </params>
         </action>

So how this works:

on click dialog opens, but before action listeer is called and you set values up.

then add in your bean:

String name
getName
setname

and in your jsp put <hSmiley Surprisedutput…. value =#{  DialogManager.bean.name}….

Okay I made the changes and it compiles and runs.  But the name of the document is not displaying.  My dialog .jsp :

 
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<h:panelGrid>                         
<h:outputText value="Name: " />
<h:outputText value="#{DialogManager.bean.node_name}"/>
<h:outputText value="Creator: " />
<h:outputText value="#{DialogManager.bean.node_creator}"/>
</h:panelGrid>

targa2000
Champ in-the-making
Champ in-the-making
entries from my web-client-config-custom.xml:


<!– sushi view –>
<action id="sushi_view">
<label>Open Sushi View Dialog</label>
<image>/images/icons/sushi_view_image.gif</image>
<action-listener>#{SushiViewDialog.nodeMethod}</action-listener>
  <action>dialog:sushiView</action>
  <params>
     <param name="ref">#{actionContext.nodeRef}</param>
  </params>            
</action>

<config>
     <dialogs>
         <dialog name="sushiView" page="/jsp/extension/dialogs/sushi-view.jsp" managed-bean="sushiViewDialog"
                    icon="/images/icons/Sushi_1.gif" title="Sushi View"
                    description="Displays sushi info" />                            
     </dialogs>
</config>

faces-config-custom.xml entry:

   
<managed-bean>
      <description>
         The bean that backs up the Sushi View Dialog
      </description>   
   <managed-bean-name>SushiViewDialog</managed-bean-name>
   <managed-bean-class>com.sushi.web.bean.SushiViewDialog</managed-bean-class>
   <managed-bean-scope>session</managed-bean-scope>
   <managed-property>
         <property-name>nodeService</property-name>
      <value>#{NodeService}</value>
   </managed-property>
   <managed-property>
        <property-name>browseBean</property-name>
      <value>#{BrowseBean}</value>
   </managed-property>
   <managed-property>
       <property-name>actionService</property-name>
      <value>#{ActionService}</value>
   </managed-property>   
  </managed-bean>

targa2000
Champ in-the-making
Champ in-the-making
and my dialog:

package com.sushi.web.bean;

import java.util.Map;

import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.ScriptActionExecuter;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.component.UIActionLink;

/**
* Bean implementation for "Sushi Overview Dialog"
*
*/
public class SushiViewDialog extends BaseDialogBean {
   
   protected String node_name;
   protected String node_creator;
   
   private ActionService actionService;
   private NodeService nodeService;
   private BrowseBean browseBean;
   
   
   public void nodeMethod(ActionEvent event) {
      
      UIActionLink link = (UIActionLink)event.getComponent();
      Map<String, String> params = link.getParameterMap();
      String ref = params.get("ref");
      NodeRef nodeRef = new NodeRef(ref);
     
       String node_name = (String)this.getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME);
       String node_creator = (String)this.getNodeService().getProperty(nodeRef, ContentModel.PROP_CREATOR);
  
   }
   
   @Override
   protected String finishImpl(FacesContext context, String outcome) throws Exception {
           
      // return the default outcome
      return outcome;
   }
   
   public void setActionService(ActionService actionService) {
      this.actionService = actionService;
   }

   public String getNode_name() {
      return node_name;
   }

   public void setNode_name(String node_name) {
      this.node_name = node_name;
   }

   public BrowseBean getBrowseBean() {
      return browseBean;
   }

   public void setBrowseBean(BrowseBean browseBean) {
      this.browseBean = browseBean;
   }

   public String getNode_creator() {
      return node_creator;
   }

   public void setNode_creator(String node_creator) {
      this.node_creator = node_creator;
   }

   public NodeService getNodeService() {
      return nodeService;
   }

   public void setNodeService(NodeService nodeService) {
      this.nodeService = nodeService;
   }

   public ActionService getActionService() {
      return actionService;
   }
}

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
 String node_name = (String)this.getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME);

Node node=new Node(nodeRef);
   node.getName();

try this. and check what ref value is. this should work fine.

targa2000
Champ in-the-making
Champ in-the-making
Thanks for your reply again!!

 String node_name = (String)this.getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME);

Node node=new Node(nodeRef);
   node.getName();

try this. and check what ref value is. this should work fine.

I see the error I made :

     
       String node_name = (String)this.getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME);
       String node_creator = (String)this.getNodeService().getProperty(nodeRef, ContentModel.PROP_CREATOR);

should be :

     
       node_name = (String)this.getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME);
       node_creator = (String)this.getNodeService().getProperty(nodeRef, ContentModel.PROP_CREATOR);

this works fine!  Not enough sleep!