How to use a jQuery Dialog in JSF 2.0
Combining JSF 2.0 and jQuery / jQuery-UI is in my opinion the best choice to build modern web applications. Your JSF web application becomes much smaller as using one of the JSF component libraries. Also with jQuery you got a lot of flexibility designing your pages.
But things become interesting when you try to integrate a jQuery Dialog box with JSF 2.0. I am talking here about a Dialog Box which contains a JSF form with input elements to be submitted - independent from the current page flow. For example: you have a normal jsf form with input components and a link to open another form (in my case a user-profile dialog) also with data which can be submitted. It takes me some time to figure out the best way to manage this. But with JSF 2.0 and ajax support things are not so difficult.
[Read More]
Posted at 05:04PM May 08, 2013
Posted by: Ralph
Category: General
using @MultipartConfig in a servlet in GlassFish 3.2.2
Today I run into a problem with a custom JSF component using the @MultipartConfig. Trying to use my FileUpload Bean (http://www.imixs.org/jsf/fileupload.html) results in the following error message:
[#|2013-04-26T15:37:21.769+0200|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=20;_ThreadName=Thread-2;|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalStateException: PWC4016: Request.getParts is called without multipart configuration. Either add a @MultipartConfig to the servlet, or a multipart-config element to web.xml
It seems that this error did not be thrown on a GlassFish 3.2.1 server.
Finally I was able to fix the problem when adding the following servlet configuration into the web.xml file for my Faces Servlet.
...
<!-- Facelets -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>0</load-on-startup>
<multipart-config>
<location>/tmp</location>
<max-file-size>20848820</max-file-size>
<max-request-size>418018841</max-request-size>
<file-size-threshold>1048576</file-size-threshold>
</multipart-config>
</servlet>
.....
Posted at 01:52PM Apr 26, 2013
Posted by: Ralph
Category: General
Eclipse Juno (4.2) for Maven Developers
Since last year the new Eclipse IDE 4.2 is available. Version 4.2 comes with a new architecture and so I thought it was time for me to leave the 3.x version. I mainly develop JEE projects and I am using maven in most of my projects, but I also develop some Eclipse plugins. So the big question is what Version of Eclipse fits best my needs? When you take a look at the Eclipse Download Page you will see a list of different Eclipse Bundles. One of the largest and most downloaded version is "Eclipse IDE for Java EE Developers". So I thought that would be the best choice for me...
I worked with the "Eclipse IDE for Java EE Developers" version 4.2 for 3 months, and it was driving me crazy. In most cases it was very slow because of a large list of validators which are doing a lot of obscure things in background. But one of the most serious bug is the JPA plugin problem which makes it for me impossible to work 'normal'. Also when you updated SP2 this bug is still not fixed.
One additional interesting detail of the "Eclipse IDE for Java EE Developers" is the missing Maven support. I don't know why, but after all I think the reason why maven (m2e) is not included in this eclipse version are problems from some plugins to handle maven projects correctly.
So after all I came to the solution that for me the best choice is the eclipse bundle "Eclipse IDE for Java Developers". This bundle is much more smaller, stable and faster than the JEE bundle. And it includes Maven support out of the box! If you are happy with the "Eclipse IDE for Java EE Developers", stick with it. However, if you also run into problems, I recommend to use "Eclipse IDE for Java Developers". I also want to point out that I am running Eclipse on a Linux 64bit system. May be that things run different on this OS.
In the following section I will explain which plugins I have installed additional after I downloaded the "Eclipse IDE for Java Developers".
SVN Team support
Eclipse 4.2 is still missing SVN Team support out of the box. The only reason I can found is the fact that there are two SVN plugins available (subclipse and subversive). I am using subersive. You can select install the "Subversive SVN Team Provider" from the Juno download site (http://download.eclipse.org/releases/juno). After restarting Eclipse you should be automatically asked to install the SVN Connectors. For linux users I recommend the svnKit 1.7.8.
Finally you can add the svn maven support. The m2e team providers for subversive can be selected from the eclipse marketplace. This feature is useful to get the option to checkout a maven project directly from a svn repository.
Manual installation
For some reason in my case the connectors where not offered automatically. I think this happens because I opened a old workspace with svn connections before I installed subversive. I recommend to use an empty workspace when you install new plugins. So it was necessary to me to upate subersive plugin directly from:
http://download.eclipse.org/technology/subversive/1.0/update-site-1.0.1/
and then install the connectors via the update manager from:
http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/
Also I was able to install the m2e team provider 'm2e-subversive' directly from:
http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/
The J2EE Server Tools
The J2EE Server Tools providing a comfortable way to integrate the
Java EE Servers (e.g. GlassFish) into the Eclipse IDE. In "Eclipse IDE for Java Developers" these tools are not included so you need to install them manually.
First you need to install the JST plugin via menu "Help>install new Software" and search for "server". Select the "JST Server Adapters" and install it. For GlassFish server support you need to add a extra update site to install the latest GlassFish adapters. Add the followin Update Site URL:
http://download.java.net/glassfish/eclipse/juno
Read also the blog from Vince Kreamer for deails.
BPMN and Imixs Plugins
As you may know I am project lead of the open source project Imixs Workflow. This is the reason why I also install a BPMN and the Imixs Modeler Plugin to manage my workflow projects. The Imixs Modeller can be installed from :
http://www.imixs.org/org.imixs.eclipse.updatesite
To install the BPMN Plugin see BPMN2 Download page and check for the latest milestone or nightly build
Posted at 09:16AM Apr 01, 2013
Posted by: Ralph
Category: General
jQuery Dialog - Submit form with ajax
Today I searched for a solution to submit a form embedded into a jQuery dialog with ajax.
My situation is the following: I use a jQuery UI Dialog to display a feedback-form in my web application. The feedback form should not change the state of the page the user worked before.When the form was submitted the jQuery Dialog should close automatically.
Using jQuery makes the solution very easy....
Posted at 01:17PM Feb 16, 2013
Posted by: Ralph
Category: General
Bootstrap and jQuery UI
Bootstrap and jQuery UI
are both web frameworks. Both frameworks support web developers
designing web pages. Where Bootstrap is mainly supporting the design of
a web site in general jQuery UI is more focusing on the development of
programmatic design an the development of more complex requirements like
in applications. Both frameworks are based on css and the java script
framework jQuery. There is no reason why not to combine both frameworks
for your development.
But there are subtle differences in both frameworks that you have to realize before you begin working. [Read More]
Posted at 09:14AM Feb 02, 2013
Posted by: Ralph
Category: General
JSF f:ajax - how to locate components outside the current context
Using f:ajax in JSF 2.0 simplifies web design. Using the render and execute tags allows to update components in an ajax context.
But I run often into problems when I try to update a component outside my current context. For example in a table row of a h:datatable I want to update the table content after special actions.
You typically see log messages like this one:
f:ajax contains an unknown id 'j_idt90:painelTabela' - cannot locate it in the context of the component j_idt75
To solve such context problems you could bind the component to a view and reference its UIComponent#getClientId() in the ajax context...[Read More]
Posted at 10:51AM Jan 27, 2013
Posted by: Ralph
Category: General
Ubuntu - R-E-I-S-U-B: Reboot Even If System Utterly Broken
If your linux freezes and become entirely unresponsive (what should not happen after all) there exists a magic key sequence to perform a secure reboot:
While holding down ALT+SysRq, press R-E-I-S-U-B
See also: http://en.wikipedia.org/wiki/Magic_SysRq_key
But since Ubuntu 10.10 maverick this keys has been disabled . To re-enable it you have to modify the respective kernel parameter like this:
echo 1 | sudo tee /proc/sys/kernel/sysrq
As you can not enter this command in a frozen situation you should re-enable it every time at startup. So add the above line to crontab:
@reboot echo 1 | sudo tee /proc/sys/kernel/sysrq
To edit chrontab use :
sudo crontab -e
To force linux to check your partition during the next boot use the following command:
sudo touch /forcefsck
Posted at 10:32PM Dec 13, 2012
Posted by: Ralph
Category: General
Wortmann Terra Mobile 1450 II running Ubuntu!
Today I got my new ultrabook 'Wortmann Terra Mobile 1450 II' with Intel i7-3517U, 8GB and 240GB SSD. This is a great ultrabook!
I installed Ubuntu 12.10 64bit. Works great out of the box. Only one issue concerning the missing TouchPad functionality. As explained in this forum this problem can be easily fixed with the following changes of linux kernel options. (Please note that you should have already worked with Linux before you change your configuration - If it goes wrong you can make a refresh install ;-).
- make a copy of the grub boot loader configuration '/etc/default/grub'
- edit the configuration file '/etc/default/grub'
for example from a terminal with the command:>sudo vim /etc/default/grub
- change line GRUB_CMDLINE_LINUX="" into GRUB_CMDLINE_LINUX="i8042.noloop"
- save your changes
- from a terminal run the command:
>sudo update-grub
- finally reboot your system
Now the touchpad should work. You can enable/disable it also with key 'Fn+Esc'
Optimize the SSD
In addition I changed the settings of my SSD in the '/etc/fstab'. If you edit this file you can add the options 'noatime,nodiratime'. For example the mountpoint can look like this:
UUID=[ID] / ext4 errors=remount-ro,noatime,nodiratime 0 1
Note that '[ID]' means here your! partition-id - don't change it!
Update 19.12.2012
After I had some randomly system freezes, I installed manually the kernel version 3.6.10.
With this kernel the system runs now stable. I think the kernel update is mandatory.
Posted at 07:43PM Dec 11, 2012
Posted by: Ralph
Category: General
The Imixs Workflow project
Today I want to talk about the Imixs workflow project which is under development for more than 5 years. Since the project is based on the Java Enterprise Edition 5 it becomes more stable, flexible and serious. Version 3.0.x based on GlassFish 3 and JEE6 makes the project very powerful and robust. There were a number of simplifications which had made it much more easy to integrate the imixs workflow engine into JEE projects.
Now I am working on version 3.1.0 which is available in a snapshot-release. This new version has some improvements in the Imixs Workflow engine which is the core of the project. But also in this new version, I try to figure out a way to develop JEE web applications in a leaner way without heavy JSF libraries like RichFaces (which is really great stuff). My idea for now is to work with JSF 2.0 in its reference implementation. As this version provides ajax support in a standardized way I believe that rich web applications can be implemented with more usage of javascript - after all jQuery.
So for now everything looks pretty cool in the new version 3.1.0 which is also used in the next version of the Marty framework. Marty is a general workflow framework to simplify the development of business applications based on the imixs workflow project. The result of all this work can be seen in the Imixs Office Workflow project. This project site is only available in german language, but I plan also to provide an international home page.
In the future I will post the status of the current development on this blog.
Posted at 09:28PM Nov 19, 2012
Posted by: Ralph
Category: General
Eclipse Juno - slow....
With the current Eclipse Release 4.2 I am running in the currently discussed performance issue (https://bugs.eclipse.org/bugs/show_bug.cgi?id=385272)
For now the best solution for me is to delete the workbench.xmi file.
- Navigate into your workspace sub folder .metadata/.plugins/.org.eclipse.e4.workbench
- Remove or rename the file workbench.xmi.
- Restart the Eclipse IDE
Posted at 10:19AM Nov 10, 2012
Posted by: Ralph
Category: General
GlassFish - Active Directory
Running JEE Applications on Glassfish can be easily connected to an existing Microsoft Active Directory Structure.
To authenticate a JEE application against Active Directory (AD) you can setup a LDAPRealm in Glassfish. Use the folowing example settings:
- JAAS Context: 'ldapRealm'
- Direcotry : ldap://your-ad-server:389
- Base DN: 'DC=mycompany,DC=local'
Additional to these standard connection settings (you should use your own environment configuration) you need to add the following additioanl Properties:
- search-filter = (&(objectClass=user)(sAMAccountName=%s))
- group-search-filter = (&(objectClass=group)(member=%d))
- search-bind-dn = some-technical-account (do not use distinguished name)
- search-bind-password = your-technical-account-password
- java.naming.referral = follow
The property 'java.naming.referral = follow' is necessary in most cases to avoid internal exceptions during a search request.
Thats it.
How to configure an external JNDI Resource
You can also use the AD to lookup additional ldap attributes from you application code. There for you need to add a external JNDI Resource which can be configured from the GlassFish console. Use the following example settings:
- JNDI Name : you-custom-resource-name
- Resource Type: javax.naming.ldap.LdapContext
- Factory CLass: com.sun.jndi.ldap.LdapCtxFactory
- JNDI Lookup: 'DC=mycompany,DC=local'
Also here you should add some additional properties:
- java.naming.provider.url = ldap://your-ad-server:389
- java.naming.security.authentication = simple
- java.naming.security.principal = some-technical-account (do not use distinguished name)
- java.naming.security.credentials = your-technical-account-password
- java.naming.referral = follow
The property 'java.naming.referral = follow' again is important here.
To lookup the external resource from your application you can use the either a annotation:
@Resource(name = "you-custom-resource-name") private DirContext ldapConn;
You can also do a programatic lookup like this:
Context initCtx = new InitialContext();
ldapCtx = (LdapContext) initCtx.lookup("you-custom-resource-name");
Posted at 03:17PM Oct 12, 2012
Posted by: Ralph
Category: General
JSF 2.0 - Ajax Suggestion Box
Since JSF 2.0 has introduced the ajax support it is quite simple to implement functional widgets like a suggestion input box. The following short tutorial shows how to build your own suggestion widget using JSF 2.0 and it's ajax capabilities. [Read More]
Posted at 08:09PM Oct 04, 2012
Posted by: Ralph
Category: General
Speedup Eclipse Juno
To my mind, the new Eclipse release 4.2 (Juno) is a little bit slower than Eclipse Indego.
To make it faster I changed the following things:
- disable validators
I disabled all Validators until 'Classpath Dependency Validator', 'Facelet HTML Vlvalidator' and 'HTML Syntax Validator' - disable maven index update
I disabled also the maven plugin feature 'Download repository index updates on startup'
Posted at 05:02PM Sep 19, 2012
Posted by: Ralph
Category: General
JEE6 and packaging an ear - part II
As I explained in my previous blog entry about JEE6 ear packaging, there is a flexible and powerful way to deploy EARs containing JEE component libraries.
Using maven makes it much easy to build such ear deployment units. The interessting part of the pom.xml of the ear module looks something like this....
[Read More]
Posted at 09:02PM Sep 18, 2012
Posted by: Ralph
Category: General
JSF 2.0 - Action event model
If you are working with JSF 2.0 there are different ways to interact with backend methods and passing params to action methods. A useful link for this topic can also seen here.
So for example if you have a JSF page with the following command link you use different ways to bound your backing bean:
<h:commandLink action="#{workflowController.editAction(workitem)}"
actionListener="#{workflowController.doEdit}">
<h:outputText value="click me" />
<f:setPropertyActionListener
target="#{workflowController.workitem}" value="#{workitem}" />
</h:commandLink>
The important thing here is the order which the jsf framework will trigger the differnt methods of the backingBean 'worklfowController'
- The actionListener method will be called
- The setPropertyActionListener will trigger the setter method of the property 'workitem'
- The action method with a custom param will be called
So in this case you backingBean can look something like this - note that there are two different ways to pass a param:
// first the actionListener method will be called
public void doEdit(ActionEvent event) throws Exception {
// do something...
.....
}
// next the setter for the property will be called
public void setWorkitem(Data aworkitem) {
// do something
}
// last the action method will be called
public String editAction(String action) {
// do something
return action;
}
Posted at 09:51PM Jul 29, 2012
Posted by: Ralph
Category: General