Skip to Content
0
Former Member
Oct 26, 2005 at 12:02 PM

Problem in HTMLB..setOnClientClick()..Urgent Help....:)

18 Views

Hello All,

I have 2 jsp files named:

1> NewOrder.jsp -> This file uses HTMLB Taglib style. includes form and set its layout to gridlayout. It further includes/calls another jsp called "i1_NewOrder.jsp"

2> i1_NewOrder.jsp -> This includes all the GUI elements like inputfield, textview, etc. This forms a TableView.

Question:

I have added a button in i1_NewOrder.jsp and have fired an event using AddLine.setOnClientClick("javascript:AddLines()");

Now, an alert is being executed (refer to the code below), which has been written in NewOrder.jsp file.

What I want is that when I click on this button (say "AddNewLine"), a new row should be added in the TableView that is being built up using i1_NewOrder.jsp file.

How can I get a reference of TableView from i1_NewOrder.jsp to NewOrder.jsp??

If you se the code, I have tried to do this, but failed 😔

Code:

1> NewOrder.jsp

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

<%@ page import="com.sapportals.htmlb.*" %>

<%@ page import="com.sapportals.htmlb.enum.*" %>

<%@ page import="com.sapportals.htmlb.table.*" %>

/*<script language="JavaScript">

function AddLines()

{ var rowcnt;

alert("Hi");

rowcnt = tvOrderDetails.getRowCount();

document.write(rowcnt);

rowcnt++;

}

</script> */

<jsp:useBean id="beanOrderDetails" scope="session" class="com.sap.NewOrderAssignment.BeanOrderDetails" />

<hbj:content

id="contextNewOrder">

<hbj:page

title="New Order">

<hbj:form

id="formNewOrder">

<hbj:gridLayout

id="gridNewOrder"

debugMode="False"

width="100%"

cellSpacing="2">

<%@ include file="i1_NewOrder.jsp"%>

</hbj:gridLayout>

</hbj:form>

</hbj:page>

</hbj:content>

-


2> i1_NewOrder.jsp

<%

//****** define the cells **********//

GridLayoutCell cellEmpty = new GridLayoutCell("&nbsp;");

GridLayoutCell cellLabelEmpty = new GridLayoutCell("&nbsp;");

GridLayoutCell cellGeneralOrderInfo = new GridLayoutCell("&nbsp;");

GridLayoutCell cellDetailsOrderInfo = new GridLayoutCell("&nbsp;");

GridLayoutCell cellLabelYourOrderNo = new GridLayoutCell("&nbsp;");

GridLayoutCell cellLabelCustomer = new GridLayoutCell("&nbsp;");

GridLayoutCell cellLabelOrderDate = new GridLayoutCell("&nbsp;");

GridLayoutCell cellLabelAddress = new GridLayoutCell("&nbsp;");

cellLabelAddress.setVAlignment(CellVAlign.TOP);

GridLayoutCell cellLabelRequestedDelDate = new GridLayoutCell("&nbsp;");

GridLayoutCell cellLabelCompletedelivery = new GridLayoutCell("&nbsp;");

GridLayoutCell cellLabelGIM = new GridLayoutCell("&nbsp;");

GridLayoutCell cellLabelDeliveryAddress = new GridLayoutCell("&nbsp;");

GridLayoutCell cellInputYourOrderNo = new GridLayoutCell("&nbsp;");

GridLayoutCell cellinputRequestedDelDate = new GridLayoutCell("&nbsp;");

GridLayoutCell cellTvCustomer = new GridLayoutCell("&nbsp;");

GridLayoutCell cellTvOrderDate = new GridLayoutCell("&nbsp;");

GridLayoutCell cellTvAddress = new GridLayoutCell("&nbsp;");

GridLayoutCell cellTvDeliveryAddress = new GridLayoutCell("&nbsp;");

GridLayoutCell cellCBCompleteDelivery = new GridLayoutCell("&nbsp;");

GridLayoutCell cellCBGIM = new GridLayoutCell("&nbsp;");

GridLayoutCell cellTVOrderLines = new GridLayoutCell("&nbsp;");

GridLayoutCell cellButtonAddLine = new GridLayoutCell("&nbsp;");

//****** define design values for cells **********//

// Design values for labels

//****** define the visible gui elements and assign to the cell **********//

//order details

TableView tvOrderDetails = new TableView("tvOrderDetails");

tvOrderDetails.setModel(beanOrderDetails.getOrderLines());

tvOrderDetails.setSelectionMode(TableSelectionMode.MULTISELECT);

cellTVOrderLines.setColSpan(6);

cellTVOrderLines.setContent(tvOrderDetails);

//General order info: header>

TextView tvGeneralOrderInfo = new TextView("General Order Information");

cellGeneralOrderInfo.setColSpan(6);

cellGeneralOrderInfo.setContent(tvGeneralOrderInfo);

//General order details>

TextView tvDetailsOrderInfo = new TextView("Order details");

cellDetailsOrderInfo.setColSpan(6);

cellDetailsOrderInfo.setContent(tvDetailsOrderInfo);

//label Your order number

