Skip to Content
avatar image
Former Member

Browser Back/forward button in WDJ


I have a requirement, where user should not leave the current form until he provides required information in that form..

It was similar requirement like, posting query in sdn forums, whenever the user creates a new query, if he leaves the current query and navigate to the other area, one popup box will come to either discard or continue.

How to achieve it in Webdynpro java?



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 03, 2011 at 10:27 AM

    Hi ,

    its like confirmation dialogue box in your application.

    please chcek the below links for more detailse explanation and ther so many Blogs on the popup messages or dailogu messages .







    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 04, 2011 at 01:15 AM


    Regarding not being able to leave a form until all required information is entered, the user will always be able to close the window, so nothing much you can do there. Other than that, I would recommend you to create an attribute in your context, type boolean, let's say bData, for example, and then in your code you could do something like this...

    In your wdDoInit...

    wdContext.currentContextElement.setBData( false );

    Then, in your wdDoModify...

    IContextElement c = wdContext.currentContextElement;
    c.setBData( true );
    c.setBData( checkData( c.getBData, c.getAttribute1 );
    c.setBData( checkData( c.getBData, c.getAttribute2 );
    c.setBData( checkData( c.getBData, c.getAttribute3 );
    c.setBData( checkData( c.getBData, c.getAttributeN );

    Attributes 1, 2, 3... N represent all the information that needs to be entered. Now, for that checkData, you would do this in the OTHERS section...

    private boolean checkData( boolean bool, String value )
    	  boolean hasValue = false;
    	  if( bool )
    		  if( value != null && !"".equals( value ) )
    		  	  hasValue = true;
    	  return hasValue;

    That code, as you can see, only works for Strings, but you could easily modify it to take any kind of value without having to overload. You could have it receive an Object, and then do different actions by

    if ( value instanceof //DATA TYPE)

    So far, you have a boolean attribute in you context, and it represents whether all the required info has been entered. Every time you enter a value or delete a value from your view, wdDoModify will kick in and set that boolean value in your context. Now, at the time of pressing whatever button or whatever other action that terminates the view, you can, through code, know if all required information has been entered by getting that boolean, if it's false, the data is not complete, if it's true, then it is.

    You were also asking about a pop up message... there is an easy way without having to create another view...

    // Pop-Up Generation with message and default button
    // If you want message to just be informative, you still need that default button
    // so you can create an action or event handler with no code
    IWDConfirmationDialog confDialog;
    confDialog = wdComponentAPI.getWindowManager().
                 createConfirmationWindow( YOUR MESSAGE,
                                           ACTION OR EVENT HANDLER FOR BUTTON,
                                           BUTTON TEXT );
    // Aditional buttons
    confDialog.addChoice( ACTION OR EVENT HANDLER, BUTTON TEXT );
    // Message window header and alignment
    confDialog.setTitle( HEADER TEXT );
    confDialog.setWindowPosition( WDWindowPos.CENTER );
    // If you want, you can set window size in pixels, if not, sizes to fit
    // Show the popup ( this replaces deprecated );

    The action or event handler need to be created in your view, of course, in your Actions or Methods tab. I prefer to use EventHandlers for the buttons, you can access those by


    Otherwise, you could try

    IWDControllerInfo controllerInfo = wdControllerAPI.getViewInfo().getViewController();

    to access your view controller and get the Event Handler or Action you need from it.

    Now, that code for the pop up message could be used in your button, or like I said, any other action that terminates the view... like...

    	  if( !wdContext.currentContextElement.getBData() )

    Sorry for the very long answer, hope you find it useful.


    Add comment
    10|10000 characters needed characters exceeded

  • Jan 05, 2011 at 10:09 AM


    Simply use the suspend and resume plug there.

    Before firing suspend plug give the warning message .


    Best Regards

    Satish Kumar

    Add comment
    10|10000 characters needed characters exceeded