Skip to Content
author's profile photo Former Member
Former Member

Date Field in Tableview Cell

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 18, 2006 at 01:12 AM

    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);

    }

    }

    }

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.