on 07-08-2009 7:42 AM
Hi,
I had created one table view to diasplay KM Data with 3 columns Name, path, created.For path column with LinkbyURL property and i can able to display it in explorer but i want down load that file whenever i clicked on that link .How can it possible.
Regards,
surya.
HI,
You can try this piece of code :
IResourceContext resourseContext = new ResourceContext(ep5User);
com.sapportals.wcm.repository.IResource resource = ResourceFactory.getInstance().getResource(rid, resourseContext);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(resource.getContent().getInputStream());
doc.getDocumentElement().normalize();
Hope this piece of solution will be helpful.
Thanks
Ritushree
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Create node structure below: and bind this node to the table.
Attachments
-
> AttachmentURL
-
>AttachmentText
-
> CreatedDate
-
> CreatedBy
And in the table take one column's table cell editor as LinkToURL.
Regards,
Charan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
public void getListOfResources( )
{
wdContext.nodeAttachments().invalidate();
String decoderResourceName = null;
ArrayList al1 = null;
try {
String initialpath = "/documents/Test";
com.sapportals.portal.security.usermanagement.IUser user = null;
int localPort = 0;
String localhost = null;
ResourceContext ctx=null;
IResourceList children = null;
IUriReference uriRef = null;
IHierarchicalUri uri = null;
String accessURI = null;
IURLGeneratorService ug = null;
try {
ug = (IURLGeneratorService)com.sapportals.wcm.repository.ResourceFactory.getInstance().getServiceFactory
().getService(IServiceTypesConst.URLGENERATOR_SERVICE);
}
catch (ResourceException e1) {
e1.printStackTrace();
}
ArrayList file_names = new ArrayList();
ArrayList file_modify_date = new ArrayList();
IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
com.sap.security.api.IUser sapUser = wdClientUser.getSAPUser();
user = WPUMFactory.getUserFactory().getEP5User(sapUser);
ctx = new ResourceContext(user);
RID aRid=RID.getRID(initialpath);
com.sapportals.wcm.repository.IResource resource =
com.sapportals.wcm.repository.ResourceFactory.getInstance ().getResource(aRid, ctx);
uriRef = ug.getResourcePageUri(PathKey.CONTENT_ACCESS_PATH,resource.getAccessRID(),null);
uri = ug.createAbsoluteUri(uriRef);
IWDRequest req = WDProtocolAdapter.getProtocolAdapter().getRequestObject();
if(req != null)
{
localhost = req.getServerName();
localPort = req.getServerPort();
}
//this is the URL where it will give the absolute path
String uriPath = null;
if(uri != null)
{
uriPath = uri.getPath();
}
accessURI = "http://"+localhost+":"+localPort+uriPath;
ICollection collection = (ICollection)resource;
children = collection.getChildren();
IResourceListIterator listchild = children.listIterator();
al1 = new ArrayList();
while(listchild.hasNext())
{
IPrivateUploadFileKM_View.IAttachmentsElement attachmentsEle =
wdContext.createAttachmentsElement();
com.sapportals.wcm.repository.IResource element = listchild.next();
if(element.getName() != null && !al1.contains(element.getName()))
{
decoderResourceName = java.net.URLDecoder.decode(element.getName(),"UTF-8");
attachmentsEle.setAttachmentText(decoderResourceName);
al1.add(element.getName());
String resourceName=element.getName().toString();
//If % exists in the file name
if(checkIfExeists(resourceName,'%'))
{
attachmentsEle.setAttachmentURL(accessURI+"/"+URLEncoder.encode(element.getName(),"UTF-8"));
}else
{
attachmentsEle.setAttachmentURL(accessURI+"/"+element.getName());
}
attachmentsEle.setCreateDate(new java.sql.Date(element.getCreationDate().getTime()));
wdComponentAPI.getMessageManager().reportSuccess("Unique Name "+sapUser.getName());
attachmentsEle.setCreatedBy(element.getLastModifiedBy());
wdContext.nodeAttachments().addElement(attachmentsEle);
}
}
}catch(Exception e)
{
wdComponentAPI.getMessageManager().reportException("Exception in method getListOfResources()"+e,true);
}
}
Regards,
Charan
Hi Surya,
Try passing the exact path of the file. Like the path
<Drive>\testFolder\test_File.txt.
I hope you should get the file option to download.
Thanks and Regards
Pravesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.