cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger server event component view .htm page

0 Kudos

Hey,

We have requirement to trigger server round trip after spesific device has finished it's automatic input.

Scenario is like this:

1. We have input field on enhanced view

2. We place cursor on the field, and activate device.

3. Device first simulates enter button which triggers server roundtrip and then outputs content to the field

4. In set method for the attribute we wait for few seconds - to delay refresh from roundtrip and raise spesific flag that indicates that device is performing data output to the field.

5. Now in .htm of the field we want to read the flag from view controller and if it is raised, then trigger roundtrip again. The idea of this round trip is to push device output, that is now visible in the inputField to CRM backend.

This also happens if user now submits using enter button, but we want to avoid user having to do this every time.

If we understand correctly we have to trigger server event using Javascript:

We have tried several ideas including this one:

<bsp:htmlbEvent name = "fireServerEvent"
                Id   = "fireServerEvent"
                p1   = "p1"
                p2   = "p2" />
<script language="javascript">
    fireServerEvent( p1 = "first_parameter"
                     p2 = "second_parameter" );
</script>

But the script is not triggering server side event - breakpoint in view controller do_handle_event method is not triggered.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Instead of triggering server event we have now made new tag as an enhancement from inputField tag.

We changed implementation of tag by copying IF_BSP_ELEMENT~DO_AT_BEGINNING from inputField class and adjusting it slightly so that generated html/javascript coding is different for onkeydown attribute.

Original coding generated was something like this:

onkeydown="if(htmlbEnterKey(event)) {

blur(this);  

focus(this);  

return htmlbSL(this,2,'<field_ID>:submitonenter','0')};"

Method was adjusted to generate code similar to this:

onkeydown="if(this.value)

{

  if(htmlbEnterKey(event)) 

  {       

     blur(this);        

     focus(this);         

     return htmlbSL(this,2,'<field_id>:submitonenter','0')};   

  } 

else 

{

  event.preventDefault();

}"

HINT: To find best place to adjust code search method for keyword "submit".

Intended effect is that ENTER is not triggering submit when field is empty, but triggering it when field has some content.

This seems to be working as well.

Answers (2)

Answers (2)

0 Kudos

Still searching for solution, but it seems what I need is input field, that would not send server round trip on <ENTER> if input is empty, and send it throguh if input is not empty.

0 Kudos

I have also now tried to move the whole solution to a popup.

The solution is the same - I raise a flag during set method and call outbound plug during do_prepare_output if flag is raised.

The popup is exited correctly, but screen content is not pushed to BOL.