BSP 技术测试02 -- A Small BSP Application (No MVC & With HTMLB)

参考SAP标准文档做的技术测试:

http://help.sap.com/saphelp_nw04/helpdata/en/6d/275a2ddb68b14790d09b383507f044/content.htm

 

基本操作与前一篇文章大同小异, 不同之处是这里采用了SAP的HTMLB控件, 从而导致Layout和Event Handler会有所不同, 但大同小异, 代码很简单, 还是很容易理解的, 这里只列出不同部分, 相同之处请参见前一篇文章.

 

1. 创建程序过程及涉到的页面均与前一篇文章相同.

 

2. Default.htm

     LayOut代码:

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:
content>
  <htmlb:page 
title="my Title" >
    <
table width="100%" height="100%" cellspacing="1" cellpadding="2" border="0">
                <
tr class="sapTbvCellStd"> <td bgcolor="Whitesmoke" valign="top">
         <
h2> Welcome to our Online Book Catalog! </h2>
    <
p>
    This bookshop offers 
a small selection of interesting books.
    <
p>
        <
img height="130" src="../PUBLIC/Tutorial/book2.jpg ">
        <
img height="130" src="../PUBLIC/Tutorial/book2.jpg ">
        <
img height="130" src="../PUBLIC/Tutorial/book2.jpg ">
    <
p>
    <htmlb:
form id           = "myFormId"
                
method       = "post"
                encodingType = 
"multipart/form-data" >
      <htmlb:group 
id        = "group1"
                   bodyColor = 
"whitesmoke"
                   design    = 
"SAPCOLOR"
                   
width     = "500" >
        <htmlb:groupBody>
          To display all the books written by an author, enter the 
name of the author in the fields below and
          choose <
i>books by this author</i>.
           <
br>
          <htmlb:
label id      = "authorlname_Label"
                       
for     = "authorlname"
                       
text    = "last name"
                       tooltip = 
"author's last name" />
          <htmlb:inputField 
id    = "authorlname"
                            
value = "<%= authorlname %>" />
          <
img width="30"  src="../PUBLIC/Tutorial/blind.gif">
          <htmlb:
label id      = "authorfname_Label"
                       
for     = "authorfname"
                       
text    = "first name"
                       tooltip = 
"author's first name" />
          <htmlb:inputField 
id    = "authorfname"
                            
value = "<%= authorfname %>" />
          <
p>
          To display all the authors whose books we offer, choose <
i>to list of authors</i>.
          <
p>
          To display all books we offer, just choose
          <
i>books by this author</i> without entering a name.
          <
br>
          <htmlb:
button id      = "search"
                        
text    = "books by this author"
                        
onClick = "onInputProcessing(select)" />
          <
img width="30"  src="../PUBLIC/Tutorial/blind.gif">
          <htmlb:
button id      = "authorlist"
                        
text    = "to list of authors"
                        
onClick = "onInputProcessing(authors)" />
        </htmlb:groupBody>
      </htmlb:group>
    </htmlb:
form>
    </
td> </tr> </table>
  </htmlb:page>
</htmlb:
content>

   因为采用了HTMLB控件, 所以Event Handler也变更如下:

   

CLASS CL_HTMLB_MANAGER DEFINITION LOAD.
* Optional: test that this is an event from HTMLB library.
IF EVENT_ID = CL_HTMLB_MANAGER=>EVENT_ID.
* See if upload is triggered from button
  
DATAEVENT TYPE REF TO CL_HTMLB_EVENT.
  
EVENT = CL_HTMLB_MANAGER=>GET_EVENT( RUNTIME->SERVER->REQUEST ).
  
IF EVENT->NAME = 'button' AND EVENT->EVENT_TYPE = 'click'.
    
DATA: BUTTON_EVENT TYPE REF TO CL_HTMLB_EVENT_BUTTON.
    BUTTON_EVENT ?= 
EVENT.
  
ENDIF.
  
CASE EVENT->ID.
    
WHEN 'search'.
      
DATA: LNAME TYPE REF TO CL_HTMLB_INPUTFIELD.
      
DATA: FNAME TYPE REF TO CL_HTMLB_INPUTFIELD.
      LNAME ?= CL_HTMLB_MANAGER=>GET_DATA(
                          REQUEST = RUNTIME->SERVER->REQUEST
                          NAME    = 
'inputField'
                          
ID      = 'authorlname'
                                        ).
      
