Dynamic View Panel Customizer Bean

package com.yourconame.desc;

import java.util.Map;

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 MyCustomizerBean extends DominoViewCustomizer{

	@SuppressWarnings("unchecked")
	@Override
	public void afterCreateColumn(FacesContext context, int index,
			ColumnDef colDef, IControl column) {
			//Get a map of the session variables to read the view session scope variable
			Map svals = context.getExternalContext().getSessionMap();
			//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;
			//To have every view open the selected documents in read mode add the following
			dynamicColumn.setOpenDocAsReadonly(true);
			
			/*
			 * If all you need to do is have the views open in read mode instead of
			 * edit mode then the above code is all you need.
			 * If you want to customize the view columns the the follow code can be
			 * used as an example.			
			*/

			
			//Set column properties for specific views.
			//Where VIEWNAME is the view name stored in a session scope variable
			if (svals.containsValue("VIEWNAME") & colDef.isLink()) {
				
				//set the checkbox property to true for this view
				if(dynamicColumn.getColumnName().equalsIgnoreCase("COLUMNNAME")){
					dynamicColumn.setShowCheckbox(true);	
				}
			}
			
			if (svals.containsValue("VIEWNAME")) {
				
				//Hide the address column in this view
				if(dynamicColumn.getColumnName().equalsIgnoreCase("COLUMNNAME")){
					dynamicColumn.setRendered(false);
				}

			}

		
		
		super.afterCreateColumn(context, index, colDef, column);
	}

}





This is an example of base code that can be used for the Extension Libraries Dynamic View Panel Customizer bean property.  
Add the code to your NSF as a Java Code Element (8.5.3) or as a java class in the package explorer (8.5.2).  
See the code comments for specific instructions on the VIEWNAMEs and COLUMNNAMES

Java
Paul T. Calhoun
September 24, 2012 9:40 AM
Rating
306

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



No comments yetLogin first to comment...