Friday, December 08, 2017

How do I create a responsive Rich Text Editor in Oracle APEX?

I was in a video call this morning with a great customer from England (and by the way, this customer is in the process of transforming the healthcare industry across the UK).  They asked me a very simple question:

How do I create a responsive Rich Text Editor item on a page?

Simple question and answer, right?  Well, you'd be wrong.  While we pride ourselves on the responsive user interfaces that you can easily create with Oracle Application Express (APEX), unfortunately, the item type of Rich Text Editor is not responsive, out of the box.

So - I did what all smart people do, and I reached out to the Oracle APEX Development team, in this case, the ever-intelligent Carsten Czarski.  And in a few minutes, he showed me exactly what I needed to do.

  1. Open up Application Builder, and in Page Designer, edit the page with the Rich Text Editor item.  In my example, my Rich Text Editor page item name is P3_RESUME.
  2. Navigate to the attributes of the Rich Text Editor item, and in the Advanced section, enter the following code in the "JavaScript Initialization Code" attribute:
    function (o) {
        o.width = $("#P3_RESUME").closest(".t-Form-inputContainer").width() - 5;
        o.height = 300;  // Specify your desired item height, in pixels
        return o;
    }
    This code determines the width of the region container of the item, subtracts 5, and returns the object initialized to this size.  This will take care of the Rich Text Editor when the page is initially displayed. But it won't handle the case when the browser is resized. To handle that case, we'll need to add a dynamic action.
  3. Click the Dynamic Actions sub-tab in Page designer (the lightning bolt)
  4. Select Events in the upper-left, right-click your mouse and choose "Create Dynamic Action".
  5. In the attributes, enter "Resize" for Name, and select "Resize" for the Event.
  6. Select the True action of the dynamic action (it should be "Show").  Change the Action to "Execute JavaScript Code".
  7. In the Code attribute, enter the code:
    CKEDITOR.instances.P3_RESUME.resize( $("#P3_RESUME").closest(".t-Form-inputContainer").width() - 5, 300);
    
    This is an absolute reference to the Rich Text Editor item on the page, named P3_RESUME. And like the code before, this will determine what the width is of the container of the item, subtract 5 from it, and invoke the resize() method of the Rich Text Editor (CK Editor) element.
That's all there is to it!



Obviously, this item type (like all others) should be responsive, out of the box.  And Carsten is looking at this for the next version of APEX.  In the meantime, if you're using Universal Theme with Oracle APEX 5.1, all it takes is a tiny amount of JavaScript to get a responsive Rich Text Editor.

Thursday, December 07, 2017

Errors when downloading a file on page submit in Oracle Application Express 5.1 or later...

Recently, Sharon Kennedy from our team approached me for some help with file download in Oracle Application Express (APEX).  Sharon is the primary developer of Oracle Live SQL (among many of her other responsibilities), and she wanted to initiate a file download in a page process, after page submission.  Since I've done this 100 times in APEX applications, should be easy, right?

Back in 2014, I wrote a short blog post showing how to generate a link to download a file from a BLOB stored in a table.  But this problem was slightly different.  The application flow was:

  1. In Oracle Live SQL Administration, an administrator would click the button "Download Oracle Content"
  2. The page would then be submitted, and a PL/SQL page process would fire, which would query all of the static scripts and tutorials from Live SQL, zip them up using APEX_ZIP, and initiate a file download.

However, when the button was clicked, the page would be submitted, no file download would be initiated, and the following error was displayed on the page:


Error: SyntaxError: Unexpected token r in JSON at position 0



After spending more than an hour debugging the Live SQL application, I resorted to a simpler test case.  I created a trivial application with a button on the first page, which would submit and invoke the PL/SQL page process:

declare  
    l_file_blob blob;  
    l_file_name apex_application_files.filename%type;  
    l_file_mimetype apex_application_files.mime_type%type;  
begin  
    select blob_content, mime_type, filename into l_file_blob , l_file_mimetype , l_file_name from apex_application_files where id = 2928972027711464812;     
    sys.owa_util.mime_header( l_file_mimetype , false );  
    sys.htp.p('Content-Disposition: attachment; filename="' || l_file_name ||'"');  
    sys.htp.p('Content-length: ' || sys.dbms_lob.getlength( l_file_blob ));  
    sys.owa_util.http_header_close;  
    sys.wpg_docload.download_file( l_file_blob );  
    -- Stop page processing  
    apex_application.stop_apex_engine ;  
