cancel
Showing results for 
Search instead for 
Did you mean: 

Date Field in Tableview Cell

Former Member
0 Kudos

Hi,

I want to insert a Input field with date picker in the tableview cell. I know I have to use the Renderer class for this. But I need some code samples. Please help me in this regard.

Regards,

Purushothaman.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Purushothaman,

//be sure to import the following

import com.sapportals.htmlb.InputField;

public class TableViewCellRenderer implements ICellRenderer {

public void renderCell(int row, int column, TableView tableView, IPageContext rendererContext) {

if (column == 6) {

InputField dateField = new InputField("myInfoField");

// Now we set the string for inputField from the model, so that the selections

// already made in the tableView don't get lost

dateField.setString(tableView.getValueAt(row, column).toString());

// Now we set the datatype to DATE and SHOWHELP to TRUE

dateField.setShowHelp(true);

dateField.setType(DataType.DATE);

dateField.setDesign(InputFieldDesign.SMALL);

// Set the renderer

dateField.render(rendererContext);

}

}

}

Former Member
0 Kudos

Hi Umair,

Thanks for ur reply but I am not able to call this renderer class from my JSP or Dynpage. It shows me null pointer exception. Can u please help me in this?

Regards,

Purushothaman.

Former Member
0 Kudos

Sorry about that...here's the code in the JSP...

<%@ page import = "com.yourcompany.yourapp.TableViewCellRenderer,com.sapportals.connector.execution.structures., com.sapportals.htmlb.enum." %>

<hbj:tableView id="myTableView"

model = "myBean.model"

design = "ALTERNATING"

headerVisible = "true"

footerVisible = "true"

fillUpEmptyRows = "true"

navigationMode = "BYLINE"

selectionMode="MULTISELECT"

visibleRowCount = "4"

width="700"

onNavigate = "onNavigation" >

<%myTableView.setUserTypeCellRenderer(new TableViewCellRenderer()); %>

</hbj:tableView>

Former Member
0 Kudos

Hi Umair,

Thanks a lot for ur quick reply. Its not going to the Renderer class itself. I dont know what I am missing. Please help me in this regard.

Thanks,

Purushothaman.

Former Member
0 Kudos

Hmmm...what's the error message you're getting?

make sure you've got the package right and you're importing the renderer class into your JSP:

<b><%@ page import = "com.yourcompany.yourapp.TableViewCellRenderer %></b>

Former Member
0 Kudos

Hi Umair,

Thanks for ur reply. I have already given that.

It working fine now. I have commented some code and when i removed that its working good.

Regards,

Purushothaman.

Former Member
0 Kudos

If my responses helped you resolve the issue, please assign the appropriate 10 points

thank you!

Former Member
0 Kudos

Hi,

I am not able to get the value from the inputfield in tableview. Please help me in this regard.

Regards,

Purushothaman.

Former Member
0 Kudos

I have solved it.

Regards,

Purushothaman.

Former Member
0 Kudos

Hi puroshotam, Saliam

I m trying htmlb table for the first time. I am not able to add elements onto table cell.. My code is as follows

dynpage:

package com.linde.myaccounts.paymyaccountprelogin.dynpage;

import com.sapportals.htmlb.event.Event;

import java.io.IOException;

import javax.naming.Context;

import com.linde.myaccounts.util.TableBean;

import com.sapportals.htmlb.page.DynPage;

import com.sapportals.htmlb.page.PageException;

import com.sapportals.portal.htmlb.page.JSPDynPage;

import com.sapportals.portal.htmlb.page.PageProcessorComponent;

import com.sapportals.portal.prt.component.IPortalComponentProfile;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.prt.component.IPortalComponentResponse;

import com.sapportals.portal.prt.runtime.PortalRuntime;

public class PayMyAccountPreLoginDynpage extends PageProcessorComponent {

public DynPage getPage(){

return new PayMyAccountPreLoginDynpageDynPage();

}

public static class PayMyAccountPreLoginDynpageDynPage extends JSPDynPage{

private TableBean myBean = null;

public void doInitialization(){

IPortalComponentResponse response = (IPortalComponentResponse) this.getResponse();

IPortalComponentProfile profile = ((IPortalComponentRequest)getRequest()).getComponentContext().getProfile();

Object o = profile.getValue("myBean");

if(o==null || !(o instanceof TableBean)){

myBean = new TableBean();

myBean.createData();

profile.putValue("myBean",myBean);

} else {

myBean = (TableBean) o;

}

// fill your bean with data here...

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

//doJca(request);

}

public void doProcessAfterInput() throws PageException {

}

public void doProcessBeforeOutput() throws PageException {

this.setJspName("PayMyAccountPreLoginStep1.jsp");

}

public void onInstruction(Event event)

{

}

public void onClearScreen(Event event)

{

}

public void onPayment(Event event)

{

}

}

}

