cancel
Showing results for 
Search instead for 
Did you mean: 

Read Attributes between different views in the same Component

Former Member
0 Kudos

Hello,

I have a attribute-D1 declared in VIEW1 and i need to read it into attribute D2 declared in VIEW2.

I am planning to read it in DO_PREPARE_OUTPUT method of VIEW2.

Can you please tell me how can i achieve this without having to create another context node (similar type to VIEW1) in VIEW2 and Binding it.

Can't I just access the View Controller Class of VIEW1 to read it in VIEW2?

Quick replies would be great.

Regards

Dedeepya C

Accepted Solutions (0)

Answers (4)

Answers (4)

suchita_phulkar
Active Contributor
0 Kudos

Hi,

Check out this Wiki

[http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=201066680]

Hope it helps resolve your issue.

Thanks & Regards

Suchita

Former Member
0 Kudos

Please check Wiki there is a post explaining you can declare the instance of the context class in the context node itself so you have access to all the attributes of all the context nodes in the contextnode itself.

rgds,

CMP

former_member206299
Contributor
0 Kudos

Hi Deepa,

Declare a static attribute in the View controller of first view.

Read the attribute D1 value from DO_PREPARE_OUTPUT of first View and pass it to the Static sttribute.

In your 2nd view u can read this Static Atribute and use it.

Static Attribute u need to call as follows .

Z********IMPL(Implemantation Class)=>ATTR1

Regards,

Sijo

Former Member
0 Kudos

Hi Gangadhar & Sijo

Thanks for your timely replies.

However, my approach has been slightly different (example taken from a standard component)

1) I read the value for D1 in SEARCH event Handler which is called in DO_PREPARE_OUTPUT (for 1st time) and DO_HANDLE_EVENT(for 2nd time onwards).

2) For some unknown reason, when i click on search the control 1st goes to DO_INIT_CONTEXT of the view controller, 2nd to VIEWB.HTM & lastly to EVENT HANDLER Search where the attribute D is being set.

This happens only the 1st time!

From 2nd time onwards the control goes to EVENT HANDLER FIRST and then to VIEWB.HTM.

Due to this, the 1st time the attribute value in D1 is empty.

Any Idea why this happens?

What am i missing.?

Former Member
0 Kudos

Hello again,

I think i was not very clear in my earlier post. So il explain a bit more clearly this time-

My requirement is to display a SEARCH+RESULT popup (view) onclick of a link; and the popup display has the result list already fetched for the SEARCH Criteria(defaulted).

Now what i had to do was have the RESULT LIST TITLE display the number of records fetched.

So my approach was to -

1) READ the RESULT Size in EH_ONSEARCH of SEARCH VIEW.

2) Form the Result Title using method cl_crm_uiu_gen_tools=>get_result_title into a Public Ins Attribute GV_TITLE.

3) READ the GV_TITLE from SEARCHVIEW into a local attribute in SEARCHVIEWSET (SEARCH VIEW + RESULT VIEW) LV_TITLE.

   
 data : lv_result_title type string,
  lv_view_controller type ref to ZL_SEARCHVIEW_IMPL.
  lv_view_controller ?= controller->get_subcontroller_by_viewname( 'Ztest/SearchView' ). "#EC NOTEXT
  if lv_view_controller is bound.
  lv_result_title = lv_view_controller->gv_result_title.
  endif.
  <thtmlb:searchFrame showSearchFields = "TRUE"
                      resultListTitle  = "<%= lv_result_title %>" >
  </thtmlb:searchFrame>

Now, i noticed during debug, when the SEARCH Popup is triggered the 1st time, the control goes to SEARCHCVIEWSET.HTM 1st (GV_TITLE is initial at this point) and then goes to DO_PREPARE_OUTPUT where the Event Handler for SEARCH is called and where the GV_TITLE is set. Due to this the Result Tab gets the default title RESULT LIST

Whereas the next time, when i click on SEARCH event on popup, the control 1st goes to EVENT HANDLER (where GV_TITLE is set) and then to SEARCHVIEWSET.HTM, this then sets the correct title for RESULT list.

I need some pointers on why the control goes to SEARCHVIEWSET 1st before even DO_PREPARE_OUTPUT is called.

How do i set the RESULT Title in the 1st instance to display the correct no. of records fetched.

Any help would be appreciable.

Regards

Dedeepya

Former Member
0 Kudos

Hi ,

You can read the size of the result collection in the DO_PREPARE_OUTPUT of the result view itself an set it there.

By doing so,you issue of displaying the result title first time will be resolved since this Do_prepare_output should ideally be called before the viewset htm,always.

Suvidha

former_member214667
Contributor
0 Kudos

Hi Dedeepya

If the piece of code you have mentioned here is from .htm file, then you don't need to call GET_SUBCONTROLLER_BY_VIEWNAME( ) method here. If you just want to set the result list title, then I recommend the following:

1. Declare a public method in the view controller class of search view ; say GET_RESULT_TITLE( ) that returns a string.

2. If there are no results, then just return the text "Result List". Otherwise return gv_result_title that would have been filled by search.

3. Call this method in resultListTitle attribute as follow:

resultListTitle = "<%=controller->get_result_title( ) %>

This should solve it for you.

Former Member
0 Kudos

Hi all.

Thanks for the suggestions.

The issue i face is not of accessing context attributes between views;but of the control flow.

My problem is that SEARCHVIEWSET is called the 1st before any other view is called.

due to this the variable GV_RESULT i set in RESULT VIEW remains initial during display.

Is there no way i could bind this Variable GV_RESULT to Component Controller or would declaring it as STATIC help displaying the value set later in program?

Hope the problem im stating here is clear

Edited by: dedeepya reddy on Apr 19, 2011 12:27 PM

Former Member
0 Kudos

There is no way to bind a variable,but what you can do is infact declare the variable itself in the component controller impl class,and access it usign the class instance.I don't think making the variable as static will help you.

Suvidha

Former Member
0 Kudos

The issue could nt be resolved.

Thank U all for ur valuable inputs.

- Dedeepya

Former Member
0 Kudos

The issue could nt be resolved.

Thank U all for ur valuable inputs.

Thread lies closed.

- Dedeepya

Former Member
0 Kudos

Hi ,

Bind the context node of View1 with Component controller.

and in View2

data lr_comp_controller type ref to X----component controller

lr_entity TYPE REF TO cl_crm_bol_entity.

lr_comp_controller ?= me->comp_controller.

lr_entity ?= lr_comp_controller->typed_context->Y->collection_wrapper->get_current( ). Y---CONTExt node in view1.

Regards,

Gangadhar.S