Skip to Content
0
Former Member
Jul 26, 2005 at 08:26 PM

Table View Sorting Problem

16 Views

Hi SDN,

I am developing a Java iView with table view

I am getting Data from R/3 using JCA connectivity

and can able to display IRecordSet in table view

now i want the data to be sorted in multiple columns

can any one provide me how to proceed further , thank you in advance

please find the attached code below

public void getInitialData(){

IPortalComponentRequest request = (IPortalComponentRequest)getRequest();

String BAPI_InitialData = request.getComponentContext().getProfile().getProperty("BAPI_InitialData");

String ADD_ON_APPLICATION = request.getComponentContext().getProfile().getProperty("ADD_ON_APPLICATION");

String PLAN_VERSION = request.getComponentContext().getProfile().getProperty("PLAN_VERSION");

String userid = request.getUser().getUniqueName();

this.getConnection();

try{

IInteraction interaction = connection.createInteractionEx();

IInteractionSpec interactionSpec = interaction.getInteractionSpec();

interactionSpec.setPropertyValue("Name", BAPI_InitialData);

RecordFactory recordFactory = interaction.getRecordFactory();

MappedRecord input = recordFactory.createMappedRecord("input");

input.put("ADD_ON_APPLICATION",ADD_ON_APPLICATION) ;

input.put("PLAN_VERSION",PLAN_VERSION) ;

input.put("USER_NAME",userid) ;

MappedRecord exportParams = (MappedRecord) interaction.execute(interactionSpec, input);

IRecordSet templatetable = (IRecordSet)exportParams.get("T_TEMPLATES");

myBean.setTemplates(templatetable);

myBean.createNewTable(templatetable);

String default_template = (String)exportParams.get("DEFAULT_TEMPLATE");

myBean.setDTemplate(default_template);

Date begda = (Date)exportParams.get("FROM_DATE");

myBean.setBegda(begda);

//myBean.setBegda(begda.toLocaleString());

Date endda = (Date)exportParams.get("TO_DATE");

myBean.setEndda(endda);

connection.close();

MY BEAN

import com.sapportals.htmlb.table.DefaultTableViewModel;

//import com.sapportals.htmlb.table.TableColumn;

import com.sapportals.htmlb.table.TableViewModel;

//import java.util.Vector;

import java.io.Serializable;

import java.util.*;

import com.sapportals.connector.execution.structures.*;

public class LeaderStatusBean implements Serializable{

String msgStr = "";

String d_template ="";

String begda = "" ;

String endda = "";

IRecordSet templates = null ;

Date _begda = null ;

Date _endda = null ;

public DefaultTableViewModel model;

public TableViewModel model2;

public DefaultTableViewModel getModel() {

//this.createNewTable();

//model2 = new TableViewModel();

return this.model;

}

/* public void setModel(DefaultTableViewModel model) {

this.model = model;

}*/

public void setMessage(String msg){

msgStr = msg ;

}

public String getMessage(){

return msgStr ;

}

public void setDTemplate(String d_tmp){

d_template = d_tmp ;

}

public String getDTemplate(){

return d_template ;

}

public void setTemplates(IRecordSet _templates){

templates = _templates ;

}

public IRecordSet getTemplates(){

return templates ;

}

/*public void setBegda(String t_begda){

begda = t_begda ;

}*/

public String getFromDate(){

begda = this.getStrDate(this.getBegda());

return begda ;

}

public void setBegda(Date td_begda){

begda = tdbegda ;

}

public Date getBegda(){

return _begda ;

}

public void setEndda(Date t_endda){

endda = tendda ;

}

public Date getEndda(){

return _endda ;

}

public String getToDate(){

endda = this.getStrDate(this.getEndda());

return endda ;

}

public String getStrDate(Date _indate) {

String outFormat = "yyyyMMdd";

String strdate = "";

java.text.SimpleDateFormat outDf =

new java.text.SimpleDateFormat(outFormat);

java.util.Date result = _indate;

try

{

strdate = outDf.format(result);

}

catch(Exception ex){}

return strdate ;

}

public void createNewTable(IRecordSet _temptable) {

IRecordSet mytable = _temptable ;

Vector data = createData(mytable);

Vector colName = new Vector();

colName.addElement("DOCUMENT ID");

colName.addElement("DOCUMENT NAME");

colName.addElement("SHORT TEXT");

colName.addElement("BEGDA");

colName.addElement("ENDDA");

model = new DefaultTableViewModel(data, colName);

//return model;

model.setKeyColumn(1);

}

public Vector createData(IRecordSet _temptable) {

Vector dataVec = new Vector();

Vector retVector = new Vector();

IRecordSet temptable = this.getTemplates();

try{

temptable.beforeFirst();

while (temptable.next()){

dataVec = new Vector();

dataVec.addElement(temptable.getString("OBJID"));

dataVec.addElement(temptable.getString("STEXT"));

dataVec.addElement(temptable.getString("SHORT"));

dataVec.addElement(temptable.getString("BEGDA"));

dataVec.addElement(temptable.getString("ENDDA"));

retVector.addElement(dataVec);

dataVec = new Vector();

dataVec.addElement("");

dataVec.addElement("");

dataVec.addElement(" somejunk 1");

dataVec.addElement("");

dataVec.addElement("");

retVector.addElement(dataVec);

}

}catch(Exception te){

}

return retVector ;

}

}

JSP

<hbj:tableView id="myTableView"

model = "myBean.model"

design = "ALTERNATING"

headerVisible = "true"

footerVisible = "true"

fillUpEmptyRows = "true"

navigationMode = "BYLINE"

selectionMode = "MULTISELECT"

headerText = "tableView - Navigation - Selection"

onNavigate = "onNavigation"

visibleRowCount = "5" >

</hbj:tableView>