I am using a Dynamic View Panel to display various views inside a single XPage. This has resulted in a few problems. Firstly, column styling set inside the views is not displayed on the XPage (eg: making column headers bold). More importantly, while the view contains links to the documents inside the view, links are all appended with action=editDocument
, which I would like to change to action=openDocument
. However, I cannot find any way to change this property.
3 Answers
You need to use a customizer bean for this and add the name of that bean to the customizerBean
property of the Dynamic View Panel control.
In the customizer bean you can control styling such as what you are looking for but you need to code the Java bean yourself. Jesse Gallagher has created a great example of an extended customizer bean and even put it on Github: https://github.com/jesse-gallagher/Domino-One-Offs.
Have a look at his blog posts on the subject:
- This Dynamic View Customizer Is Getting Into Shape
- Enhancing xe:dynamicViewPanel For My Own Purposes
--
For your specific question on changing editDocument to openDocument you can use the following small example of a customizer bean:
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import com.ibm.xsp.extlib.builder.ControlBuilder.IControl;
import com.ibm.xsp.extlib.component.dynamicview.DominoDynamicColumnBuilder.DominoViewCustomizer;
import com.ibm.xsp.extlib.component.dynamicview.UIDynamicViewPanel.DynamicColumn;
import com.ibm.xsp.extlib.component.dynamicview.ViewDesign.ColumnDef;
public class customizer extends DominoViewCustomizer{
@Override
public void afterCreateColumn(FacesContext context, int index, ColumnDef colDef, IControl column) {
//Create a variable for the current component
UIComponent columnComponent = column.getComponent();
//Create a reference to the column and set the links to open in read mode
DynamicColumn dynamicColumn = (DynamicColumn) columnComponent;
dynamicColumn.setOpenDocAsReadonly(true);
super.afterCreateColumn(context, index, colDef, column);
}
}
Remember to add the class to faces-config.xml in order to be able to use it as a bean.
Instead of a customizer bean you can use the onColumnClick event to do your own redirect. Here's an example:
<xe:dynamicViewPanel value="#{viewdatasource}" id="dynamicViewPanel1" var="viewEntry" pageName="/page.xsp">
<xp:eventHandler event="onColumnClick" submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:var url="/page.xsp?action=openDocument&documentId="+viewEntry.getNoteID();
context.redirectToPage(url);
}]]></xp:this.action>
</xp:eventHandler>
</xe:dynamicViewPanel>
-
Thanks! I've used the eventHandler for now to solve the openDocument problem, and I will look at implementing the customizer bean to solve the other niggling problems. Commented Apr 29, 2012 at 16:32
-
1 click in a <xp:viewColumn> property - a lot simpler than creating a Bean. Commented Apr 27, 2014 at 17:46
-
Charles, except the question was about the use of the Dynamic View Panel. Commented Apr 27, 2014 at 20:16
If you want to open document using its form instead of using XPage, then you can do it like this, where rowData
is var for ViewPanel
<xp:eventHandler event="onColumnClick" submit="true" refreshMode="complete" id="eventHandler1">
<xp:this.action><![CDATA[#{javascript:if (!rowData.isCategory())
var url = "0/"+rowData.getUniversalID()+"?OpenDocument"
facesContext.getExternalContext().redirect(url);}]]>
</xp:this.action>
</xp:eventHandler
-
One note to point out is that the onColumnClick event only respond to the active column links you have in the view (not all columns) so if you did not actively in the view column enabled any columns to be weblinks only the first columnn is a link. Commented Sep 16, 2013 at 7:28
In SSJS, you can possibly try on the links in the document by adding this:
context.redirectToPage(@ReplaceSubstring(context.getUrl().toString(),"editDocument","openDocument"));