This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

Category: Development

Joomla/RSForms post request to Java Servlet

Maybe this information is useful for other Joomla/RSForms users or for developers who want send a post request from php to anywhere :)

I had the following configuration in my dev environment:

Joomla together with RSForms (free version)

I love to use this combination because it is easy and just works. With RSForms I created some forms like User registration. This tool allows you to send emails to the registered user and it stores the registration automatically in the database. It's really useful.

In my case, the user registration was not real-time because I got an email and had to create a user account manually. This is web 0.1.

Well, I decided to push the whole process to web 2012. My plan was to create a simple Java servlet that creates my user accounts. This servlet should be called from the RSForms component, with a simple POST request. I don't like SOAP overhead, so it was no option for me. Of course, my servlet is a service :)

BTW, I wouldn't change the RSForms component because it should work as it was. The component has a nice feature that allows you to configure custom scripts for loading and processing.

I started with the configuration and added following process script:

$url = 'https://tomcatvm/services/User';
 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

$data = array();
$data[] = 'language=en';

foreach ($_POST['form'] as $post => $value)
{
    if (is_array($value))
    {
        foreach ($value as $post2 => $value2)
        {
            $data[] = $post.'[]='.urlencode($value2);
        }
    }
    else
    {
        $data[] = $post.'='.urlencode($value);
    }
}

curl_setopt($ch, CURLOPT_POSTFIELDS, implode('&', $data));
 
$data = curl_exec($ch);

if (curl_errno($ch))
{
    JUtility::sendMail($form->emailfrom,$form->emailfromname,
    'support@sibvisions.com','Service error',
    'Service call failed! ('.curl_error($ch).')',$form->emailmode,null,null,null);
}

curl_close($ch);

The code is written in php, but it is not rocket science. It simply sends a post request to the configured URL. The important thing is that all form parameters were used as parameters for the request, because the service needs the entered values!

That's all for Joomla/RSForms. During development I thought that the process script will be executed only once per form but that was not true. It was executed after loading and everytime when the user submits the form. If the forms had validation errors, the process script was executed more than once (with and without valid inputs).

I changed the php script a little bit and moved the process execution after the validation. It depends on your RSForms version, but in my case the original script (/plugins/content/mosforme.php) looks like:

...
eval($form->script_process);

