07-20-2010 07:07 AM
07-21-2010 03:05 AM
package org.alfresco.sample;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.util.ParameterCheck;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.content.AddContentDialog;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Node;
@SuppressWarnings({"serial", "unchecked"})
public class CustomAddContentDialog extends AddContentDialog{
protected Node node;
protected NodeRef addedCategory;
protected List categories;
protected String description;
@Override
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.categories = null;
this.addedCategory = null;
String nodeRef = (String)parameters.get("nodeRef");
ParameterCheck.mandatoryString("nodeRef", nodeRef);
this.node = new Node(new NodeRef(nodeRef));
FacesContext context = FacesContext.getCurrentInstance();
if (getDictionaryService().isSubClass(this.node.getType(), ContentModel.TYPE_FOLDER))
{
this.description = Application.getMessage(context, "editcategory_space_description");
}
else
{
this.description = Application.getMessage(context, "editcategory_description");
}
}
public boolean getFinishButtonDisabled()
{
return false;
}
public String getContainerTitle()
{
return Application.getMessage(FacesContext.getCurrentInstance(), "modify_categories_of") + " '" + this.node.getName() + "'";
}
public String getContainerDescription()
{
return this.description;
}
protected String getErrorMessageId()
{
return "error_update_category";
}
public List getCategories()
{
if (this.categories == null)
{
this.categories = ((List)getNodeService().getProperty(this.node.getNodeRef(), ContentModel.PROP_CATEGORIES));
}
return this.categories;
}
public void setCategories(List categories)
{
this.categories = categories;
}
public NodeRef getAddedCategory()
{
return this.addedCategory;
}
public void setAddedCategory(NodeRef addedCategory)
{
this.addedCategory = addedCategory;
}
@Override
protected String finishImpl(FacesContext context, String outcome)
throws Exception {
outcome = super.finishImpl(context, outcome);
Map updateProps = getNodeService().getProperties(this.node.getNodeRef());
updateProps.put(ContentModel.PROP_CATEGORIES, (Serializable)this.categories);
getNodeService().setProperties(this.node.getNodeRef(), updateProps);
return outcome;
}
}
…
<table cellpadding="2" cellspacing="2" border="0" width="100%">
<tr>
<td colspan="2" class="paddingRow"></td></tr>
<tr>
<td></f:verbatim>
<h:outputText value="#{msg.categories}" /><f:verbatim>:</td>
<td width="98%">
</f:verbatim>
<r:multiValueSelector id="multi-category-selector"
value="#{AddContentDialog.categories}"
lastItemAdded="#{AddContentDialog.addedCategory}"
selectItemMsg="#{msg.select_category}"
selectedItemsMsg="#{msg.selected_categories}"
noSelectedItemsMsg="#{msg.no_selected_categories}"
styleClass="multiValueSelector">
<f:subview id="categorySelector">
<r:ajaxCategorySelector id="catSelector" styleClass="selector"
value="#{AddContentDialog.addedCategory}"
label="#{msg.select_category_prompt}" />
</f:subview>
</r:multiValueSelector>
<f:verbatim>
</td>
</tr>
<tr><td colspan="2" class="paddingRow"></td></tr>
</table>
…
07-21-2010 05:06 AM
package org.alfresco.sample;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.web.bean.content.AddContentDialog;
@SuppressWarnings({"serial", "unchecked"})
public class CustomAddContentDialog extends AddContentDialog{
private NodeRef addedCategory;
private List<NodeRef> categories;
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.categories = new ArrayList<NodeRef>();
this.addedCategory = null;
}
public List getCategories(){
return this.categories;
}
public void setCategories(List categories)
{
this.categories = categories;
}
public void setAddedCategory(NodeRef addedCategory)
{
this.addedCategory = addedCategory;
}
public NodeRef getAddedCategory()
{
return this.addedCategory;
}
@Override
protected String finishImpl(FacesContext context, String outcome)
throws Exception {
outcome = super.finishImpl(context, outcome);
Map updateProps = getNodeService().getProperties(this.createdNode);
updateProps.put(ContentModel.PROP_CATEGORIES, (Serializable)this.categories);
getNodeService().setProperties(this.createdNode, updateProps);
return outcome;
}
}
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.