on 08-30-2007 10:36 AM
Hi All,
Im new to BSP, I created the controller class and model class for a application which will add two numbers and display the result.
Im giving the two numbers from the BSP page using <b>input field</b>.
I have no error in the application but the data is not passed from the BSP page for process but i got the result when i tried by hard coding the values.
Please guide me,
Thanks,
Sarath.C
You have done Static Binding in your code.
<htmlb:inputField id = "value1"
value = "<%= model->value1 %>" />
So, you need to catch the value explicitly in do_handle_event.
Like this:
<i>DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.
data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server-request
name = 'inputField'
id = 'value1' ).</i>
Or else, use Dynamic Binding in the Layout. Like this:
<htmlb:inputField id = "value1"
value = "//model/value1" />
Hope it helps!
Regards,
Kapali
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank u very much Kapali, I got the answer.
DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.
data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server-request
name = 'inputField'
id = 'value1' ).
The above gave me an error saying SERVER is an object reference and hence does not have a component called REQUEST.
but this solved my problem,
<htmlb:inputField id = "value1"
value = "//model/value1" />
Please paste the code of you have written in the "Layout" i.e. your BSP Page/View.
Regards,
Kapali
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> Please paste the code of you have written in the
> "Layout" i.e. your BSP Page/View.
>
> Regards,
> Kapali
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="design2003">
<htmlb:page title = "Main Page ">
<htmlb:form>
<htmlb:tray id = "tray1"
width ="100%" >
<center>
<htmlb:textView text = "ADDITION"
design = "EMPHASIZED" />
<br>
<htmlb:gridLayout id = "maingrid"
width = "70%"
cellSpacing = "2"
columnSize = "2"
rowSize = "4" >
<htmlb:gridLayoutCell
id = "cell11"
rowIndex = "1"
columnIndex = "1"
style = "TRANSPARENT">
<htmlb:textView text = "Enter First Value : "
design = "EMPHASIZED" />
</htmlb:gridLayoutCell>
<htmlb:gridLayoutCell id = "cell12"
rowIndex = "1"
columnIndex = "2">
<htmlb:inputField id = "value1"
value = "<%= model->value1 %>" /> <br>
</htmlb:gridLayoutCell>
<htmlb:gridLayoutCell
id = "cell21"
rowIndex = "2"
columnIndex = "1"
style = "BORDER">
<htmlb:textView text = "Enter Second Value : " />
</htmlb:gridLayoutCell>
<htmlb:gridLayoutCell id = "cell22"
rowIndex = "2"
columnIndex = "2">
<htmlb:inputField id = "value2"
value = "<%= model->value2 %>" />
</htmlb:gridLayoutCell>
<br><br>
<% if model->result is not initial. %>
<htmlb:gridLayoutCell id = "cell31"
rowIndex = "3"
columnIndex = "1" >
<htmlb:textView text = "The Result is : " />
</htmlb:gridLayoutCell>
<htmlb:gridLayoutCell id = "cell32"
rowIndex = "3"
columnIndex = "2" >
<htmlb:inputField id = "result"
value = "<%= model->result %>" />
</htmlb:gridLayoutCell>
<%endif.%>
<br><br>
<htmlb:gridLayoutCell id = "cell32"
rowIndex = "4"
columnIndex = "1"
horizontalAlignment = "RIGHT" >
<htmlb:button id = "addition"
text = "Add"
onClick = "add" />
</htmlb:gridLayoutCell>
</htmlb:gridLayout>
</htmlb:tray>
</htmlb:form>
</htmlb:page>
</htmlb:content>
Ok. Could you please paste your code from the layout then?
Regards,
Kapali
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the code,
=============================================
method DO_INIT.
DATA: model TYPE REF TO zmodel_bsp_7936.
model ?= create_model( class_name = 'ZMODEL_BSP_7936'
model_id = 'model_main' ).
clear: model->value1,model->value2,model->result.
endmethod.
=============================================
method DO_REQUEST.
DATA: main_view TYPE REF TO if_bsp_page,
model TYPE REF TO zmodel_bsp_7936.
dispatch_input( ).
model ?= get_model( 'model_main' ).
main_view = create_view( view_name = 'main.htm' ).
main_view->set_attribute( name = 'model' value = model ).
call_view( main_view ).
endmethod.
=============================================
method DO_HANDLE_EVENT.
DATA: model TYPE REF TO ZMODEL_BSP_7936.
model ?= get_model( 'model_main' ).
IF htmlb_event->server_event = 'add'.
model->result = model->value1 + model->value2.
ENDIF.
endmethod.
=============================================
Did u call dispatch_input( ) in your DO-REQUEST of the controller?
it should be the 1st statement of your do_request method.
Regards,
Kapali
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I had similar problem. To me help when I set method (in controller and model) like public. The example which I saw before, had in controller private classes.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You need to catch the Input field values in your controller class method:
do_handle_data or
do_handle_request
and add them by using your model class method.
This code from F1 help might be helpful!
<i><i>DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.
data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server-request
name = 'inputField'
id = 'myInputField1' ).</i></i>
Regards,
Kapali
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
TRY This
DATA: data TYPE REF TO CL_HTMLB_INPUTFIELD.
data ?= CL_HTMLB_MANAGER=>GET_DATA( request = runtime->server->request
name = 'inputField'
id = 'myInputField1' ).
what kind of binding you are using for the variable on the view.. if you are using
<%=model->myinput %>
Try using
<%=//model/myvalue%>.
Cheers
Amandeep
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.