Latest posts from Codename One.
Blog

Questions of the Week 35
This week has been a bit slow with features and external progress as we’ve started to focus on the issues for the January release of 3.6. During December we’ll probably pause blogging between December 22nd and January 2nd as it would probably get lost to the ether for most of our audience. I’ll still be working and at least some of our team will, but we’ll focus on support and features/issues which will give us a lot to write about when we get back. ...

Seamless Storage Encryption
We had support for bouncy castle encryption for quite a while but it is not as intuitive as we’d like it to be. This makes securing/encrypting your app painful and so we procrastinate and eventually skip that “feature” altogether. Frankly, I hate working on encryption it’s painful… That’s why we procrastinated on this feature until today! We now support full encryption of the Storage (notice the distinction, Storage is not FileSystemStorage). This is available by installing the latest bouncy castle cn1lib from the extensions menu then using one line of code ...

Default Validation Emblem
The validation framework makes it easy to verify input quickly and effectively. Up until now you had to define an emblem in order to create an error icon and if you didn’t you had to define an “Invalid” UIID for every entry. This exists by default for text fields and other types but is still a big hassle just to check that we have a valid email… The main reason for this is that when we introduced the validation framework we hadn’t yet integrated the material icons into Codename One, this was remedied and starting with the next update we’ll have a default emblem. Notice that if you replace it manually your emblem will still be used… ...

TIP: Avoid 2D Arrays
In the first betas of Codename One we had a lot of bugs related to 2D arrays due to XMLVM. We no longer use XMLVM but the recommendation to avoid 2D arrays remains. We still use them in some occasions e.g. in the creation of a DefaultTableModel but the implementation discards them in favor of an ArrayList internally. __ | To be fair, a 2D array will be faster than an ArrayList so in this case we discarded them due to their lack of ...

Questions of the Week 34
While I find these posts useful I think it’s time to re-think this post which is overly mechanical and only post interesting news from the week rather than “everything”. So this week we’ll try something new, I’ll discuss the news in general and the questions/answers I find valuable only. I’ll ignore the other questions and this should make the post more “digestible”. peopletookallthegoodnames asked about Storage to FileSystemStorage mapping here. This is a problematic subject. Storage is an abstraction, the fact that the implementation can be seen sometimes within the FileSystemStorage is a “leak” within the abstraction. ...

Request Body, Dialog & Border Layout
Subclassing isn’t bad but it becomes tedious especially if it’s just there to implement something trivial. One of the pain points we had with the ConnectionRequest API’s is the submission body wasn’t as convenient as it should be. E.g. if my web service accepts JSON in the post argument I have to write something like this: ConnectionRequest r = new ConnectionRequest(myURL, true) { protected void buildRequestBody(OutputStream os) throws IOException { os.write(myJSON.getBytes("UTF-8")); } }; This works great but does it really require subclassing? ...

How you can Help Spread Codename One
I’ve written this in emails before and on quite a few occasions but this bares repeating. Gaining visibility in this industry is tough especially when the industry is driven by the likes of Google, Facebook & Apple. Despite years of effort, most Java developers or mobile developers haven’t heard about us and it’s still an uphill battle for awareness. If you like our product and think we are doing something important it would be VERY helpful for us if you can help us with these small things. ...

Connecting to a MySQL Database from Codename One Part 2: Pure Java
In my last post I demonstrated how to integrate a MySQL database into a Codename One app using Xataface as a web service layer. In this installment, I’m going to demonstrate how we can build an equivalent app using a Java web service layer. Requirements For this tutorial, I’ll be using NetBeans 8.1 and its bundled GlassFish 4.0 container. If you don’t already have a MySQL database set up, then I recommend you install XAMPP XAMPP, as it provides a double-clickable installer for Mac and Windows and an easy administration console. ...

TIP: Cross Platform Update Available Strategy
One of the nice things in mobile development vs. desktop is the fact that updates are seamless. We supposedly don’t need to worry about them and most newer OS’s turn them on by default. This keeps are users with the latest version which is important, e.g. if we fixed a crucial bug or added a new monetization option… However, the reality rarely fits into this nice image. In practice an update can be delayed because of permission changes user settings and many other problems. As a result old and even discontinued apps can still exist on user devices and give you a hard time with user complaints. ...

Questions of the Week 33
This has been a very busy week, we published new information on the properties approach which I’m excited about but I’m not sure if I can drum up your enthusiasm… Steve made a big post about mysql support too. Todays library update includes new simulator code that might break some apps if you’ve refactored stuff around so be vigilant and let us know if something suddenly stops working. On stack overflow things were as usual: ...

Connecting to a MySQL Database from Codename One
In the following series of blog posts I’m going to shift some attention to server-side development in so much as it can complement a Codename One client application. In this post I’ll demonstrate how you can combine a MySQL database, a web-service layer, and a Codename One client to produce a “Contacts” app. I’m going to steal the Contacts code from the Kitchen Sink demo for the UI, but I’ll implement a different datasource that loads the contacts from a remote MySQL database instead of from the phone’s internal contacts. ...

Fail Fast & Margin/Padding Performance
One of the frustrating parts in Codename One is builds failing in the cloud, the expectation is that a build that passes locally would pass in the cloud and that is something we strive to have at all times. One of the more common failures for new developers is due to refactoring of the main class or changing the signatures of the methods e.g. adding a throws clause to start(). ...