if(!empty($processform)){
...

and the new script:

if(!empty($processform)){
...
    if(!empty($_SESSION['formmsg'])){
    ...
    // store it in the db
    ...
    eval($form->script_process);
    ....
}

But it is also possible to use the original script without modification.

The other side was the servlet... It's to simple to show you the whole source, only a snippet:

@Override
public void doPost(HttpServletRequest pRequest, HttpServletResponse pResponse) throws ServletException
{
    String sParamFirstName;
    String sParamLastName;
    String sParamEmail;

    try
    {
        sParamFirstName = getParameter(pRequest, "firstname");
        sParamLastName  = getParameter(pRequest, "lastname");
        sParamEmail     = getParameter(pRequest, "email");
        sParamLanguage  = getParameter(pRequest, "language");
    ...

JavaFX TableView with Database records

JavaFX has a nice looking TableView and it offers useful functionality, but the standard implementation is not useful for real-world database applications.

Why?

  • You must fill a TableView manually with records from the database, because JavaFX has no datasource support integrated. This means you have to use JDBC directly or libraries like EclipseLink or Hibernate, to fill your table.
  • If you fill your TableView manually, you miss support for database sort operations. JavaFX supports memory sort but if you have millions of records, it is not the best idea to fetch all records for simple sort operations.
  • Support for lazy-loading/load-on-demand is not integrated. With load-on-demand, I mean the possibility to load records when the UI requests them. If you have a database table with e.g. 10 million records, the UI should load the first 1.000 (or more). If the user needs more records, the TableView should load more automatically. I won't use paging for this use case.
  • Column resizing works well but is not user-friendly. The CONSTRAINED_RESIZE_POLICY is like auto-resize in JTable. It allows column resizing within the table width, but it is not possible to enlarge the table horizontally. The UNCONSTRAINED_RESIZE_POLICY allows enlarging but adds an extra "column". This column is not selectable and fills the gap if the total column width is smaller than the table width. We need a resize policy that supports both and such a policy is not included in JavaFX.
  • The default selection model offers ROW and CELL selection, but in ROW mode you don't see the selected cell (= focus). If you need an editable TableView it is a problem if you can't see the selected cell.
  • If you need an editable table, you have support but not a working solution - especially if you work with database records.
  • Missing support for Insert and Delete rows with keyboard. It is possible to start updating values with <F2>.
  • No standardized solution for Master/Detail with multiple levels.

I don't say that it is not possible to implement above features, but if you don't create a custom control, you'll have a lot of boilerplate code in your applications. Some features are not trivial because the APIs do not offer relevant methods and the JavaFX control development model hides a lot of functionality. Of course, it is always possible to create new controls, but it is not cool to reinvent the wheel. One problem is that the TableView implementation together with the TableViewSkin and TableViewBehavior are not very developer friendly, because the classes are not really extendable. Most important methods are private or final. Another problem is that you need css and code together, for specific features. It is easy to change padding with css but where is a method in the API?

A solution for the datasource problem is offered from the DataFX project.

I'm a developer for business application frameworks and most applications are connected to databases with or without an application server. The applications must be fast and responsive. It helps if an application looks fancy, but functionality is more important.

Sometimes I think that JavaFX controls are really impressive but their developers should create real-world (business) applications.
If you get feedback from your paying customers you know exactly what you have to do and which features are good and important. My personal opinion is that Oracle should ask application developers and work with them to solve real-world problems.

With JVx, we have a full-stack-application framework that solves our business problems and we try to implement new UI technologies as soon as they are market relevant. So we started with the integration of JavaFX. We tried to solve above points, because they are very important for us.

Our current development progress is available as OpenSource (sub)Project of JVx and is licensed under Apache 2.0.

What we have solved so far?

All above points, but more or less clean. Some solutions are "dirty" because we have no API or didn't find a better solution.

"Dirty" solutions?

  • Column resize policies are supported but relevant features are missing or hidden, e.g. The TableView retrieves the content-width from the TableViewSkin (via general control properties - getProperties()) because the TableView has no access to scrollbars and the content width is different with and without vertical scrollbar. This is dirty and does not work in any cases in the original TableView, but this information is important if you develop your own resize policy! We need more and better access through the API.
  • Load-on-demand works but this is the dirtiest hack. It is not so easy to add a feature that was not planned. We used a custom event dispatcher to made it possible. We must check the implementation with every TableView update...
  • Show focused cell in ROW selection mode is possible with CSS but it is horrible.

There are more funny solutions, but the result just works. One additional and maybe interesting feature is, that we don't change the row height if you start editing. It was annoying that the table height toggled in edit mode.

Our current solution offers an editable TableView which is connected to a database (2 or 3-tier architecture). All sort operations are delegated to the database. The solution supports any Master/Detail relations (memory, db and mixed) and loads records automatically from the database. All Insert/Update/Delete operations are sent to the database.

Our current solution is not finished because we don't have specific cell editors. We have to implement cell editors for Number/Date/Images/LOVs (= ComboBox).

A first impression:

TableView with Database

TableView with Database

  Country - States - Districts

with Master/Detail/Detail

The database:

CREATE TABLE COUNTRIES
(
  ID      INTEGER IDENTITY,
  COUNTRY VARCHAR(200) NOT NULL,
  EU      CHAR(1) DEFAULT 'N' NOT NULL,
  constraint CTRY_UK UNIQUE (COUNTRY)
)

CREATE TABLE STATES
(
  ID      INTEGER IDENTITY,
  CTRY_ID INTEGER NOT NULL,
  STATE   VARCHAR(200) NOT NULL,
  constraint STAT_UK UNIQUE (STATE),
  constraint STAT_CTRY_ID_FK FOREIGN KEY (CTRY_ID) REFERENCES COUNTRIES (ID)
)

CREATE TABLE DISTRICTS
(
  ID       INTEGER IDENTITY,
  STAT_ID  INTEGER NOT NULL,
  DISTRICT VARCHAR(200),
  constraint DIST_UK UNIQUE (DISTRICT),
  constraint DIST_STAT_ID_FK FOREIGN KEY (STAT_ID) REFERENCES STATES (ID)
)

Oracle Forms' best friends...

...should be JVx and VisionX.

Our integration of JVx applications is now available.
We won't replace Forms with Java and don't say that Java is better than Forms. Of course, Forms is not dead and it will probably never die. But, Forms uses Java as client technology and why shouldn't we bring more Java to Forms?

If you search for Java and Forms all you will find are relatively simple components or PJCs, e.g. a JTable integration in your forms module. There are a lot of "ready-to-use" examples, but if you are not a Java pro, it will be hard to understand what happens.

I know that Forms needs a face lifting, but it is not a good idea to start from scratch. You should start pimpin' with some cool icons, colors and a nice background image. But if you need better usability, don't try to reinvent the wheel. You need more than modern controls like a JTable with sort-on-header. Do you know how you fill your table with data or how you transfer data from a remote database to your application within a 3-tier architecture?

What you need is a framework that is as powerful as forms, offers modern controls and solves communication problems. And it must be simple - should just work, because Forms simply works.
Oh... I forgot that the framework must work in Oracle Forms and without Forms. It must be a one-4-all solution.

If you think that this is impossible then you are wrong, because it works!

We married best of both worlds.

  • Use a modern table in your forms application and don't think about how you connect the table to your database. You get table headers and sort-on-header for free :)
  • Use layout managers for dynamic GUIs instead of fixed size GUIs.
  • Call a stored procedure on button click within your Java bean? No problem.
  • Use modern Look and Feels and pimp your forms GUI.
  • You need REST services? They are already implemented.

And you don't need different frameworks or tons of libraries. You need exactly one framework - JVx. It solves all your problems and with our Forms integration, it is possible to use your Java application within your Forms application without code changes.

We have some screenshots for you :)

Forms application with Java screen   Java screen without Forms

On the left side, you see the Forms application with exactly the same screens as in our Java application on the right side. We added a close button to the forms application, because it is Forms and you decide when you need Java and when standard Forms controls are better.

Oh... when you think you must migrate your Forms application to another technology - why do you think that? Modernize your existing Forms applications and if you decide to replace Forms, your Java screens are ready.

Flyspray as Ticket/Support System

Every (open source) software project needs a tool for bug reporting. Without such a tool it is hard because you need spreadsheets or mailing lists to manage todos. I think every developer knows why such tools are used ;-)

There are a lot of bug reporting tools like Bugzilla, JIRA, trac, Mantis, ... There are also a lot of project management tools with built-in ticket systems like Redmine.
It depends on your needs, if you develop open source or commercial software, the available money, ... which system is best suited.

We evaluated some systems and decided us for Flyspray.

Why?

We need a bug tracker that

  • is also a change request management tool
  • should be used from our customers (end-users)
  • should not have tons of configuration options
  • should be commercially useable
  • should be open source
  • should be easily adaptable
  • should allow custom styles/themes
  • should be template based
  • should not waste development time

Many points have been met from different tools, but the popular tools were too complex or heavy weight. Flyspray is different, because it focuses on the basics. One of the problems are custom styles/themes. It supports custom themes but it does not support custom site templates.
But it offers most features that a professional system should have, it is small and easily adaptable - compared to other tools. And the tool is not only for developers. An end-user can handle it.

We knew that the system needs some tweaks. We added support for

  • custom site templates (per project)
  • custom mail templates (text, html, ..)
  • enter officer for a ticket (group setting related), add effort (per ticket, per comment), add internal comments
  • added a switch that disables global priorities/severities,status, ...
  • set severity colors via database per project (instead of css)

This are some of our changes. We also fixed some layouting problems and created custom themes/templates.

If you are interested, look at our Flyspray installation:

SIB Visions Theme:
https://oss.sibvisions.com

Different style/site templates:
https://oss.sibvisions.com/index.php (WebUI)

If you are interested, leave a comment.

JVx nightly builds

We have posted that JVx quality reports are available.

Today, we also offer nightly JVx builds. The builds contain (nightly) in the Implementation-Title and Implementation-Version.

Don't use nightly build versions in production environments.

To use our nightly builds, go to

https://dev.sibvisions.com/jvx.nightly/

and click the Download link in the top menu.

JVx EE Master Thesis

Congratulations to Stefan Wurm for graduation!

He sent us his Master Thesis about JVx EE. It is a great documentation about the features and power of JVx EE. The document is in German.

Feel free to send us your comments.

The project is hosted on sourceforce and is available under Apache License 2.0.

Oracle Forms with JavaFx and Swing

I'm sure that some of you have already used custom swing controls in Forms applications to enrich them. But have you tried to use JavaFx together with your Forms application?

JavaFx has cool effects, animations, controls, css styling and much more.

If you enter 'oracle forms javafx' or similar, in your favourite search engine, you get no specific results. So I think it is time to integrate JavaFx to an Oracle Forms application, isnt't it?

- It is a world premiere -


First, a screenshot:

Oracle Forms and JavaFx

Oracle Forms and JavaFx

We used the source code from the official example, that integrates JavaFx in a Swing application.

The result of our integration is a screen that contains Swing and JavaFx controls. If you change a value in the table, the chart is updated immediately. It is really cool because the chart has nice transition effects.

You can combine rapid application development with modern controls and new development concepts.

Oracle Forms together with JVx/Swing (modernization)

The good old Oracle Forms UI does not look really cool. Of course, you can use nice icons and choose the right colors, but the controls are not fancy compared to swing controls.

If you try to to migrate from Oracle Forms to Java, wouldn't it be great to migrate one screen after the other. Or better, create new screens with Java and integrate them in your existing Oracle Forms application. Use both technologies as long as is necessary.

Don't think that you have to migrate the whole Oracle Forms application, migrate step by step. It is absolutely possible to use your new screens in your Oracle Forms aplication or as separate application without Forms. Save time, money and don't replace your existing Oracle Forms developers.

You would like to see how this can look like?


The first screenshot shows a standard Java swing application, with a simple master/detail and some editors:

JVx Swing UI

JVx Swing UI



The next screenshot shows the same screen (without source code changes) used in an Oracle Forms application:

Forms with Java screen

Forms with Java screen



You are right, it is great to embedd the same Java screen, but the Look and Feel is not very cool. Do you know that Java has some nice LaF's? Here is the same screen with Nimbus Look and Feel:

Oracle Forms Nimbus LaF

Oracle Forms Nimbus LaF

JVx EE Source Code is available

The scource code is online. Thanks to Stefan for his great work!

Check out the project page.

In the coming weeks we will finalize the documentation and build the binaries.

You find the JPA integration and a complete example application in the repository.
Have fun.

JVx EE

Our new project is created and we are preparing the source upload.

JVx EE

What is JVx EE?

It's the integration of JPA 2.0 in JVx. Create professional backend software with JVx and use your domain model which is already available in your Java EE based web application. With JVx EE you can use the configured EntityManager and JPA implementation of your web application. Reuse your existing DAOs or EAOs without changes in your application.

With JVx EE it is possible to create a standard JVx application that is connected to your domain model, e.g.:

JPAStorage jpaAddress = new JPAStorage(Address.class);
jpaAddress.setEntityManager(getEntityManager());
jpaAddress.open();

or with a custom EAO

CustomerEAO eaoCustomer = new CustomerEAO();
eaoCustomer.setEntityManager(getEntityManager());

JPAStorage jpaCustomer = new JPAStorage(Customer.class);
jpaCustomer.setEntityManager(getEntityManager());
jpaCustomer.getJPAAccess().setExternalEAO(eaoCustomer);
jpaCustomer.open();

Do you need a professional backend application for your existing web frontend? Use JVx and your problems are solved. You get all advantages of JavaEE in your JVx application.

JVx EE is licensed under Apache License 2.0.

Do you have any questions? Let me know.