IF LNAME IS NOT INITIAL.
        AUTHORLNAME = LNAME->VALUE.
      
ENDIF.
      FNAME ?= CL_HTMLB_MANAGER=>GET_DATA(
                          REQUEST = RUNTIME->SERVER->REQUEST
                          NAME    = 
'inputField'
                          
ID      = 'authorfname'
                                        ).
      
IF FNAME IS NOT INITIAL.
        AUTHORFNAME = FNAME->VALUE.
      
ENDIF.
      NAVIGATION->SET_PARAMETER( 
'authorlname' ).
      NAVIGATION->SET_PARAMETER( 
'authorfname' ).
      NAVIGATION->NEXT_PAGE( 
'TORESULTS' ).
    
WHEN 'authorlist'.
      NAVIGATION->NEXT_PAGE( 
'TOAUTHORS' ).
    
WHEN OTHERS.
  
ENDCASE.
ENDIF.

  

其他的代码和设置均与前一篇文章相同, 此处略之.

3. Authors.htm

    Layout代码:

   

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:
content>
  <htmlb:page 
title        = "List of Authors"
              marginBottom = 
"10"
              marginLeft   = 
"10"
              marginRight  = 
"10"
              marginTop    = 
"10"
              scrolling    = 
"yes" >
    <
table width="100%" height="100%" cellspacing="1" cellpadding="2" border="0">
              <
tr class="sapTbvCellStd"> <td bgcolor="Whitesmoke" valign="top">
    <htmlb:
form>
      <htmlb:tableView 
id            = "tv1"
                       headerText    = 
"List of Authors"
                       headerVisible = 
"true"
                       footerVisible = 
"false"
                       design        = 
"ALTERNATING"
                       
table         = "<%= authors %>" >
        <htmlb:tableViewColumns>
          <htmlb:tableViewColumn columnName = 
"authfnam"
                                 
title      = "first name" >
          </htmlb:tableViewColumn>
          <htmlb:tableViewColumn columnName = 
"authlnam"
                                 
title      = "last name" >
          </htmlb:tableViewColumn>
        </htmlb:tableViewColumns>
      </htmlb:tableView>
    </htmlb:
form>
    </
td></tr></table>
  </htmlb:page>
</htmlb:
content>

其他的代码和设置均与前一篇文章相同, 此处略之.

 

4. Results.htm

      Layout代码

    

<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:
content>
  <htmlb:page 
title="Books that match your query" >
    <
table width="100%" height="100%" cellspacing="1" cellpadding="2" border="0">
                <
tr class="sapTbvCellStd"> <td bgcolor="Whitesmoke" valign="top">
    <
h2> Your Book Search Results </h2>
    
<%
  
if books is initial.
    
%>
    page->messages->add_message(
"That was wrong").
    
<%-- <h3> Sorry, we found no matches for <%= authorlname %>, <%= authorfname %>. </h3> --%>
    
<%
  
else.
    
%>
    <
h3> The matches for this search are: </h3>
    <htmlb:
form>
      <htmlb:tableView 
id            = "tv2"
                       headerText    = 
"Books that match your query"
                       headerVisible = 
"true"
                       footerVisible = 
"false"
                       design        = 
"ALTERNATING"
                       
table         = "<%= books %>" >
        <htmlb:tableViewColumns>
          <htmlb:tableViewColumn columnName = 
"authfnam"
                                 
title      = "Author's first name" >
          </htmlb:tableViewColumn>
          <htmlb:tableViewColumn columnName = 
"authlnam"
                                 
title      = "Author's last name" >
          </htmlb:tableViewColumn>
          <htmlb:tableViewColumn columnName = 
"title"
                                 
title      = "Book Title" >
          </htmlb:tableViewColumn>
          <htmlb:tableViewColumn columnName = 
"isbn"
                                 
title      = "ISBN" >
          </htmlb:tableViewColumn>
        </htmlb:tableViewColumns>
      </htmlb:tableView>
    </htmlb:
form>
    
<%
  
endif.
    
%>
    </
td></tr></table>
  </htmlb:page>
</htmlb:
content>

5. 运行效果:

BSP 技术测试02 -- A Small BSP Application (No MVC & With HTMLB)_第1张图片

6. 测试环境:

你可能感兴趣的:(mvc,manager,测试,layout,application,border)