cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to serialize a web dynpro component controller?

jj1
Associate
Associate
0 Kudos

Hi,

Is it possible to serialize a web dynpro component controller and deserialize it for use?

I have one web dynpro application WDA1 for web dynpro component WDC1. And another web dynpro application WDA2 for WDC2 will be opened in a new window triggered by a button action in WDC1.

Iu2019d like to pass the object reference of WDC1 component controller to WDC2.

I first tried to use a static member of a class object but found out that even the static member is initialized and set in WDC1, itu2019s still initial when I access it in WDC2.

Then I searched the forum and found one article .

The recommended way is to serialize the object reference and store in a DB table, later on read it out and deserialize it for use.

I tried serialization using the following code, but when itu2019s deserialized, the result is initial.

Can anyone share some ideas on this?

Serialize


  data: ostream type string,
           xslt_err type ref to cx_xslt_exception.
***** serialize model class
  try.
      call transformation id
      source model = wd_comp_controller
      result xml ostream.

    catch cx_xslt_exception into xslt_err.

  endtry.

Deserialize


    data: istream type string,
          xslt_err type ref to cx_xslt_exception.

    istream = ls_db_sel-obj.
    data lr_wdc type REF TO ZIWCI_BY_WDC_SERIALIZE.
    try.
        call transformation id
        source xml istream
        result model = lr_wdc.
        
      catch cx_xslt_exception into xslt_err.
    endtry.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

When you say new window, I assume you mean new browser window. This is a separate user session then. This is why the singleton pattern doesn't work. Have you considered using a new dialog window instead of a new browser window. It will be modal, but will share the same user session as the parent window.

>Why do you choose this approach over cross-component usage ? component usage is the way webdynpro components are >to be reused.

>You can also consider using Singleton OO pattern class to share data between these two components.

Neither of these approaches will work if you are using separate browser windows. Such an approach results in two separate user sessions (perhaps even running on different application servers depending upon how you have load balancing setup) and therefore can't share data using either of these approaches.

In general the idea of serialization and then writing the string ito a server cookie or other database table is sound. I don't think you should try and serialize the component controller, however. Serialization only saves and restores public attributes - not protected or private ones. So in general a class has to be designed for serialization. The component controller is much too complex and wasn't designed for such an operation.

I would suggest instead extracting the data you want to share out of component controller or context and serializing it into a custom class and passing that to the other component.

Former Member
0 Kudos

>

> When you say new window, I assume you mean new browser window. This is a separate user session then. This is why the singleton pattern doesn't work.

>

Hallo Thomas,

Can an object in Shared Memory serve the purpose here ?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Yes and no. Shared memory is per application server. In a production environement with multiple application servers, depending upon how you perform load balancing, you can find the new session opened on a different application server than the parent. You can't depend upon the fact that you will be on the same application server. This would mean needing some sort of replication routine to copy the shared memory object to all available application servers. This is why I personal would recommend the database/server cookie approach over the shared memory one.

Former Member
0 Kudos

Hi Thomas,

Clear !! Thanks for the explanation.

jj1
Associate
Associate
0 Kudos

Hi Thomas,

Thank you very much for the help here. I tried the suggested way to open a new dialog window and I can get the object reference now using a static member approach.

Best regards,

Beiyang

Answers (1)

Answers (1)

Former Member
0 Kudos

>

> Hi,

>

> Is it possible to serialize a web dynpro component controller and deserialize it for use?

>

> I have one web dynpro application WDA1 for web dynpro component WDC1. And another web dynpro application WDA2 for WDC2 will be opened in a new window triggered by a button action in WDC1.

>

>

Hi Beiyang,

Why do you choose this approach over cross-component usage ? component usage is the way webdynpro components are to be reused.

You can also consider using Singleton OO pattern class to share data between these two components.