cancel
Showing results for 
Search instead for 
Did you mean: 

Display a file from the KM

Former Member
0 Kudos

Hello all,

I want to display a file from the KM.

I manages to get the file content as an IContent object .

How can I use this object to display the file?

If there is a better way to display KM files (not with IContent) I would appreciate information about it as well.

Thanks in advance, Adi.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member188498
Active Participant
0 Kudos

Hi Adi,

you can use LinkToURL control. We use it for example to display xml

forms files.

You just have to set "text" and "reference" properties.

The "text" property could be assigned for example a file name and

the "reference" property must point to the url of a document in KM.

For example:


...
linkUrlDoc.text = "filename";
linkUrlDoc.reference = "http://"+getServerHostAndPort()+"/irj/go/km/docs/documents/filetodisplay.xml";

where


  public java.lang.String getServerHostAndPort( )
  {
    //@@begin getServerHostAndPort()
    
	WDDeployableObjectPart d = wdComponentAPI.getDeployableObjectPart();
	try
	{
		String url = wdComponentAPI.getURLService().getGeneralService().getAbsoluteWebResourceURL(d);
		
		int index = url.indexOf('/', 8);
		return url.substring(7, index);
	}
	catch(WDURLException e)
	{
		return "";	
	}
    
    //@@end
  }

Logged user also needs read permissions to that km folder.

Hope this helps,

Regards

Ladislav

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi Adi,

InputStream in = icontent.getInputStream();

DataInputStream dis = new DataInputStream(in);

StringBuffer sb = new StringBuffer();

String line;

while ((line=dis.readUTF()) != null) {

sb.append(line+”\n”);

}

String finalSring = sb.toString();

bind the final string to some context attribute .

place text edit control and set the value property to the above context attribute.

hope this helps.

Regards

Abhimanyu L