TextView labelYourOrderNo = new TextView("Your order number");

cellLabelYourOrderNo.setWidth("150");

cellLabelYourOrderNo.setContent(labelYourOrderNo);

//Input Your order number

InputField inputYourOrderNo = new InputField("InputYourOrderNo");

cellInputYourOrderNo.setWidth("200");

cellInputYourOrderNo.setContent(inputYourOrderNo);

//label Customer

TextView labelCustomer = new TextView("Customer");

cellLabelCustomer.setWidth("150");

cellLabelCustomer.setContent(labelCustomer);

//Textview customer

TextView tvCustomer = new TextView("tvCustomer");

cellTvCustomer.setContent(tvCustomer);

//label Order date

TextView labelOrderDate = new TextView("Order Date");

cellLabelOrderDate.setContent(labelOrderDate);

//Text view order date

TextView tvOrderDate = new TextView("tvOrderDate");

cellTvOrderDate.setContent(tvOrderDate);

//last check

//Label address

TextView labelAddres = new TextView("Address");

cellLabelAddress.setContent(labelAddres);

//text view address

TextView tvAddress = new TextView("Tjaskerlaan");

cellTvAddress.setContent(tvAddress);

//Label Requested delivery date

TextView labelRequestedDelDate = new TextView("Requested Delivery Date");

cellLabelRequestedDelDate.setContent(labelRequestedDelDate);

//Label Complete delivery

TextView labelCompleteDelivery = new TextView("Completed Date");

cellLabelCompletedelivery.setContent(labelCompleteDelivery);

//Checkbox Complete delivery

Checkbox cbCompleteDelivery = new Checkbox("cbCompleteDelivery");

cellCBCompleteDelivery.setContent(cbCompleteDelivery);

//Label Complete GIM

TextView labelGIM = new TextView("GIM");

cellLabelGIM.setContent(labelGIM);

//Checkbox GIM

Checkbox cbGIM = new Checkbox("cbGIM");

cellCBGIM.setContent(cbGIM);

//Label delivery address

TextView labelDeliveryAddres = new TextView("Delivery Address");

cellLabelDeliveryAddress.setContent(labelDeliveryAddres);

//text view address

TextView tvDeliveryAddress = new TextView("Tjaskerlaan");

cellTvDeliveryAddress.setContent(tvDeliveryAddress);

// listbox delivery addresses

ListBox lbDeliveryAddress = new ListBox("lbDeliveryAddress");

cellTvDeliveryAddress.setContent(lbDeliveryAddress);

Button AddLine = new Button("AddLine","Add New Line");

cellButtonAddLine.setContent(AddLine);

//AddLine.disabled=true;

AddLine.setOnClientClick("javascript:AddLines()");

//----


//****** add cells to grid **********//

gridNewOrder.addCell(1, 1, cellGeneralOrderInfo);

gridNewOrder.addCell(2, 1, cellLabelYourOrderNo);

gridNewOrder.addCell(2, 2, cellInputYourOrderNo);

//gridNewOrder.addCell(2, 3, cellEmpty);

gridNewOrder.addCell(2, 4, cellLabelCustomer);

gridNewOrder.addCell(2, 5, cellInputYourOrderNo);

gridNewOrder.addCell(2, 6, cellEmpty);

gridNewOrder.addCell(3, 1, cellLabelOrderDate);

gridNewOrder.addCell(3, 2, cellTvOrderDate);

//gridNewOrder.addCell(3, 3, cellEmpty);

gridNewOrder.addCell(3, 4, cellLabelAddress);

gridNewOrder.addCell(3, 5, cellInputYourOrderNo);

gridNewOrder.addCell(4, 1, cellLabelRequestedDelDate);

gridNewOrder.addCell(4, 2, cellInputYourOrderNo);

//gridNewOrder.addCell(4, 3, cellEmpty);

gridNewOrder.addCell(4, 4, cellLabelEmpty);

gridNewOrder.addCell(4, 5, cellInputYourOrderNo);

gridNewOrder.addCell(5, 1, cellLabelCompletedelivery);

gridNewOrder.addCell(5, 2, cellCBGIM);

//gridNewOrder.addCell(5, 3, cellEmpty);

gridNewOrder.addCell(5, 4, cellLabelDeliveryAddress);

gridNewOrder.addCell(5, 5, cellTvDeliveryAddress);

gridNewOrder.addCell(6, 1, cellLabelGIM);

gridNewOrder.addCell(6, 2, cellCBGIM);

gridNewOrder.addCell(6, 3, cellEmpty);

gridNewOrder.addCell(6, 4, cellLabelEmpty);

gridNewOrder.addCell(7, 4, cellLabelEmpty);

gridNewOrder.addCell(6, 6, cellEmpty);

gridNewOrder.addCell(8, 1, cellEmpty);

gridNewOrder.addCell(9, 1,cellDetailsOrderInfo);

gridNewOrder.addCell(10, 1,cellTVOrderLines);

gridNewOrder.addCell(11,1,cellButtonAddLine);

%>

Awaiting Reply.

Please help.

Thanks and Warm Regards,

Ritu