Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do we need any jar files for EL?

Status
Not open for further replies.

jollyplay

Programmer
Dec 16, 2003
90
Hello

i am using weblogic 8.1. In a JSP file, i am using like
${something} to get values from a variable. But it is printing ${something} instead of extracting the value of something(variable).

My doubt is, we need any jar files or configuration to make EL work. Please advice.

balachandar
 
The code is
-----------
SortUtil.java

package com.11.22.util;

import java.util.Arrays;

import org.apache.commons.collections.comparators.ComparatorChain;

public class SortUtil {
/** This is a generic method which is used to sort any 2D array. The array which is passed to the method
* is worked on and sorted. hence the return type is void
*
* @param inputArray A 2D array which needs to be sorted
* @param colNum Array of column numbers on which sorting should be done. zeroth element is primary sort, first element is secondary sort and so on
* @param sortFlag Direction of sorting when sortFlag =1 The sorting is ascending. otherwise it is descending. The sort flag is common for all columns on which sorting is performed
*/
public static void sort2DArray(Object[][] inputArray, int colNum[],int sortFlag) {
ComparatorChain chn = new ComparatorChain();
//Creating multiple sorting objects based on no of columns to sort
for (int iter = 0 ; iter <colNum.length ; iter++) {
chn.addComparator(new TableSorter(colNum[iter]));

/* The sort which we are trying to put should be put on all the indvidual sorter */
if (sortFlag == 1 )
{
chn.setForwardSort(iter);
}
else
{
chn.setReverseSort(iter);
}

} // for end
Arrays.sort(inputArray, chn);

} // method end

}


TableSorter.java


package com.11.22.util;
import java.util.Comparator;

public class TableSorter implements Comparator {

int column; // colunmn id to be sorted
public TableSorter(int columnToSortBy) {
this.column = columnToSortBy;
}

public TableSorter() {}

public void setColumnToSortBy(int columnToSortBy) {
this.column = columnToSortBy;
}

public int compare(Object o1, Object o2) {
Object[] a1 = (Object[])o1;
Object[] a2 = (Object[])o2;

Object objColumnValue1 = a1[column];
Object objColumnValue2 = a2[column];

if (objColumnValue1 instanceof Integer && objColumnValue2 instanceof Integer )
{
int val1 = Integer.parseInt(objColumnValue1.toString());
int val2 = Integer.parseInt(objColumnValue2.toString());
if (val1 > val2)
return 1;
else if (val1 < val2)
return -1;
else
return 0;
} else if (objColumnValue1 instanceof java.lang.Double && objColumnValue2 instanceof java.lang.Double ) {
double val1 = java.lang.Double.parseDouble(objColumnValue1.toString());
double val2 = java.lang.Double.parseDouble(objColumnValue2.toString());
if (val1 > val2)
return 1;
else if (val1 < val2)
return -1;
else
return 0;
} else if (objColumnValue1 instanceof Long && objColumnValue2 instanceof Long ) {
long val1 = java.lang.Long.parseLong(objColumnValue1.toString());
long val2 = java.lang.Long.parseLong(objColumnValue2.toString());
if (val1 > val2)
return 1;
else if (val1 < val2)
return -1;
else
return 0;
}else {
String str1 =objColumnValue1.toString().toUpperCase();
String str2 =objColumnValue2.toString().toUpperCase();
return str1.compareTo(str2);

}
// return array1[column].compareTo(array2[column]);
}


}





AOManagementServiceImpl.java

public class AOManagementServiceImpl implements AOManagementService {


public List sortAccountOpen(AccountFileSearchResult[] result, int numCol,
int colNum[], int sortFlag) throws SomeException {
List list = new ArrayList();
Object[][] obj = { {}, {} };
obj = new Object[result.length][numCol];
for (int i = 0; i < result.length; i++) {
logger.info("result.getSegmentCode() "
+ result.getTransDateTime());
obj[0] = result.getSegmentCode();
obj[1] = result.getTransDateTime();
obj[2] = result.getTransSource();
obj[3] = result.getTPAId();
obj[4] = result.getCSTCTPAId();
obj[5] = result.getOriginFlag();
obj[6] = new Long(result.getMatch());
obj[7] = new Long(result.getTotal());
}

/* Here we can convert the 2D array back to Array of sort objects */

SortUtil.sort2DArray(obj, colNum, sortFlag);

for (int i = 0; i < obj.length; i++) {
AccountFileSearchResult accountResult = new AccountFileSearchResult();
accountResult.setSegmentCode(obj[0].toString());
accountResult.setTransDateTime(obj[1].toString());
accountResult.setTransSource(obj[2].toString());
accountResult.setTPAId(obj[3].toString());
accountResult.setCSTCTPAId(obj[4].toString());
accountResult.setOriginFlag(obj[5].toString());
accountResult.setMatch(new Long(obj[6].toString()).intValue());
accountResult.setTotal(new Long(obj[7].toString()).intValue());
logger.info(" Sorted " + accountResult.toString());
list.add(accountResult);
}
return list;
}

}
AccountFileSearchResult.java

