Announcement

Collapse
No announcement yet.

How to interrupt an ACTION from a PreAction with g.UI_Exception

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to interrupt an ACTION from a PreAction with g.UI_Exception

    I have a small PreAction that I would like to interrupt the ACTION and return the user to the previous screen with an error message.

    The relevant code is:

    Code:
    <mvt:assign name="g.ui_exception_code" value="'customeraddress_invalid_addinfo'" />
    <mvt:do file="g.module_library_utilities" name="g.result_exception" value="UIException( g.ui_exception_code )" />
    <mvt:do name="l.result" file="g.module_library_utilities" value="Message_Error( l.settings:message )" />
    The UIException function should throw a g.UI_Exception true but it does not.

    When I hardcode a g.UI_Exception true then the PreAction runs but does not respond with a g.screen.

    Is there a way to interrupt an ACTION from a PreAction?



    http://www.alphabetsigns.com/

    #2
    I have a small utility module that does pre-actions (as well as pre-screens, post-actions, and post-screens). It has a couple of mvt:item tags that can be used to interrupt the normal Action processing and display error messages. You can drop me a line by email if you're interested.

    Thanks --
    Kent Multer
    Magic Metal Productions
    http://TheMagicM.com
    * Web developer/designer
    * E-commerce and Miva
    * Author, The Official Miva Web Scripting Book -- available on-line:
    http://www.amazon.com/exec/obidos/IS...icmetalproducA

    Comment


      #3
      For posterity, there is no way to intercept the ACTION without a system extension module.
      http://www.alphabetsigns.com/

      Comment


        #4
        No there is not. I don't see your example code working at all because by the time that is executed, whatever action has already taken place.
        David Carver
        Miva, Inc. | Software Developer

        Comment


          #5
          Think of it this way. If you need something to occur before the page loads, then it can't happen on a page load which is when SMT code is processed. So, some sort of module is required.
          Bruce Golub
          Phosphor Media - "Your Success is our Business"

          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
          phosphormedia.com

          Comment


            #6
            Toolbelts PREACTION_code intercepts the Merchant action. It can be "tricked" into returning to the previous screen.

            If you store a variable required for Merchant action, into a temporary global variable, then clear the required variable, Merchant will detect the missing variable and return the user to the previous screen with an error. When the original page loads, it will be up to you to detect the temporary variable, and restore it into the original and also intercept the Merchant error message.

            For example you want to add a process when a customer creates an account. In your template PREACTION_ACAD you detect missing extra data, so you would use
            g.Save_Customer_ShipFirstName = g.Customer_ShipFirstName then
            g.Customer_ShipFirstName = ''

            Miva Merchante detects the error and return the user to the ACAD screen where you set
            if ( g.Save_Customer_ShipFirstName )
            g.Customer_ShipFirstName = g.Save_Customer_ShipFirstName

            And the change the value store in the error message.

            I know its a hack, but it works. I never managed to get the ui_exception to work, because it was taking more time than I had to spend.
            Ray Yates
            "If I have seen further, it is by standing on the shoulders of giants."
            --- Sir Isaac Newton

            Comment


              #7
              well...that's a module :)
              Bruce Golub
              Phosphor Media - "Your Success is our Business"

              Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
              phosphormedia.com

              Comment


                #8
                Hi Ray,

                Thanks for the trick. I am able to get it to work.

                I noticed some side effects of the conditional PRE_ACTION hack which is why I was hoping the UI_Exception would be more elegant.

                1. One side effect is to return a g.ShipFirstName_Invalid is true for styling.

                2. If you are using other system modules that use the value of the 'hacked' field then it can throw an unintended UI_Exception. For example, I use the UPSADDR5 module which is a system module and although the item is not assigned to the page it will still throw a UI_Exception. So it appears that every system module is iterated on an UI_Exception Action.

                (Makes me wonder if I should uninstall deprecated system modules still in the store.)

                3. So, selecting the best required input to make null is very important. If you invalidate the ShipZipCode or ShipStateSelect field on OCST then it effects the shippingmethods array on the OSEL page.

                I like your use of the Customer FirstName which looks like it works well for most cases.

                Thanks again for taking a look at this and teaching an old dog a new trick.



                http://www.alphabetsigns.com/

                Comment

                Working...
                X