cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in transfring attributes.

former_member184111
Active Contributor
0 Kudos

Hi All,

I am practicing with a simple application where i have two inputfields and a submit button on a BSP page.

If i input a value in first inputfield then on pressing submit button some calculations are done and the result is shown in second inputfield same happens if i input a value in second inputfield.

<b>The code for layout is:</b>

<htmlb:content design="design2003" >

<htmlb:page title="First page" >

<htmlb:form id="form1" >

<htmlb:label for="field1" text="Enter % Disc." />

<htmlb:inputField id = "field1"

value = "<%= var2 %>"

type = "INTEGER"

alignment = "CENTER" />

<htmlb:label for="field2" text="Enter Disc. in Rs." />

<htmlb:inputField id = "field2"

value = "<%= var1 %>"

type = "INTEGER"

alignment = "CENTER" />

<htmlb:button id = "submit"

text = "Press Me"

onClientClick = "javascript:checkInput();" />

</htmlb:form>

</htmlb:page>

</htmlb:content>

<b>Code of onInputProcessing is:</b>

class cl_htmlb_manager definition load .

data: event 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 'submit'.

data: input1 type ref to cl_htmlb_inputfield .

data: input2 type ref to cl_htmlb_inputfield .

input1 ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'inputField'

id = 'field1' ).

input2 ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'inputField'

id = 'field2' ).

if field1 is initial .

var1 = ( field2 * 100 ) / 5000 .

else.

var2 = ( field1 * 5000 ) / 100 .

endif.

<b>And page attribtes are:</b>

field1 TYPE I (auto)

field2 TYPE I (auto)

var1 TYPE I (auto)

var2 TYPE I (auto)

Here when i debug i get proper values in field1 , field2 and var1 , var2 , But these values are not getting passed .ie. value is not displayed in browser when the page is reloaded.

Note that i m navigating to the same page only.

Thanks ,

Anubhav.

Accepted Solutions (0)

Answers (1)

Answers (1)

raja_thangamani
Active Contributor
0 Kudos

I noticed you have shuffled the var1 & var2. I mean field1 has value of Var2 & field2 has value of Var1. Correct them as show below. It shd work.

<htmlb:inputField id = "field1"
value = "<%= var1 %>"
type = "INTEGER"
alignment = "CENTER" />
<htmlb:label for="field2" text="Enter Disc. in Rs." />

<htmlb:inputField id = "field2"
value = "<%= var2 %>"
type = "INTEGER"
alignment = "CENTER" />

Raja T

former_member184111
Active Contributor
0 Kudos

Hi Raja,

Logically your answer is correct but it has nothing to do with transfer of values.Sorry to bother you but when i deleted the line navigation->to_page(TOFINAL) ,the values of variables are retained , even after the page is reloaded.

Now the problem is that even after refreshing the page the values are not cleared ie the inputfield contains the previous values even after refreshing.

Thanks,

Anubhav.

raja_thangamani
Active Contributor
0 Kudos

If you want to refresh the value, CLEAR the fields after the calculation.

Raja T

former_member184111
Active Contributor
0 Kudos

If I clear the fields after calculaion, the input fields are blank when the pageis reloaded.

Anubhav.

raja_thangamani
Active Contributor
0 Kudos

Thats what you wanted rite? clear only those fields which you wanted to refresh.

Raja T

former_member184111
Active Contributor
0 Kudos

Sir , Thers a little bit of confusion here.

Actually the scenario is like this:

When i enter value in one field and click Submit buton i should get the result in second input box.

Until here its working perfect,

But when i refresh the page the inputboxes should be cleared , this is not happening and if i clear the variables after calculation , i dont get any values on pressing the Submit button .

<b>one more thing </b>

How can we handle Mouse click (left)? using javascript..

I will be greatfull to you if you can solve this query too.

Regards,

Anubhav.

raja_thangamani
Active Contributor
0 Kudos

can post your code where you clear the values?

Regarding <i>How can we handle Mouse click (left)? using javascript</i>

Please dont mix up the thread. have one question in one thread..Open new thread for new issues..

Raja T

former_member184111
Active Contributor
0 Kudos

The Code is:

class cl_htmlb_manager definition load .

data: event 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 'submit'.

<b> clear: var1 , var2 ,var3 , var4 , var5 , var5 , var6 .</b>

data: input1 type ref to cl_htmlb_inputfield .

data: input2 type ref to cl_htmlb_inputfield .

data: input3 type ref to cl_htmlb_inputfield .

data: input4 type ref to cl_htmlb_inputfield .

data: input5 type ref to cl_htmlb_inputfield .

data: input6 type ref to cl_htmlb_inputfield .

input1 ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'inputField'

id = 'field1' ).

input2 ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'inputField'

id = 'field2' ).

input3 ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'inputField'

id = 'field3' ).

input4 ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'inputField'

id = 'field4' ).

input5 ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'inputField'

id = 'field5' ).

input6 ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'inputField'

id = 'field6' ).

if field1 is initial .

var1 = ( field2 * 100 ) / 5000 .

var2 = field2 .

else.

var2 = ( field1 * 5000 ) / 100 .

var1 = field1 .

endif.

if field3 is initial .

var3 = ( field4 * 100 ) / 5000 .

var4 = field4 .

else.

var4 = ( field3 * 5000 ) / 100 .

var3 = field3 .

endif.

if field5 is initial .

var5 = ( field6 * 100 ) / 5000 .

var5 = field6 .

else.

var6 = ( field5 * 5000 ) / 100 .

var5 = field5 .

endif.

navigation->set_parameter( 'var1').

navigation->set_parameter( 'var2' ).

navigation->set_parameter( 'var3').

navigation->set_parameter( 'var4' ).

navigation->set_parameter( 'var5').

navigation->set_parameter( 'var6' ).

endcase.

raja_thangamani
Active Contributor
0 Kudos

Can you please explain me in what case WHICH field shd be blank after the reload? so it will be easy to asnwer without any confusion.

Also please post the layout.

Raja T

former_member184111
Active Contributor
0 Kudos

Sir i guess it wil be simpler to take example with only two input fields intead of six.

So the event handling code is as folows:

class cl_htmlb_manager definition load .

data: event 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 'submit'.

clear: var1 , var2 .

data: input1 type ref to cl_htmlb_inputfield .

data: input2 type ref to cl_htmlb_inputfield .

input1 ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'inputField'

id = 'field1' ).

input2 ?= cl_htmlb_manager=>get_data(

request = runtime->server->request

name = 'inputField'

id = 'field2' ).

if field1 is initial .

var1 = ( field2 * 100 ) / 5000 .

else.

var2 = ( field1 * 5000 ) / 100 .

endif.

navigation->set_parameter( 'var1').

navigation->set_parameter( 'var2' ).

endcase .

User have to enter value in any one and only one inputbox .

When he presses the submit button some calculations are done (as you can see above) and the reslt is displayed in other inputbox.

After this cycle whhen we press F5 or refresh the page the values should be cleared .This is not happeninn and after refreshing also the old values (One the user entered in and other the RESULT ) are still there on the page.

raja_thangamani
Active Contributor
0 Kudos

you can not control the F5 or Refresh event. Any browser will resend post data on refresh.

Raja T

former_member184111
Active Contributor
0 Kudos

Hi Raja,

My confusion is cleared .I got your point.

Thanks a lot .

Anubhav