Skip to Content
author's profile photo Former Member
Former Member

Message Handling from model to controller

Hi,

I'm looking into how (error) messages that are trapped in the model can be communicated to the controller.

Up till now I have been using flags as model attributes.

So I'm creating a different flag for each possible error in the model. I guess there must be a better way to tackle this.

Thanks for any help provided.

Regards,

Eric

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 09, 2005 at 04:03 PM

    Hi Eric, I´m also investigatin on this.

    Why not using exceptions?? As I said I´m still investigatin, but I guess it´s the best solution..

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 09, 2005 at 07:42 PM

    Hi Eric,

    the best solution in my opinion is implementing the observer pattern. So you make your model observable and the controller acts as an observer which registers itself for certain error events (http://patternshare.org/default.aspx/Home.PP.Observer). This solution is highly reuseable and easy to implement. I talked about this solution during my sdn presentation at walldorf so I already have some materials. If there are more people interested in this solution I can write a weblog about it.

    regards

    Thomas

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi all,

      I seem to have triggered an interesting topic here...

      Thanks all for the valuable input.

      Last night (yep, I get my best ideas in bed and also on another location I'll not further discuss about...) it dawned on me that I could of course simply use return codes/exceptions for the different methods in my model in stead of creating and using flags as extra model attributes.

      Thomas, your post about the observer is most intreguing.

      Definitely worth a weblog! I have the feeling it answers

      my underlying need for it's not only "errors" I'm trying to trap...

      Regards,

      Eric

  • author's profile photo Former Member
    Former Member
    Posted on May 09, 2005 at 02:56 PM

    hi Eric,

    you can use a string or an internal table in model in which u can insert ur error messages.

    Then u can access that table or string from controller.

    Hope this will help you.

    Regards,

    Ankur

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 10, 2005 at 04:47 AM

    Via debugger have a look to the CL_BSP_MODEL->ERRORS attribute for example in the DO_HANDLE_EVENT method of your controller...

    Do you know that MODELs perform a format check on each field binded by a view (//model/structure.field)?

    Your controller could ask to the model if there are errors; I never found any standard way to do that but I created a simple public method (get_errors) that returns the protected attribute ERRORS (do not ask me why it is protected!!).

    You could also add your messages in the object ERRORS for example via the ADD_MESSAGE_FROM_T100 method.

    Sergio

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 25, 2005 at 08:33 PM

    Hi Guys,

    it took me a little longer than expected but here is my <a href="/people/thomasalexander.ritter/blog/2005/05/25/bsp-using-the-observer-design-pattern-for-error-handling have fun 😊

    regards

    Thomas

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.