on 04-16-2008 3:45 PM
Hi,
We have a KM folder where we store articles based on xml forms. One iView displays the last 3 articles from this folder.
Is there a command that can be used in the collection renderer for creating a link to this KM folder and display the content with a selected layout set? The goal is that the user should be able to view all the articles in the folder. Is there maybe another work around? Any pointers?
Best,
Bjorn
Hi,
This is possible by implementing a UICommand, which will again call a KM Navigation IView with a specific layoutset.
So the link should look like this:
"/irj/servlet/prt/portal/prtroot/com.sap.km.cm.navigation" + "pathToKMFolder" + "?rndLayoutSet=YourSpecial_LayoutSet"
This link should be called in your UICommand.
Regards,
Praveen Gudapati
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bjørn,
In order to get the knowledge on how to implement a UI Command you can check out following links:
and
Hope this helps,
Robert
Hi Bjorn,
I had the same requirement and this is the code that i used...
I got this from SDN only from Thilo's How to Guide...
I tried to find that link...
package com.company;
import java.io.InputStream;
import java.util.List;
import java.util.Properties;
import com.sap.tc.logging.Location;
import com.sapportals.portal.security.usermanagement.IUser;
import com.sapportals.wcm.WcmException;
import com.sapportals.wcm.rendering.base.IRenderingEvent;
import com.sapportals.wcm.rendering.base.IScreenflowData;
import com.sapportals.wcm.rendering.uicommand.AbstractCommand;
import com.sapportals.wcm.rendering.uicommand.ICommand;
import com.sapportals.wcm.rendering.uicommand.LinkAttributes;
import com.sapportals.wcm.repository.IResource;
import com.sapportals.wcm.repository.IResourceContext;
import com.sapportals.wcm.repository.ResourceContext;
import com.sapportals.wcm.repository.ResourceException;
import com.sapportals.wcm.repository.ResourceFactory;
import com.sapportals.wcm.service.IServiceTypesConst;
import com.sapportals.wcm.service.urlgenerator.IURLGeneratorService;
import com.sapportals.wcm.service.urlgenerator.PathKey;
import com.sapportals.wcm.util.content.IContent;
import com.sapportals.wcm.util.uri.IHierarchicalUri;
import com.sapportals.wcm.util.uri.IUriReference;
import com.sapportals.wcm.util.uri.RID;
import com.sapportals.wcm.util.usermanagement.WPUMFactory;
/**
*/
public class Revisions extends AbstractCommand {
Location logger = Location.getLocation(Revisions.class);
//String url = "";
//private List values;
public Revisions() {
super("Revisions", "Revisions");
}
public ICommand getNewInstance() {
return this.initNewInstance(new Revisions());
}
public IRenderingEvent execute(IScreenflowData arg0) throws WcmException {
return null;
}
public String[] getTargetParameters() throws WcmException {
//return new String[0];
String result[] = new String[1];
result[0] = this.resource.getRID().getPath();
return result;
}
public void setTargetParameters(List arg0, IResourceContext arg1)
throws WcmException {
// this.context = arg1;
//
// this.values = arg0;
}
public boolean isExecutable() {
return true;
}
protected String getLabel() {
String label = "Revisions";
try {
label = getproperty("COMMAND_LABEL");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return label;
}
protected String getTooltip() {
String toolTip = "View all revsions";
try {
toolTip = getproperty("TOOL_TIP");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return toolTip;
}
public boolean raisesEvent() {
return false;
//Changed false to true to make the call to EXECUTE method
}
public LinkAttributes getLinkAttributes() {
LinkAttributes linkAttributes = null;
IResource res = this.getResource();
String resURL = "";
try {
resURL = urlGeneration(resource.getRID());
} catch (ResourceException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
resURL =
resURL.replaceAll("com.sap.km.cm.docs", "com.sap.km.cm.navigation");
try {
linkAttributes =
new LinkAttributes(
resURL + "?rndLayoutSet=" + getproperty("rndLayoutSet"),
"_blank");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return linkAttributes;
}
public java.lang.String urlGeneration(
com.sapportals.wcm.util.uri.RID rid) {
//@@begin urlGeneration()
IURLGeneratorService ug;
IUriReference uriRef = null;
String uriString = "";
try {
ug =
(IURLGeneratorService) ResourceFactory
.getInstance()
.getServiceFactory()
.getService(IServiceTypesConst.URLGENERATOR_SERVICE);
uriRef =
ug.getResourcePageUri(PathKey.CONTENT_ACCESS_PATH, rid, null);
IHierarchicalUri uri = ug.createAbsoluteUri(uriRef);
uriString = uri.toExternalForm();
uriString = escapeURLSpace(uriString);
} catch (ResourceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WcmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return uriString;
//@@end
}
public java.lang.String escapeURLSpace(java.lang.String url) {
//@@begin escapeURLSpace()
StringBuffer str = new StringBuffer(50);
int len = (url != null) ? url.length() : 0;
for (int i = 0; i < len; i++) {
char ch = url.charAt(i);
switch (ch) {
case ' ' :
str.append("%20");
break;
case '&' :
str.append("%26");
break;
default :
str.append(ch);
}
}
return str.toString();
//@@end
}
public String getproperty(String key) throws Exception {
IUser adminUser =
WPUMFactory.getServiceUserFactory().getServiceUser(
"cmadmin_service");
InputStream is = null;
String value = "";
String configFilePath =
"/documents/command.properties";
RID ridOfConfigFile = RID.getRID(configFilePath);
try {
if (adminUser.isAuthenticated()) {
// create a resource context with the authenticated user
ResourceContext resourceContext =
new ResourceContext(adminUser);
IResource resource =
ResourceFactory.getInstance().getResource(
ridOfConfigFile,
resourceContext);
IContent iContent = resource.getContent();
is = iContent.getInputStream();
Properties props = new Properties();
props.load(is);
value = props.getProperty(key);
}
} finally {
if (is != null)
is.close();
}
return value;
}
}
User | Count |
---|---|
82 | |
9 | |
9 | |
7 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.