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());
}
}
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.