05-03-2010 08:17 AM
05-17-2010 07:44 AM
05-17-2010 07:49 AM
05-17-2010 08:00 AM
05-17-2010 08:46 AM
08-31-2010 08:05 AM
08-31-2010 08:06 AM
08-31-2010 03:04 PM
10-06-2011 07:32 AM
you are submiting on each click as I see. not very good idea…
<script type="text/javascript">
<%– LEGTM Selection Box Javascript Begin –%>
window.onload = onLoad;
function onLoad()
{
var items = document.getElementsByName("browse:chkbox");
var selected_values = document.getElementById('browse:selectionlist');
var arr = selected_values.value.split(";");
if (items != null)
{
for (var i = 0; i < items.length; i++)
{
var item = items[i];
var item_selected = false;
for (var j = 0; j < arr.length; j++)
{
if (arr[j] == item.title)
{
item_selected = true
}
}
if (item.checked != item_selected)
{
item.checked = item_selected;
}
item.title = item.checked ? "Please click to remove from selection" : "Please click to add to selection";
}
}
var selectAll = document.getElementById("browse:selectAll");
if (selectAll != null) {
var initialSelectAll = document.getElementById("browse:initialSelectAll");
selectAll.checked = (initialSelectAll != null);
}
}
function doselect(value, item)
{
var selected_values = document.getElementById('browse:selectionlist');
if (item.checked)
{
if (selected_values.value.length != 0)
{
selected_values.value = selected_values.value + ";";
}
selected_values.value = selected_values.value + value;
item.title = "Please click to remove from selection";
}
else
{
var arr = selected_values.value.split(";");
var new_value = "";
for (var i = 0; i < arr.length; i++)
{
if (arr[i] != "" && arr[i] != value)
{
if (new_value.length != 0)
{
new_value = new_value + ";";
}
new_value = new_value + arr[i];
}
}
selected_values.value = new_value;
item.title = "Please click to add to selection";
var selectAll = document.getElementById('browse:selectAll');
if (selectAll != null) {
selectAll.checked = false;
}
}
}
function selectAll(e)
{
document.forms['browse']['browse:act'].value='browse:select-apply-all';
document.forms['browse']['on_off'].value= e.checked;
if (document.forms['browse']['browse:contentRichList:pager'] != null)
{
document.forms['browse']['browse:contentRichList:pager'].value = document.forms['browse']['browse:contentRichList:pager:pageNamber'].value - 1;
}
document.forms['browse'].submit();
}
…..
<a:actionLink id="select-apply-all" value="" actionListener="#{BatchNavigationBean.setSelectAll}">
<f:param name="on_off" id="on_off" value="" />
</a:actionLink>
<h:inputHidden id="selectionlist" value="#{BatchNavigationBean.selection}" />
<h:inputHidden id="initialSelectAll" rendered="#{BatchNavigationBean.allSelected}" />
<a:richList id="contentRichList" binding="#{BrowseBean.contentRichList}" viewMode="#{BrowseBean.browseViewMode}" pageSize="#{BrowseBean.pageSizeContent}"
styleClass="recordSet" headerStyleClass="recordSetHeader" rowStyleClass="recordSetRow" altRowStyleClass="recordSetRowAlt" width="100%"
value="#{BrowseBean.content}" var="r">
…..
<a:column id="col-sel" style="padding:2px;text-align:left" >
<f:facet name="header">
<h:selectBooleanCheckbox id="selectAll" title="Select/Unselect All" onclick="selectAll(this);"/>
</f:facet>
<a:panel id="panel-sel" >
<h:selectBooleanCheckbox id="chkbox" value="false" title="#{r.id}" onclick="javascript:doselect('#{r.id}', this);return true;" />
</a:panel>
</a:column>
<managed-bean>
<description>
Bean used to select nodes on the browse interface
</description>
<managed-bean-name>BatchNavigationBean</managed-bean-name>
<managed-bean-class>your.namespace.BatchNavigationBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>navigator</property-name>
<value>#{NavigationBean}</value>
</managed-property>
<managed-property>
<property-name>browseBean</property-name>
<value>#{BrowseBean}</value>
</managed-property>
</managed-bean>
class BatchNavigationBean implements Serializable {
transient private NavigationBean navigator = null;
transient private BrowseBean browseBean = null;
private String currentNodeId = null; // reset the selection when the currentNodeId has changed
private String selection = "";
private static Log logger = LogFactory.getLog(BatchNavigationBean.class);
public void setSelection(String selection) {
this.selection = selection;
if (logger.isDebugEnabled()) {
logger.debug("Selection set to " + selection);
}
}
public String getSelection() {
if ( ((currentNodeId == null) != (this.navigator.getCurrentNodeId() == null)) ||
((currentNodeId != null) && !currentNodeId.equals(this.navigator.getCurrentNodeId()))) {
currentNodeId = this.navigator.getCurrentNodeId();
selection = "";
}
return selection;
}
public boolean isAllSelected() {
return selection.split(";").length == browseBean.getContent().size();
}
public void setAllSelected(boolean allSelected) {
if (isAllSelected() != allSelected) {
if (allSelected) {
StringBuffer sb = new StringBuffer();
for(Node node : browseBean.getContent()) {
NodeRef nodeRef = node.getNodeRef();
if (sb.length() != 0) {
sb.append(";");
}
sb.append(node.getId());
}
selection = sb.toString();
if (logger.isDebugEnabled()) {
logger.debug("Selection set to all nodes");
}
} else {
selection = "";
if (logger.isDebugEnabled()) {
logger.debug("Selection set to no nodes");
}
}
}
}
// action to handle "select all" click
public void setSelectAll(ActionEvent event) {
UIActionLink uIActionLink = (UIActionLink) event.getComponent();
boolean allSelected = "true".equals(uIActionLink.getParameterMap().get("on_off"));
setAllSelected(allSelected);
}
public Set<NodeRef> getSelected() {
Set<NodeRef> result = new HashSet<NodeRef>();
String[] array = selection.split(";");
StoreRef storeRef = Repository.getStoreRef();
for (String ref : array) {
if (ref != null && !ref.isEmpty()) {
NodeRef nodeRef = new NodeRef(storeRef, ref);
result.add(nodeRef);
}
}
return result;
}
// remove selections from current space e.g. when action was performed
public void unselectNodes(Set<NodeRef> nodeRefsToUnselect) {
Iterator<NodeRef> selectedNode = getSelected().iterator();
while (selectedNode.hasNext()) {
NodeRef selectedNodeRef = selectedNode.next();
if (nodeRefsToUnselect.contains(selectedNodeRef))
selectedNode.remove();
}
}
public void setNavigator(NavigationBean navigator) {
this.navigator = navigator;
currentNodeId = this.navigator.getCurrentNodeId();
selection = "";
}
public NavigationBean getNavigator() {
return navigator;
}
public void setBrowseBean(BrowseBean browseBean) {
this.browseBean = browseBean;
}
public BrowseBean getBrowseBean() {
return browseBean;
}
}
12-20-2011 05:33 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.