cancel
Showing results for 
Search instead for 
Did you mean: 

Validation in mvc

Former Member
0 Kudos

Hi sdn,

Please tell me how to do the validation in mvc.

if input1 eq ' ' and input2 eq ' '. (or) if input1 is initial and input2 is initial .

if sy-subrc = 0.

str = ''enter input values'.

endif.

endif.

this code is compiled,in the execution getting the error null pointer exception. Please tell me sample programme.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi RamKumar,

By the if statement 'Sy-SUBRC' is not triggered. please remove that sy-subrc and just keep that code in if loop and you will get the required output.

Hope this will solve your problem.

Former Member
0 Kudos

Hi Raju,

I already tried remove with sy-subrc.

Answers (1)

Answers (1)

Former Member
0 Kudos

The following steps will help you validate....

define two attributes...in the class (public)

gt_errmsg type string

gt_errtype type string

In the controller class do_handle_event method...

data: eventid type string,

input1 type string,

input2 type string.

input1 = request->get_form_field( 'input1' ).

input2 = request->get_form_field( 'input2' ).

eventid = htmlb_event_ex->event_id.

case eventid.

when 'Save'.

if input1 is initial or input2 is initial.

gt_errmsg = 'Fields cannot be null'.

gt_errtype = 'Error'.

exit.

endif.

endcase.

In the do_request method....

lirv_page->set_attribute( name = 'gt_errmsg' value = gt_errmsg ).

lirv_page->set_attribute( name = 'gt_errtype' value = gt_errtype ).

In you htm page...

gt_errmsg type string

gt_errtype type string

and in the top of the layout page...

<phtmlb:messageBar id = "mBar"

rulerDisplay = "BOTTOM"

type = "<%= gt_errtype %>"

text = "<%= gt_errmsg %>" >

myFormId.setMessageBar(mBar).

</phtmlb:messageBar>