on 04-21-2014 3:00 PM
Hi Experts,
I have created a view(MAIN) that contains SUBMIT button and also included four other views(Using ViewContainerUIElement) in the MAIN view itslef. So am calling the respective view based on some certain condition from MAIN view.
Now my problem is, am using check_mandatory_attr_on_view() method which is being called on SUBMIT action from MAIN view of WDDOBEFOREACTION. But it is not checking Required Fields from other views. It checks the Required Fields only in the MAIN view.
I know that I want to call the reference of other views in MAIN view, but how can I do it?
Please help me, as how I can check the Required fields on action of SUBMIT button in MAIN view for other views.
BR,
RAM.
Hi,
Follow the below steps:
1. Create attribute(s) in component controller say ( gv_emb_view1, gv_emb_view2.. of type if_wd_view ).
2. In your sub view(s) WDDOINIT method, get the reference of view and set it to the created attributes in component controller.
wd_comp_controller->gv_emb_view1 ?= wd_this->wd_get_api( ).
3. Now in your main view, get the sub view reference by accessing the component controller attribute ( wd_comp_controller->gv_emb_view1) and pass it to mandatory field checking..
On Action of Submit button:
CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW(
EXPORTING
view_controller = wd_comp_controller->gr_emb_view1.
CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW(
EXPORTING
view_controller = wd_comp_controller->gr_emb_view2.
....
....
....
Hope this helps u,
Regards,
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kiran,
Thanks for your suggestion. I did as you said, it's working but am facing another problem now.
My default view is MAIN view and based on the user input selction am populating sub views. The problem is if I press SUBMIT button in MAIN view, it is checking Required fields for all other Sub views also. So am receiving error message for all my views(MAIN+SUB) in MAIN view, irrespective of not calling the Sub view.
I tried to clear the global attribute and checked like IS BOUND in BEFOREACTION of MAIN view. But nothing is working. How can I proceed further?
BR,
RAM.
Hi,
So am receiving error message for all my views(MAIN+SUB) in MAIN view, irrespective of not calling the Sub view.
I didn't get what you meant! As you asked in the original query, " you need to check the mandatory attributes of sub views also on click of Submit button" isn't it..?
If not, please provide more details on your requirement.
Regards,
Kiran
Kiran,
I told already that, am calling sub views based on some condition from Main view.
Though am in MAIN view, If i clicks the submit button it checks the Required fields on both MAIN and Sub views, where still I have not called the Sub view.
So am getting the error message with respect to MAIN and SUB views.
BR,
RAM
Oh, that is the issue. When you are controlling the visibility of views by using property "VISIBILITY" of view container, actually view gets initialized and hence, the attribute is bound. So you are getting messages of all the sub views irrespective of its visibility.
I don't think its right approach to handle the view visibility.
I suggest you to use navigation plugs to show/hide views whenever required.
If you still wants to continue with current approach,
you need to restrict the check for mandatory fields only to the visible sub view as below
data lo_view_ctrl type ref to if_wd_view_controller.
case lv_sub_view.
when 'SUB1'.
lo_view_ctrl = wd_comp_controller->go_sub_view1.
when 'SUB2'.
lo_view_ctrl = wd_comp_controller->go_sub_view2.
when others.
endcase.
CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW(
EXPORTING
view_controller = lo_view_ctrl.
Now, only for visible view, the mandatory check logic executes.
Regards,
Rama
Hi,
Though am in MAIN view, If i clicks the submit button it checks the Required fields on both MAIN and Sub views, where still I have not called the Sub view.
If you didn't call the sub view, the WDDOINIT method of your sub view wouldn't have been triggered and so the sub view reference is not set in the component controller, isn't it.?
OR you are calling sub view separately in the initial state and get the reference and then in your MAIN view calling the sub view based on condition in the View Container UI..?
If so, create an attribute in your Main view (say sub_view_name of type string) and then use the below code to get the current sub view name and then pass the corresponding sub view reference:
DATA:lr_view_controller type ref to IF_WD_VIEW_CONTROLLER,
lr_main_view_usage type ref to IF_WD_RR_VIEW_USAGE.
lr_vc_assignment type ref to IF_WD_RR_VIEW_CNT_ASSIGNMENT.
lr_view_usage type ref to IF_WD_RR_VIEW_USAGE.
lr_t_views type WDRR_VCA_OBJECTS.
lr_s_view like line of lr_t_views.
lr_view type ref to if_wd_rr_view.
lr_view_controller = wd_this->wd_get_api( ).
lr_main_view_usage = lr_view_controller->GET_VIEW_USAGE( ).
lr_t_views = lr_main_view_usage->GET_VIEW_CNT_ASSIGNMENTS( ). "This will return all the View Container assignments.
* Now loop over all the View containers and get the reference of embedding view.
loop at lr_t_views into lr_s_view .
lr_vc_assignment = lr_s_view-VIEW_CNT_ASSIGNMENT.
lr_view_usage = lr_vc_assignment->GET_DEFAULT_VIEW_USAGE( ). " This will return view usage reference
lr_view = lr_view_usage->get_view( ). " This will have the meta info of view
wd_this->sub_view_name = lr_view->get_name( ).
endloop.
Now in onAction submit,
CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW(
EXPORTING
view_controller = lr_view_controller " MAin view reference
case wd_this->sub_view_name.
when 'SUB_VIEW1'.
CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW(
EXPORTING
view_controller = wd_comp_controller->gr_emb_view1.
when 'SUB_VIEW2'.
CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW(
EXPORTING
view_controller = wd_comp_controller->gr_emb_view2.
.....
.....
.....
Or, alternatively; create all the nodes(of sub views) in component controller, then map all those to MAIN view, then read the required node attributes and validate manually.
hope this helps u,
Regards,
Kiran
Hi Rama and Kiran,
Thanks for your great efforts.
I did it simply by checking a IF condition before raising the message in WDDOBEFOREACTION of MAIN view. From MAIN view,am displaying SUB view based on user action. For eg, if the form request is to CREATE, then I'm displaying SUB1 view.
So according to Kiran's code, just checking with a respective IF condition, which completely resolved my issue.
Thanks a lot again for both of your efforts. Anyways both of your ideas helped me to get new concepts from your codings.
Still confused as to whom I want the mark the Correct Answer, as you both guys are always
replying the correct answers.
BR,
RAM.
Hi RAM,
Check out this option as well:
I don't think there a need to have references of other views in comp controller and then use in MAIN view, instead you can directly place the logic for checking mandatory fields in WDDOBEFOREACTION( ) method of each sub view.
Please follow the below steps:
- Create a global attribute GV_ACTION in component controller
- Collect the current action of MAIN view in WDDOBEFOREACTION( ) method as below
wd_comp_controller->gv_action = lo_action.
- Now, go to WDDOBEFOREACTION( ) method of sub views, write the logic as below
case wd_component_controller->gv_action.
when 'SAVE'.
CL_WD_DYNAMIC_TOOL=>CHECK_MANDATORY_ATTR_ON_VIEW(
EXPORTING
view_controller = lo_api_controller.
when OTHERS.
ENDCASE.
Here, we are distributing the error handling of each view inside its own methods i.e. the view, which owns the fields and the validation of these fields is its responsibility.
Hope this helps you.
Regards,
Rama
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.