public class AccountFileSearchResult implements Serializable{
private static final long serialVersionUID = 1L;
// File Name
private String transSource;
// Import Date/Time
private String transDateTime;
// Campaign
private String segmentCode;
// TPA ID // get set methods
private String TPAId;
// CSTC TPA
private String CSTCTPAId;
// origin
private String originFlag;
// matching records
private int match;
// total records
private int total;
// total records

private String formatTransDateTime;
}

Sort function in Action Class

public ActionForward sort(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
logger.info("start sort");
try {
AOManagementService aoManagementService = AOManagementServiceFactory
.getAOManagementService();
HttpSession session = request.getSession(false);
UserProfile userProfile = (UserProfile) session
.getAttribute(Constant.USER_PROFILE_OBJECT);
this.checkBDCSTC(userProfile, form, session);

if (session.getAttribute(Constant.ACCOUNT_FILES_DETAILS) != null) {
AccountFileSearchResult[] result = (AccountFileSearchResult[]) session
.getAttribute(Constant.ACCOUNT_FILES_DETAILS);

if (result.length > 1) {
int colCount = 8;
int colNum[] = { 0, 0, 0 };
int sortFlag = 1;
int priSort = 3;
String sortOrder = (String) PropertyUtils
.getSimpleProperty(form, FIELD_SORT_ORDER);
String sortColPr = (String) PropertyUtils
.getSimpleProperty(form, FIELD_SORT_COl);
if(sortOrder == null)
{
if (session.getAttribute(FIELD_SORT_ORDER) != null) {
sortOrder = (String) session
.getAttribute(FIELD_SORT_ORDER);
}
}
try {
if (sortOrder != null && sortOrder.trim().length() > 0) {
sortFlag = Integer.parseInt(sortOrder);
}
logger.info("sort order" +sortFlag);
if (sortColPr != null && sortColPr.trim().length() > 0) {
priSort = Integer.parseInt(sortColPr);
}
logger.info("primary sort col" + ""+priSort);
} catch (NumberFormatException ex) {
sortFlag = 1;
}
// priSort -- depends on the col number
if (priSort == 3) {
colNum[0] = 3;
colNum[1] = 2;
colNum[2] = 0;
} else if (priSort == 0) {
colNum[0] = 0;
colNum[1] = 3;
colNum[2] = 2;
} else if (priSort == 1) {
colNum[0] = 1;
colNum[1] = 2;
colNum[2] = 3;
} else if (priSort == 4) {
colNum[0] = 4;
colNum[1] = 3;
colNum[2] = 2;
} else if (priSort == 5) {
colNum[0] = 5;
colNum[1] = 3;
colNum[2] = 2;
} else if (priSort == 6) {
colNum[0] = 6;
colNum[1] = 3;
colNum[2] = 2;
} else if (priSort == 7) {
colNum[0] = 7;
colNum[1] = 3;
colNum[2] = 2;
}
session.setAttribute(Constant.ACCOUNT_FILES_DETAILS, null);
List accountFilesDetails = aoManagementService
.sortAccountOpen(result, colCount, colNum, sortFlag);
result = (AccountFileSearchResult[]) accountFilesDetails
.toArray(new AccountFileSearchResult[accountFilesDetails
.size()]);
if (result != null) {
session.setAttribute(Constant.ACCOUNT_FILES_DETAILS,
result);
}
if (session.getAttribute(ACTION_FIELDS) != null) {
AccountFileSearch accountFileObject = null;
accountFileObject = (AccountFileSearch) session
.getAttribute(ACTION_FIELDS);
populateForm(form, accountFileObject, session);
} else {
AccountFileSearch accountFileObject = populateSearchBean(
form, session);
session
.setAttribute(ACTION_FIELDS,
accountFileObject);
populateForm(form, accountFileObject, session);
}
PropertyUtils.setSimpleProperty(form, FIELD_SORT_ORDER,
new Integer(sortFlag).toString());
PropertyUtils.setSimpleProperty(form, FIELD_SORT_COl,
new Integer(colNum[0]).toString());
session.setAttribute(FIELD_SORT_ORDER,
new Integer(sortFlag).toString());
}
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw e;
}
logger.info("end sort");
return (mapping.findForward("success"));
}


List accountFilesDetails = null;
accountFilesDetails = aoManagementService
.defaultSearchFileDetails(userProfile,userProfile.getDisplayName());
AccountFileSearchResult accountFilesDetailss[] = null;
accountFilesDetailss = (AccountFileSearchResult[]) accountFilesDetails
.toArray(new AccountFileSearchResult[accountFilesDetails
.size()]);
session.setAttribute(Constant.ACCOUNT_FILES_DETAILS,
accountFilesDetailss);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top