1 16 package com.blandware.atleap.webapp.action.core.contentLocale; 17 18 import com.blandware.atleap.common.Constants; 19 import com.blandware.atleap.common.util.QueryInfo; 20 import com.blandware.atleap.service.core.ContentLocaleManager; 21 import com.blandware.atleap.webapp.action.core.grid.BaseGridAction; 22 import com.blandware.atleap.webapp.taglib.core.grid.util.Grid; 23 import com.blandware.atleap.webapp.taglib.core.grid.util.SortField; 24 import com.blandware.atleap.webapp.util.core.LocaleUtil; 25 import com.blandware.atleap.webapp.util.core.WebappConstants; 26 import org.apache.struts.action.ActionForm; 27 import org.apache.struts.action.ActionForward; 28 import org.apache.struts.action.ActionMapping; 29 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 import java.util.List ; 33 34 49 public final class ListContentLocalesAction extends BaseGridAction { 50 59 public ActionForward execute(ActionMapping mapping, ActionForm form, 60 HttpServletRequest request, HttpServletResponse response) { 61 62 Grid clGrid = getGridByName(WebappConstants.CONTENT_LOCALES_GRID, request.getSession()); 63 64 if ( clGrid == null ) { 65 clGrid = new Grid(WebappConstants.CONTENT_LOCALES_GRID); 66 } 67 68 String sortFieldName = request.getParameter("sortField"); 70 String orderByClause = new String (); 71 if ( WebappConstants.CONTENT_LOCALES_GRID.equals(request.getParameter("gridName")) && sortFieldName != null && sortFieldName.length() > 0 ) { 72 SortField sortField = clGrid.getSortFieldByFieldName(sortFieldName); 73 if ( sortField == null ) { 74 sortField = new SortField(sortFieldName, SortField.ORDER_DESCENDING); 75 clGrid.addSortField(sortField); 76 } else { 77 sortField.reverseOrder(); 78 clGrid.addSortField(sortField); 79 } 80 orderByClause = clGrid.getOrderByClause(); 81 clGrid.getSortFieldByFieldName(sortFieldName).reverseOrder(); 82 } 83 84 saveGrid(clGrid, request.getSession()); 85 86 QueryInfo queryInfo = new QueryInfo(); 87 queryInfo.setWhereClause(clGrid.getWhereClause()); 88 queryInfo.setOrderByClause(orderByClause); 89 90 ContentLocaleManager contentLocaleManager = (ContentLocaleManager) getBean(Constants.CONTENT_LOCALE_MANAGER_BEAN); 91 List contentLocales = contentLocaleManager.listContentLocales(queryInfo).asList(); 92 93 request.setAttribute(WebappConstants.CONTENT_LOCALES_COLLECTION_KEY, contentLocales); 94 95 request.setAttribute(WebappConstants.AVAILABLE_LOCALES_LIST_SIZE_KEY, new Integer (LocaleUtil.getInstance(servlet.getServletContext()).getAvailableLocales().size())); 97 98 saveToken(request); 100 return mapping.findForward("listContentLocales"); 101 } 102 } | Popular Tags |