jsp

<%@ taglib uri="tagLib" prefix="hbj" %>

<%@ page import="com.linde.myaccounts.util.MainCellRenderer"%>

<jsp:useBean id="myBean" scope="application" class="com.linde.myaccounts.util.TableBean" />

<hbj:content id="myContext">

<hbj:page title="PageTitle">

<hbj:form id="myFormId">

<hbj:tableView id="myTableView1"

model="myBean.model"

design="ALTERNATING"

headerVisible="false"

footerVisible="false"

fillUpEmptyRows="true"

visibleFirstRow="1"

visibleRowCount="5"

width="500 px" >

<%mytableView1.setUserTypeCellRenderer(new MainCellRenderer());%>

</hbj:tableView>

</hbj:form>

</hbj:page>

</hbj:content>

tableBean

/*

  • Created on Nov 21, 2007

*

  • To change the template for this generated file go to

  • Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments

*/

package com.linde.myaccounts.util;

/**

  • @author zm46187

*

  • To change the template for this generated type comment go to

  • Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments

*/

import java.io.Serializable;

import java.util.Vector;

import com.sapportals.htmlb.table.DefaultTableViewModel;

import com.sapportals.htmlb.table.TableViewModel;

public class TableBean implements Serializable {

public DefaultTableViewModel model;

public TableBean(){

model = new DefaultTableViewModel();

}

public TableViewModel getModel() {

return this.model;

}

public void setModel(DefaultTableViewModel model) {

this.model = model;

}

public void createData() {

//this is your column names

Vector column = new Vector();

column.addElement("invoice number:");

column.addElement("show balance");

column.addElement("balance");

column.addElement("pay balance:");

column.addElement("other amount");

//all this logic is for the data part.

Vector rVector = new Vector();

try {

for(int i=0;i<3;i++) {

Vector data = new Vector();

data.addElement("invoice number:"+ i);

data.addElement("show balance" + i);

data.addElement("balance" + i);

data.addElement("pay balance:" + i);

data.addElement("other amount" + i);

rVector.addElement(data);

}

} catch (Exception e) {

e.printStackTrace();

}

//this is where you create the model

this.setModel(new DefaultTableViewModel(column));

// this.setModel(new DefaultTableViewModel(rVector, column));

}

}

MainCellRenderer ( I have created a new class in my package and imported in the jsp)

/*

  • Created on Nov 23, 2007

*

  • To change the template for this generated file go to

  • Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments

*/

package com.linde.myaccounts.util;

/**

  • @author zm46187

*

  • To change the template for this generated type comment go to

  • Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments

*/

import com.sapportals.htmlb.Link;

import com.sapportals.htmlb.rendering.IPageContext;

import com.sapportals.htmlb.table.ICellRenderer;

import com.sapportals.htmlb.table.TableView;

public class MainCellRenderer implements ICellRenderer {

/**

  • The class, which renders the user type. In the bean we declared column 1 and 3 as type USER

  • For the 2 columns we define a cell renderer. In column 1 we set a drop down listbox

  • and in the column 3 we set an input field with the field type DATE and showHelp="TRUE"

  • This will bring up a help button at the end of the input field. When the user clicks the

  • button the date navigator comes on and the date can be selected from the calender.

  • See the HTMLB Reference for details on inputField.

*/

public void renderCell(int row, int column, TableView tableView, IPageContext rendererContext) {

System.out.println("===table VIEW cell renderer called===");

if (column == 1) {

Link link = new Link("myLink");

//link.setOnClick("GetDetails");

link.addText(tableView.getValueAt(row,column).toString());

link.render(rendererContext);

}

}

}

I am getting a error during rendering of jsp component. Is this <%mytableView1.setUserTypeCellRenderer(new MainCellRenderer());%> wrong? Bcoz when I remove this line I am able to see a empty table. Kindly help!! this is very urgent issue..Please help

Regards,

Priyanka

Answers (0)