cancel
Showing results for 
Search instead for 
Did you mean: 

onAction needs to run logic in wdDoModifyView

former_member540174
Participant
0 Kudos

I have a component. When first displayed it shows data from the current week. There is a button that is for the prior week information. When the user clicks this button the appropriate onAction fires. I then run the necessary methods in the component controller. How do I get the new data to show on the page? The current "wdDoModifyView" has logic used in order to do some special table processing so I need to call it.

Any suggestions?

Diane

Accepted Solutions (0)

Answers (2)

Answers (2)

sridhar_k2
Active Contributor
0 Kudos

If i understood your requirement correctly, you want to display some data on click of the button.

wdModfiyView will be called for each request. So if you want to show special table just activate that piece of code using some boolean operation. Declare one boolean static variable in the global scope (bottom of your view), make this boolean variable true in your button selection method. In wdModfiyView use boolean variable to show special table.

Regards,

Sridhar

Former Member
0 Kudos

No, don't use static variables!

Armin

sridhar_k2
Active Contributor
0 Kudos

Armin,

Correct me if i am wrong.

public static void wdDoModifyView() - this is a static method, then how can we use non-static variables in the static method.

Regards,

Sridhar

Former Member
0 Kudos

I did not suggest to use a non-static variable inside a static method (which is of course impossible) but to use a context attribute. Just think about how many instances of a static variable can exist at once and how many instances of the view might exist at once.

Armin

former_member540174
Participant
0 Kudos

You know I thought it would call the modify view everytime - but I wasn't seeing that. I put messages in and saw the following based on my code ---

Modify view called Build View

I clicked the button Prior week

Message stating the button was click happened - No Modify view


public static void wdDoModifyView(IPrivateDetailView wdThis, IPrivateDetailView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
    //@@begin wdDoModifyView
    BuildView(WeekToProcess.CURRENT_WEEK, wdThis, wdContext, view);
    IWDMessageManager msgMgr = wdThis.wdGetAPI().getComponent().getMessageManager();
    java.util.Date mDate = new java.util.Date();
    msgMgr.reportWarning("Do Modify View " + mDate);
    //@@end
}

public void onActionPriorWeek(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
    //@@begin onActionPriorWeek(ServerEvent)
	
	IWDMessageManager msgMgr = wdThis.wdGetAPI().getComponent().getMessageManager();
	msgMgr.reportWarning("Prior Week");
	GregorianCalendar priorWeekDate = new GregorianCalendar();
	priorWeekDate.setTime(new java.util.Date());
	priorWeekDate.add(GregorianCalendar.DATE,-7);
	wdThis.wdGetEmployeeTimeVerificatioinCustController().getEmployeeTimeData(priorWeekDate.getTime());
    //@@end
}

private static void BuildView(short weekToProcess,IPrivateDetailView wdThis, IPrivateDetailView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view)
{
	IWDMessageManager msgMgr = wdThis.wdGetAPI().getComponent().getMessageManager();
	msgMgr.reportWarning("BuildView");	
	
....does more logic....

}

What did I do wrong? Why after the button click action does my modify view not execute?

Regards,

Diane

sridhar_k2
Active Contributor
0 Kudos

Diane,

This is working for me. For Each request i could see calling wdModfiyView - data.

It is in the specification.

public static void wdDoModifyView(.....){

IWDMessageManager msgMgr = wdThis.wdGetAPI().getComponent().getMessageManager();

msgMgr.reportWarning("Do Modify View " + TestView.sayHello("Sridhar"));

java.util.Date mDate = new java.util.Date();

msgMgr.reportWarning("Do Modify View " + mDate);

}

private static IWDMessageManager msgMgr = null;

in the global scope i created message manger and instantiate in the init method

like, msgMgr = wdComponentAPI.getMessageManager();

// calling this static method in wdModify method.

private static String sayHello(String name){

msgMgr.reportSuccess("Name "+name);

return "Hey "+name;

}

// I can see all 3 statements every time on my screen.

Regards,

Sridhar

former_member540174
Participant
0 Kudos

Thank you ! Learned something - I put a timestamp on my message. I was calling the method. Must be multitasking to much today!

Diane

Former Member
0 Kudos

Do you really need to change the view after the action? If yes, the standard technique is to set a flag (boolean context attribute) in the action handler and check/reset it inside wdDoModifyView().

Armin