This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Change the way exceptions are displayed in the Web Portal

Our customer wants to change the way exceptions are displayed in the web portal.
More precisely, we want to replace the popup by something else. As an example, when editing database column via PropertyEditor, and the underlying format script throws an exception, we would like to have the message as red text below the field (like on 'regular' validation errors) instead of the 'annoying' popup.

I tried to find a component or function that is responsible for displaying exceptions, but had no luck. Is it possible to customize this behavior at all?

  • Hi

    In my opinion there are several ways to do this:

    The first way is, to create a own validation for each property in the WebDesigner. But I am not sure, if this also works for properties of database objects, because it could be that the formatscript will be validated first. In this case you have to use other collection types instead of database object.

    If you still want to use your formatscripts, you can make your exceptions a little bit more end-user-friendly. To do this your exception should look like as follows:

    //If you want to make your exception end-user-friendly for your web portal, you have to
    //add the parameter for ExceptionRelevance.
    Throw New ViException(#LD("Enter some text here...")#, ExceptionRelevance.EndUser)

    The only disadvantage is, that the exception will still displayed as a popup.

    Please note that there is no way to display exceptions coming from the backend other than a popup.

    -
    Regards
    Sven

  • Thanks for the input, Sven.

    We started of by removing the format scripts and re-implementing the checks in the web portal, but this is not feasible for all attributes, for obvious reasons.

    Using custom collections might solve the problem of having to disable the format scripts, but seems to raise bigger ones, because then we would need to implement e.g. the value templates in web designer as well.

    I've been trying to overwrite the JavaScrtipt function errors.displayHtmlInPopup() within WebDesigner, but I haven't had any luck so far.

    Is there a Connection Variable I can put in the format script, to check if the operation comes from the Web Portal? Then I wouldn't have to totally disable them.

  • Hello Christian,

    You cannot change the function itself, but you can re-define any javascript function. As an example:

    imx.errors.displayHtmlInPopup = function(title, message) {
      alert(title+": "+message);
    }

  • Thanks, Hanno, this works. Looks like I had a syntax problem in my attempts.

    Now, I don't suppose there is a simple way to redirect the contents into a UserMessage at the top of the frame ;) ? I haven't found anything in V7 that could trigger such a message via JS.

  • In version 8.x, you can call the function imx.errors.displayErrorMessage("your message goes here")

  • Hii Hanno,

    I don't know for what reason but this isn't working for me...

    Found this in my code:

    IScriptContainer p = ((IScriptContainerProvider) _targetContainer2.Page).ScriptContainer;
    p.AddScript("imx.errors.displayErrorMessage(imx.strings.STD_SessionWasEnded);");

    but when replacing this with:

    IScriptContainer p = ((IScriptContainerProvider) _targetContainer2.Page).ScriptContainer;
    p.AddScript("imx.errors.displayErrorMessage("Invalid Credentials");");

    I am getting several errors.

  • It looks like you are trying to put a double-quoted String inside a double-quoted String. Try escaping the inner quotes with a backslash.