end;  


With my test case, it was exactly the same error encountered, the meaningless error message of "Error: SyntaxError: Unexpected token r in JSON at position 0".

I finally gave up and contacted Patrick Wolf on the APEX product development team, who helped me solve this problem in one minute.  Granted...Patrick was both the creator of the problem and the creator of the solution!

To resolve this problem:

  1. Open the page in Page Designer in Application Builder
  2. Edit the page attributes
  3. In the Advanced section of the page properties on the right hand side of Page Designer, change "Reload on Submit" to "Always" (changing it from "Only for Success" to "Always")
That's it!



Setting "Reload on Submit" to "Always" will POST the page and render the result using the behavior as it was in APEX 5.0 and earlier.  In APEX 5.1, if Reload on Submit is set "Only for Success" (the default), it will use the new optimized page submission process, and expect a specifically formatted JSON result returned from the APEX engine.  Obviously, when I employ a page process which overrides the HTP buffer and emit binary content (instead of a well-formed JSON result), the libraries on the page don't know how to deal with that, and thus, results in this obtuse "Unexpected token r..." message.

Tuesday, October 17, 2017

If you're in Panama, Colombia, Ecuador, Paraguay, Brazil or Argentina, Oracle APEX is coming to you!


In the first part of November, my colleague David Peake and I are taking the Oracle APEX & Oracle Database Cloud message to a number of Oracle user groups and communities who are graciously hosting us as part of the Oracle Developer Tour Latinoamérica.  These are countries for which there is growing interest in Oracle Application Express, and we wish to help support these groups and aid in fostering their growing APEX communities.

The dates and locations are:
  1. Panamá, November 1, 2017
  2. Colombia, November 2-3, 2017
  3. Ecuador, November 7, 2017
  4. Paraguay, November 8, 2017
  5. Brasil, November 9-10, 2017
  6. Argentina, November 13-14, 2017
You should consider attending one of these conferences if:

  • You're a CIO or manager, and you wish to understand what Oracle Application Express is and if it can help you and your business.
  • You're a PL/SQL developer, and you want to learn how easy or difficult it is to exploit your skills on the Web and in the Cloud.
  • You come from a client/server background and you want to understand what you can do with your skills but in Web development and Cloud development.
  • You're an Oracle DBA, and you want to understand if you can use Oracle Application Express in your daily responsibilities.
  • You know nothing about Oracle Application Express and you want to learn a bit more.
  • You're experienced with Oracle Application Express and you want to learn what's in the future for Oracle APEX.

If you have any interest or questions or concerns (or complaints!) about Oracle Application Express, and you are nearby, we would be very honored to meet you in person and assist in any way we can.  We hope you can make it!

P.S. I couldn't make it to Panamá, but David will be there, so please join him.

Thursday, October 05, 2017

A Great APEX Developer is.....a Full Stack Developer!



I've heard these phrases from customers:

  • Where can I find Oracle APEX developers?  
  • I'm having a tough time filling a vacancy for an APEX developer.  
  • I'm getting pushback from my own management because they say Java developers are much easier to find than APEX developers.

The last comment was from Peter, a potential customer, who recently posted this on Twitter.

Make no mistake about it.  If you go to indeed.com or dice.com or monster.com, you're going to find far more openings for .NET or Java developers than Oracle APEX developers.  But I would like to take a step back and ask - what makes a really great Oracle APEX developer?  Well, a great APEX developer is competent in:

  1. The Oracle Database (installation, setup, tuning, monitoring)
  2. Data modeling
  3. SQL (and SQL tuning)
  4. PL/SQL
  5. User Interface Design
  6. Responsive Design
  7. HTML
  8. CSS
  9. JavaScript
  10. Web applications
  11. Web servers
  12. Web security
  13. Network security
  14. Server administration
  15. Continuous integration
  16. Unit testing
  17. Application Express (APEX) development

...and probably a few more not even listed here.  It's an amazing list of very specific and relatively complicated technologies.  Don't be alarmed if you consider yourself a rockstar developer with APEX and you are competent in less than half of these areas.  I can't really think of anyone on our own Oracle APEX Development team who is intimately familiar with all of these technologies.  A few experts in the APEX community can truly claim to be proficient in all of these areas, but they're finite in number.  If you look at this list of technology areas, you will quickly conclude:

