cancel
Showing results for 
Search instead for 
Did you mean: 

How to get a View handler?

Former Member
0 Kudos

Hi all,

I'm trying to make a mandatory field check but in the message triggered I want to use the attribute "Text" of the label of my inputfield:


//This is my inputfield's label
IWDLabel Dt_Decrichiesta = (IWDLabel) view.getElement("Dt_Decrichiesta_Label");
//This is my check method with 2 parameters: 1 is the field to check, 2 is the name of field to use in the error message
wdThis.CheckMandatory(IPrivateCompRequestView.IX_Zur_RichiesteElement.DT__DECRICHIESTA,Dt_Decrichiesta.getText());

everything is done in the action handler.

As u can see I need a IWDView object to call the getElement method...

Where/how can I get that???

Accepted Solutions (1)

Accepted Solutions (1)

roberto_tagliento
Active Contributor
0 Kudos

You can get WDView object only from wdDoModifyView method.

This variable arrive you from standard call.

Look parameter of wdDoModifyView

-


public static void wdDoModifyView(IPrivateAsd wdThis, IPrivateAsd.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

Message was edited by:

Roberto Tagliento

Answers (5)

Answers (5)

Former Member
0 Kudos

ok, that's it...

according to SAP specifications and raccomandations up to now you cannot get a view handler anywhere else than in wddomodifyview.

tanks to everybody

Former Member
0 Kudos

Hi,

Why can't ypu do this through ContextProgramming ?

I mean you can bind Text property, State property to respective contexts.

Read this context in your method (so that you don't require IWDView).

Regards, Anilkumar

Former Member
0 Kudos

Hi,

Can't you try with a static variable of type iWDView and initialise it inside the WD view

Regards

Ayyapparaj

Former Member
0 Kudos

Ok, I know that in the wddomodifyview I have the variable view as import parameter but the problem is that my code is implemented in the action handler and not in the wddomodifyview.

I need a way to get such reference in any other place such as wddoinit or anywhere else than wddomodifyview...

is it possible?

If no, which is the better way to pass the reference from the wddomodifyview to another method?

Regards,

Stefano Cattaneo

roberto_tagliento
Active Contributor
0 Kudos

Look:

public static void wdDoModifyView(IPrivateAsd wdThis, IPrivateAsd.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)

there is boolean firstTime.

Do your check mandatory field into wdDoModifyView, this method is called always and use firstTime for skip the control at first presentation of the view!

Former Member
0 Kudos

I've tryed your solution but I still have a problem:

in "public void onActionSave" that is my button's action handler I have to save the data from the screen to the DB, this mean that I have to check them first.

The method "public static void wdDoModifyView" is called after "public void onActionSave" so it is too late!

...still need help

Stefano Cattaneo

roberto_tagliento
Active Contributor
0 Kudos

Ok listen 😛

on "onActionSave" do the save only

if the check is OK


and
into "wdDoModifyView" as i said, show the error message

if the check isn´t ok

.

Message was edited by:

Roberto Tagliento

roberto_tagliento
Active Contributor
0 Kudos

The 2 operation are binded on functionality but are practical separated on developing.

Former Member
0 Kudos

What do u mean with:

> The 2 operation are binded on functionality but are

> practical separated on developing.

...in any case I have tryed to do what u say but when I press the button "Save" the system trigger the action and execute the corresponding method "onActionSave".

After that it execute the method "wddomodifyview" and perform the check exposing the error message.

Where I am wrong?

Thank u again and again...

Stefano

roberto_tagliento
Active Contributor
0 Kudos

😛

sorry i am criptical


by the way into method "onActionSave" {
   
     if (checkMandatory_is_OK()) {
                 
              // DO WHAT TO HAVE TO DO
     }
     // ELSE DO NOTHING/IGNORE THE click THAT USER HAVE DONE

}

and into


"wddomodifyview" {
     if (!checkMandatory_is_OK() && !firstTime) {
                 
              // SHOW MESSAGE ERROR
     }
}

forgot "firstTime"

Message was edited by:

Roberto Tagliento

Former Member
0 Kudos

Hi Roberto,

maybe I have understood... I will try this but...

you suggest to make the checks in the eventhandler and delegate the showing of message in the wddomodifyview, but in this way I can't know what fields has raised the error. Of course I can export that info and pass it but it doesn't seem convenient, I can also perform the checks again in the "wddomodifyview" but it's not convenient too...

I only need a handler for the view to get the attribute of the view element.

Don't u agree?

roberto_tagliento
Active Contributor
0 Kudos

yep

by the way look the link showed above

Message was edited by:

Roberto Tagliento

Former Member
0 Kudos

Hi,

You can do this:

In the <i>//@@begin others</i> section, declare a field like this:

static IWDView thisView = null;

Then in wdDoModifyView, assign like this:

if(firstTime)
thisView = view;

Then in your event handler methods you can access this view reference simply as <i>thisView</i>.

Regards,

Satyajit.

Former Member
0 Kudos

Just don't do it.

Armin

lajitha_menon
Contributor
0 Kudos

hi,

its available in wdDomodifyview() as an input parameter,

LM