03-09-2011 12:33 PM
 
					
				
		
03-11-2011 07:07 AM
03-14-2011 08:47 AM
public class UIAjaxFileAssocPicker extends BaseAjaxItemPicker
{
   /** list of mimetypes to restrict the available file list */
   private String mimetypes = null;
   private String type = null;
   
   @Override
   public String getFamily()
   {
      return "org.alfresco.faces.AjaxFileAssocPicker";
   }
   
      /**
    * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object)
    */
   public void restoreState(FacesContext context, Object state)
   {
      Object values[] = (Object[])state;
      super.restoreState(context, values[0]);
      this.mimetypes = (String)values[1];
      this.type = (String)values[2];
   }
   
   /**
    * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
    */
   public Object saveState(FacesContext context)
   {
      Object values[] = new Object[] {
         super.saveState(context),
         this.mimetypes,
         this.type};
      return values;
   }
   @Override
   protected String getServiceCall()
   {
      return "EditContentPropertiesDialog.getFileFolderNodes";
   }
   @Override
   protected String getDefaultIcon()
   {
      // none required - we always return an icon name in the service call
      return null;
   }
   
   @Override
   protected String getRequestAttributes()
   {
      String mimetypes = getMimetypes();
      String type = getType();
      String string = null;
      if (mimetypes != null)
      {
         string = "mimetypes=" + URLEncoder.encode(mimetypes);
      }
      if (type != null)
      {
         if(string != null && string.length() > 0){
            string += " types=" + URLEncoder.encode(type);
         }else{
            string = " types=" + URLEncoder.encode(type);
         }
      }
      return string;
   }
   
   
   // ——————————————————————————
   // Strongly typed component property accessors
   
   /**
    * @return Returns the mimetypes to restrict the file list.
    */
   public String getMimetypes()
   {
      ValueBinding vb = getValueBinding("mimetypes");
      if (vb != null)
      {
         this.mimetypes = (String)vb.getValue(getFacesContext());
      }
      
      return this.mimetypes;
   }
   
   /**
    * @param mimetypes The mimetypes restriction list to set.
    */
   public void setMimetypes(String mimetypes)
   {
      this.mimetypes = mimetypes;
   }
   
   public String getType()
   {
      ValueBinding vb = getValueBinding("type");
      if (vb != null)
      {
         this.type = (String)vb.getValue(getFacesContext());
      }
      
      return this.type;
   }
   
   public void setType(String type)
   {
      this.type = type;
   }
}
public class AjaxFileAssocSelectorTag extends AjaxItemSelectorTag
{
   /**
    * @see javax.faces.webapp.UIComponentTag#getComponentType()
    */
   public String getComponentType()
   {
      return "org.alfresco.faces.AjaxFileAssocPicker";
   }
   
   /**
    * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
    */
   protected void setProperties(UIComponent component)
   {
      super.setProperties(component);
      setStringProperty(component, "mimetypes", this.mimetypes);
      setStringProperty(component, "type", this.type);
   }
   
   /**
    * @see org.alfresco.web.ui.common.tag.HtmlComponentTag#release()
    */
   public void release()
   {
      super.release();
      this.mimetypes = null;
      this.type = null;
   }
   
   /**
    * Set the mimetypes
    *
    * @param mimetypes     the mimetypes
    */
   public void setMimetypes(String mimetypes)
   {
      this.mimetypes = mimetypes;
   }
   
   public void setType(String type)
   {
      this.type = type;
   }
   /** the mimetypes */
   private String mimetypes;
   private String type;
}
<component>
      <component-type>org.alfresco.faces.AjaxFileAssocPicker</component-type>
      <component-class>org.alfresco.module.assocSelector.ui.UIAjaxFileAssocPicker</component-class>
 </component>
<tag>
      <name>ajaxFileAssocSelector</name>
      <tag-class>org.alfresco.module.assocSelector.ui.tag.AjaxFileAssocSelectorTag</tag-class>
      <body-content>JSP</body-content>
      
      <attribute>
         <name>id</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      
      <attribute>
         <name>binding</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      
      <attribute>
         <name>rendered</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      
      <attribute>
         <name>style</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      
      <attribute>
         <name>styleClass</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      
      <attribute>
         <name>value</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>label</name>
         <required>true</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      <attribute>
         <name>initialSelection</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      
      <attribute>
         <name>singleSelect</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      
      <attribute>
         <name>disabled</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      
      <attribute>
         <name>height</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      
      <attribute>
         <name>mimetypes</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
      
      <attribute>
         <name>type</name>
         <required>false</required>
         <rtexprvalue>true</rtexprvalue>
      </attribute>
   </tag><h:panelGrid columns="2" style="padding-top: 4px; padding-bottom: 4px;"
             width="100%">
             
       <h:outputLabel for="multi-associations-selector" value="#{msj.frasRelacionadas}"/>
 
      <r:multiValueSelector id="multi-associations-selector"
                               value="#{DialogManager.bean.associations}"
                               lastItemAdded="#{DialogManager.bean.fileAssocAdded}"
                               selectItemMsg="#{msj.select_fras_assoc}"
                               selectedItemsMsg="#{msj.selected_fras_assoc}"
                               noSelectedItemsMsg="#{msg.no_selected_fras}"
                               styleClass="multiValueSelector">
            <f:subview id="associationSelector">
               <r:ajaxFileAssocSelector id="associations"
                  value="#{DialogManager.bean.fileAssocAdded}"
                  label="#{msj.select_fras_assoc}"
                  initialSelection="#{NavigationBean.currentNode.nodeRefAsString}"
                  mimetypes="application/pdf"
                  type="{FacturaModel.model}facturas"
                  styleClass="selector"
                  singleSelect="true"
                  height="105px" />
           
            </f:subview>
      </r:multiValueSelector>
   </h:panelGrid>
Set<String> types = null;
         String typeParam = (String)params.get("type");
         System.out.println("typeParam " + typeParam);
         if (typeParam != null && typeParam.length() != 0)
         {
            // convert to a set of types to test each file against
            types = new HashSet<String>();
            for (StringTokenizer t = new StringTokenizer(typeParam, ","); t.hasMoreTokens(); /**/)
            {
               types.add(t.nextToken());
            }
         }
 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.