If you're looking for a great APEX developer, you're really looking for a full-stack developer

...and those are pretty rare in the industry.  Let's look at a couple examples.

It's easier to find Java developers than it is APEX developers.  Sure, I agree.  But it's a common misconception that because someone knows .NET or Java (or PHP or Python or Ruby or JavaScript or whatever) that they are competent in elegant and attractive user interface design.  Just because you know a programming language that is commonly used in Web applications has no correlation to you having the ability to create rich and elegant UI.  This is a very rare skill, and one I see even some experienced APEX developers wrestle with.

As another example, I heard a manager say that he was going to pursue building an application with Oracle JET because it's easier to find JavaScript developers.  We on the APEX team love Oracle JET and want Oracle JET to succeed (so much so, that we've integrated Oracle JET to produce the data visualizations in APEX 5.1!).  But this manager's statement was a bit misguided, because 1) your knowledge of JavaScript doesn't mean you'll immediately know how to use Oracle JET, you'll need to learn it, and 2) what about the rest of the stack?  Is a JavaScript developer good at data modeling?  Are they competent in authoring and tuning SQL?  Do they know when it's preferable to use PL/SQL in their SQL and when not to?  Or is that someone else's job?

My advice when you're looking for APEX developers - determine what is most important to you, and what skills and technologies you need the most assistance with.  APEX development is ultimately Oracle Database development (Smart DB development, as some would say), and experience with SQL and PL/SQL and data modeling is always relevant.  If you have a subpar data model and poor SQL, your application will suffer regardless of front-end technology.  If you have no knowledge of Web applications and you are rich in Oracle Database development talent, then focus instead on those who bring Web application development experience to the table.  I've found that the customers who "get it" the most are those who have done large-scale Web app development in another language or technology.  They are the ones who can appreciate the framework of APEX and how it enables them to focus on the business problem at hand, instead of focusing on all of the necessary minutiae typically associated with modern Web app development.

When reviewing potential candidates, don't focus exclusively on APEX experience.  APEX can be on the wish list of skills, but someone adept at database development or Web development can usually pick up APEX relatively quickly.

Oracle Database application development with APEX and Oracle REST Data Services (ORDS) continues to grow, for both on-premises applications and the cloud.  Industry analysts are responding to more and more inquiries about APEX than ever before.  Countless colleges and universities are taking advantage of the free Oracle APEX curriculum and the free offering by Oracle Academy, helping to familiarize thousands of students on appdev with the Oracle Database & APEX.  The Oracle APEX community is vibrant and growing.  There's a reason why APEX skills are in high demand.

P.S.  If you've stumbled upon this blog post and have no idea what Oracle APEX even is, I suggest you review the Simple Guide to Oracle Application Express.

Thursday, September 14, 2017

The Insurance of Oracle APEX - Can Your Low Code Framework Do This?

Oracle Application Express (APEX) runs wherever the Oracle Database runs.  I've said these words to thousands of customers and partners for the last 15 years.  So why should you care?  Simple.  Peace of mind.

Last evening, Amazon Web Services tweeted the following announcement:

"Use Amazon RDS for Oracle with Oracle APEX versions 5.0.4 & 5.1.2 to build applications within your web browser."


Now, one might think I'm daft for even mentioning AWS on my blog, but I think this presents an opportunity to emphasize two very important points about Oracle APEX:

  1. While I believe that Oracle Cloud is superior for running your Oracle APEX applications, if for some reason you need to not run it on the Oracle Cloud at some later date, you have that choice.
  2. Oracle APEX is not exclusively a cloud-only solution.  You can run it in the Oracle Cloud (my preference), you can run it on AWS, you can use a number of other hosting providers, you can run it with other infrastructure providers, but you can also choose to run it on-premises.  And you can change your mind among these options whenever you wish.  This is very powerful.

Oracle Application Express is a part of every Oracle Database Cloud Service from Oracle, including:

There are other cloud services coming from Oracle later this year which will also include and feature Oracle APEX.

If you think that the Oracle Database is only good for storing data (i.e., a "bit bucket"), you'd be wrong.  If you're unfamiliar with Oracle APEX, please check out this Simple Guide to Oracle APEX.  From bespoke applications in the Oracle Cloud & on-premises to Oracle ERP Cloud PaaS Extensions using Oracle APEX, our customers and partners are really killing it with the Oracle Database and Oracle APEX.


