08-23-2011 11:37 AM
http://edlovesjava.blogspot.com/2008/12/extending-share-2-adding-new-content.html.
http://@serveur:8080/share/service/components/documentlibrary/create-content?htmlidJ'ai aussi créé mon bouton et je peux le visualiser sans souci dans le site au niveau de l'espace documentaire.
WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/documentlibrarypour la création des fichiers.
onNewContent: function DLTB_onNewContent(e, p_obj)
{
var actionUrl = YAHOO.lang.substitute(Alfresco.constants.PROXY_URI + "slingshot/doclib/action/folder/site/{site}/{container}/{path}",
{
site: this.options.siteId,
container: this.options.containerId,
path: this.currentPath
});
var doSetupFormsValidation = function DLTB_oNF_doSetupFormsValidation(p_form)
{
// Validation
// Name: mandatory value
p_form.addValidation(this.id + "-createContent-name", Alfresco.forms.validation.mandatory, null, "keyup");
// Name: valid filename
p_form.addValidation(this.id + "-createContent-name", Alfresco.forms.validation.nodeName, null, "keyup");
p_form.setShowSubmitStateDynamically(true, false);
};
if (!this.modules.createContent)
{
this.modules.createContent = new Alfresco.module.SimpleDialog(this.id + "-createContent").setOptions(
{
width: "30em",
templateUrl: Alfresco.constants.URL_SERVICECONTEXT + "components/documentlibrary/create-content",
actionUrl: actionUrl,
doSetupFormsValidation:
{
fn: doSetupFormsValidation,
scope: this
},
firstFocus: this.id + "-createContent-name",
onSuccess:
{
fn: function DLTB_onCreateContent_callback(response)
{
var file = response.json.results[0];
YAHOO.Bubbling.fire("folderCreated",
{
name: file.name,
parentPath: file.parentPath,fileCopied
nodeRef: file.nodeRef
});
Alfresco.util.PopupManager.displayMessage(
{
text: this._msg("message.new-content.success", file.name)
});
},
scope: this
}
});
}
else
{
this.modules.createContent.setOptions(
{
actionUrl: actionUrl,
clearForm: true
});
}
this.modules.createContent.show();
},
/**
* New Content button click handler
*
* @method onNewContent
* @param e {object} DomEvent
* @param p_obj {object} Object passed back from addListener method
*/
onNewContent: function DLTB_onNewContent(e, p_obj)
{
var destination = var destination = this.doclistMetadata.parent.nodeRef;
// Intercept before dialog show
var doBeforeDialogShow = function DLTB_onNewContent_doBeforeDialogShow(p_form, p_dialog)
{
Dom.get(p_dialog.id + "-dialogTitle").innerHTML = this.msg("label.new-content.title");
Dom.get(p_dialog.id + "-dialogHeader").innerHTML = this.msg("label.new-content.header");
};
var templateUrl = YAHOO.lang.substitute(Alfresco.constants.URL_SERVICECONTEXT + "components/form?itemKind={itemKind}&itemId={itemId}&destination={destination}&mode={mode}&submitType={submitType}&formId={formId}&showCancelButton=true",
{
itemKind: "type",
itemId: "cm:content",
destination: destination,
mode: "create",
submitType: "json",
formId: "create-content"
});
// Using Forms Service, so always create new instance
var createContent = new Alfresco.module.SimpleDialog(this.id + "-createContent");
createContent.setOptions(
{
width: "33em",
templateUrl: templateUrl,
actionUrl: null,
destroyOnHide: true,
doBeforeDialogShow:
{
fn: doBeforeDialogShow,
scope: this
},
onSuccess:
{
fn: function DLTB_onNewContent_success(response)
{
var contentName = response.config.dataObj["prop_cm_name"];
YAHOO.Bubbling.fire("folderCreated",
{
name: contentName,
parentNodeRef: destination
});
Alfresco.util.PopupManager.displayMessage(
{
text: this.msg("message.new-content.success", contentName)
});
},
scope: this
},
onFailure:
{
fn: function DLTB_onNewContent_failure(response)
{
if (response)
{
var contentName = response.config.dataObj["prop_cm_name"];
Alfresco.util.PopupManager.displayMessage(
{
text: this.msg("message.new-content.failure", contentName)
});
}
else
{
Alfresco.util.PopupManager.displayMessage(
{
text: this.msg("message.failure")
});
}
},
scope: this
}
}).show();
},
09-01-2011 04:25 AM
09-01-2011 11:37 AM
http://edlovesjava.blogspot.com/2008/12/extending-share-2-adding-new-content.htmlTu dois te focaliser sur "step 2 - Create a new toolbar for Document Library adding the 'New Content' button"
<div class="hideable toolbar-hidden DocListTree">
<div class="new-content"><button id="${el}-newContent-button" name="newContent">${msg("button.new-content")}</button></div>
<div class="separator hideable DocListTree"> </div>
PS: Ne redéfinis pas les fichiers de share, contentes toi juste d'ajouter ce dont tu as besoin. De plus pour voir afficher le bouton tu n'as pas besoin en premier lieu du javascript. Mais je te mets tous les répertoires au cas où.Bonne soirée et bon courage
Oublies pas de redémarrer le serveur quand tu auras fait des modifications.
La démarche expliquée concerne Alfresco Share (je dis cela car en te relisant, j'ai eu un doute)
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.