Open all | Close all
|
MVC BSP input field - Demonstrate how to retrieve a value entered into text input field
Below is the basic code for allowing users to input text onto a html page and retrieve what they have entered
using HTMLB and MVC techniques.
|
Display input field and retrieve value entered
Layout
------
The code below is HTMLB.
<htmlb:inputField id = "fieldId"
invalid = "true"
value = "<%=stuid%>"
required = "true"/>
DO_REQUEST method (within controller class)
-----------------
DATA: data_input TYPE REF TO cl_htmlb_inputfield,
ld_fieldid TYPE zstudtls-stuid.
data_input ?= cl_htmlb_manager=>get_data( request = runtime->server->request
name = 'inputfield'
id = 'fieldId' ).
IF data_input IS NOT INITIAL.
ld_fieldid = data_input->value.
ENDIF.
|
Display input field and retrieve value entered - Probably a better way
of doing it but documented second to highlight the difference
Layout
------
The code below is pure HTML and not HTMLB so you will need to remove the
htmlb code that SAP insert automatically.
<htmlb:content design="design2003">
<htmlb:page title = " ">
<htmlb:form>
<html>
<page>
<FORM NAME="formlist">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="RIGHT">
<INPUT TYPE="TEXT" NAME="gd_keywords" VALUE="gd_keywords" size=60>
<INPUT type="submit" name="OnInputProcessing(search)">
</td>
</tr></table>
</FORM>
</page>
</html>
OnInputProcessing
-----------------
case event_id. "declared in page attributes as type STRING
when 'search'.
* Sets value of parameter ready for next screen
* gd_keywords needs to declared as type STRING within page attributes
navigation->set_parameter( name = 'gd_keywords' ).
* If you create page 'courses.htm' with a field called keywords within
* page attributes then the value entered in this page will be passed
* through.
navigation->goto_page('courses.htm').
endcase.
|
|
|