P.S.  Kudos to Amazon for referencing it as Oracle APEX and not Oracle Apex!

Friday, September 01, 2017

Emails That I Do Not Like to Receive

There have been numerous articles and blog posts about how to properly write an email, or how to properly ask a technical question. These seem to be rarely read or they are simply misunderstood.  So let me tell you about the types of emails I receive with seemingly greater frequency, and which I completely abhor.


Message Body: +Joel

What they're saying:  Rather than provide a clear and succinct explanation why I'm including you in this email thread, it's my expectation that you will read the 15 messages and replies below and discern the issue being discussed.  You are to also guess why I'm including you in this thread, and if there is an action item for you in the message below, it's expected that you will find it and take action immediately.

Sentiment implied:  My time is more important than yours.


Message Body: +[someone I don't know]

What they're saying:  Rather than provide a clear and succinct explanation why I'm including this new person in this email thread, it's my expectation that they will read the 15 messages and replies below and discern the issue being discussed.  They are to also guess why I'm including them in this thread, and if there is an action item for them in the message below, it's expected that they will find it and take action immediately.  Additionally, I am choosing to subject everyone else to a barrage of followup emails in the near future, as this new recipient will surely reply all, and ask numerous questions about this topic and why they were included on the email in the first place.

Sentiment implied:  My time is more important than the person's whom I've added to this email thread.  And everyone else's, for that matter.


Message Body: Joel, since [one member of your team] is on vacation, can you please help with the issue below?

What they're saying:  It's possible that you don't have any context in the long-running issue which is discussed in the 15 messages and replies below.  I was too busy to provide a succinct explanation or even ask if you're familiar with the issues below, so can you please read all of the messages below and guess at what further information may be required?

Sentiment implied:  My time is more important than yours.


Any time I receive emails like this in the future, I'll respond back to the authors with a link to this succinct and lucid blog post.  Maybe I'll even include an explanation why I'm sending the link!

Tuesday, August 22, 2017

An Important Change Is Coming for Application Express 5.2 (if you use the Mobile User Interface)

An important change is coming in Oracle Application Express 5.2.  The mobile user interface (based upon jQuery Mobile) will be deprecated.  The deprecation announcement will be included with the forthcoming Application Express 5.1.3 patch set release.

What this means for you

  • If you have applications developed with the mobile user interface based upon jQuery Mobile, they will continue to function in a supported fashion in Application Express 5.1.x.  Premier Support of Oracle Application Express 5.1.x continues until December 2021.
  • New mobile applications should be created using the Desktop User Interface and Universal Theme (Theme 42) and not the Mobile User Interface & jQuery Mobile-based theme (Theme 51).
  • Existing mobile applications should be migrated to the Universal Theme if you want to run them on Oracle Application Express 5.2 and later.

Why is this happening?

The last stable version of the jQuery Mobile library was released on October 31, 2014, and it only provides support for jQuery versions 1.8 through 1.11, and jQuery 2.1.  Patches are no longer provided for these versions of jQuery.  Application Express 5.2 will ship with jQuery 3.2 (necessary for us to adopt the latest Oracle JET libraries).  jQuery Mobile will not function properly with jQuery 3.2.

While we will make every effort to devise a way to include the necessary libraries for jQuery-mobile based applications in Application Express 5.2, that may not solve all problems entirely, especially when we try to include the data visualizations via Oracle JET, which have different dependencies.  We do truly strive to ensure backward compatibility of APEX applications across upgrades.  It's of paramount importance to us, and we spend a lot of time and energy ensuring that stability, operation, look and feel remain constant across APEX version upgrades.  But in this specific case, there doesn't appear to be a practical solution.  We're in a box.

There has been some recent activity in a new version of jQuery Mobile, namely 1.5alpha.  But given the fact that there was a very long hiatus on jQuery Mobile for an extended period of time, and it's unlikely that jQuery Mobile 1.5 will be stable enough by the time Application Express 5.2 is released, we collectively decided to announce depreciation of the Mobile User Interface based upon jQuery Mobile.  We literally spent months researching and contemplating this dilemma.  It's unfortunate.  The positive angle, though, is that we're in complete control of the Universal Theme and should not encounter similar issues with Universal Theme-based applications in the future.