Friday, August 20, 2010

APEX Plugin: Simple Modal

I just published another plugin called Simple Modal: http://www.apex-plugin.com/oracle-apex-plugins/dynamic-action-plugin/simple-modal.html

This plugin allows you to use any region(s) (or DOM object) in your APEX application as a modal window.

When developing this plugin I learned a few more things that may be useful when developing plugins:

- Scope Creep: When developing a plugin you can make it do a lot of things. This may lead you to try and include extra unnecessary functionality. Try to remember the goal you're trying to achieve, or more importantly, what you're developers will try to achieve with the plugin.

- Instrumentation: I'm a big fan of Tom Kyte and really like the emphasis he puts on Code Instrumentation. You may want to add some debug information in your JavaScript code to help you understand what is going on. As part of this plugin I included a logger package which is essentially a wrapper for console but will work in all browsers. I'll write about this in another post and include the final copy for general use.

8 comments:

  1. Martin,
    How hard would it be to use this plugin for a report calling a form? I am looking at modal window plugins to interface with the theme I am using (APEX THEMES Delta theme).

    The current one I use is okay, but it HARD CODES the layout and such, versus using the existing theme of the application..

    ReplyDelete
  2. Hi,

    This should work assuming that you have a link on your report which, when clicked, should load a modal form.

    Since it's all bundled as a plug-in I encourage you to try it out and see if it resolves your issue. Worst case you can just remove the plug-in.

    Martin

    ReplyDelete
  3. Hi Martin -
    How did you define your modal region so it
    would appear when invoked from the dynamic action?

    ReplyDelete
  4. Hi,

    The region is a standard region. The dynamic action is the Simple Modal plugin.

    Hope this helps,

    Martin

    ReplyDelete
  5. Hi Martin

    I'm using the modal plugin on a region within my page. On the modal region, I'm inserting/editing information, however when I try to insert I get an error. It seems that the data set in the page items on that region lose the data when I hit the submit button.

    I'm hiding the region using this attribute ' style="display: none;" '. And then when I click a button the dynamic action is triggered to show the modal region.

    My coworker suspects that it may be due to using region buttons instead of page buttons. The region buttons are on the modal form.

    Any help would be much appreciated. If you need more information, please let me know.

    Thank you
    Harjeet

    ReplyDelete
  6. Hi Harjeet,

    Try running the close dynamic action (the plugin comes with two dynamic actions) before the submit occurs. Explicitly closing the modal (using the close DA plugin) will move the region back to its original position.

    Read http://forums.oracle.com/forums/thread.jspa?messageID=3180532 for more information.

    Martin

    ReplyDelete
  7. Thanks Martin

    I'll give that a shot. Would I trigger the close action as part of the submit?

    I was also looking at eric martin's blog post and he mentioned setting persist option to true. Do you know where I'd set that? The behaviour that he describes is very similar to what I'm experiencing.

    This is the post that I'm referring to:
    http://www.ericmmartin.com/projects/simplemodal/#options.

    Thank you
    Harjeet

    ReplyDelete
  8. Hi Martin

    This is what I've done. On the submit button, I trigger the Modal Close action and then do the insert/update after submit and after validations and computations.

    I'm no longer getting an error but I'm also not seeing the data that I tried to insert into the db.

    Thank you
    Harjeet

    ReplyDelete