Eclipse crashes in Debian Jessie

After some updates in my Debian/Jessie installation I run into a strange problem with Eclipse. When I start Eclipse first everything looks fine, but in the moment I use some type-ahead features or browsing classes or methods in a java-file Eclipse crashes without any error message. Maybe the problem is related to an update in libwebkitgtk-3.0.

After some searching I was finally able to fix the problem by adding the following line to my eclipse.ini:

-Dorg.eclipse.swt.browser.DefaultType=mozilla

See also this bug report:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=334466

‘evbug’ auf die Blacklist setzen

Ich hatte das Problem das mein kern.log file mit Meldungen dieser Art geflutet wurde:

Sep 27 18:07:48 r-ultrabook kernel: [ 380.012332] evbug: Event. Dev: input6, Type: 0, Code: 0, Value: 0
Sep 27 18:07:48 r-ultrabook kernel: [ 380.028334] evbug: Event. Dev: input6, Type: 2, Code: 1, Value: -1
Sep 27 18:07:48 r-ultrabook kernel: [ 380.028343] evbug: Event. Dev: input6, Type: 0, Code: 0, Value: 0
Sep 27 18:07:48 r-ultrabook kernel: [ 380.044419] evbug: Event. Dev: input6, Type: 2, Code: 1, Value: -1
Sep 27 18:07:48 r-ultrabook kernel: [ 380.044430] evbug: Event. Dev: input6, Type: 0, Code: 0, Value: 0

Diese Meldungen werden wohl vom Modul  ‘evbug’ erzeugt und dienen als Debug Information. Das Modul sollte im Normalfall eigentlicht im Kernel geladen werden.

Um nun das Modul abzuschalten kann man es auf die blacklist setzen.

Dazu habe ich die (bei mir noch nicht vorhandene) Datei /etc/modprobe.d/blacklist.conf erstellt und folgenden Inhalt eingetragen:

# This file lists those modules which we don't want to be loaded by
# alias expansion, usually so some other driver will be loaded for the
# device instead.
# evbug is a debug tool that should be loaded explicitly
blacklist evbug

Dies führt dazu das das Modul beim nächsten booten nicht mehr geladen wird und die Meldungen verschwinden.

Debian – Testing

In Debian werden Paket relativ selten aktualisiert und mit neueren Versionen ausgetauscht. Hier unterscheidet sich Debian deutlich von Ubuntu. Wen man dennoch ein wichtiges Update von einem Kernel benötigt kann man über die Backports diesen meist problemlos nach-installieren. Dies habe ich hier beschrieben.

Darüber hinaus gibt es aber auch die Möglichkeit über die DebianTesting releases neuere Paket zu nutzen. Ich beschreibe im Folgenden das grundsätzliche vorgehen.

Continue reading “Debian – Testing”

Debian – systemd

Debian Weezy verwendet in der aktuellen version immer noch den Init-Deamon System-V-init. Dieser kann durch den neueren deamon systemd ersetzt werden. Dieser erlaubt einen schnelleren  Bootvorgang, da beim booten mehrere dienste parallel gestartet werden können:

# apt-get update
# apt-get install systemd

 

Debian Installation

Hier folgen einige kurze Hilfestellungen zur Installation von Debian 7 (Wheezy)

Für die Installation von Debian wird die ‘Netzwerkinstallation‘ empfohlen. Es handelt sich dabei um ein ca. 200MB großes ISO Image welches von einem USB-Stick aus installiert werden kann. Sämtliche für die eigentliche Installation benötigten Komponenten werden werden später automatisch heruntergeladen. Continue reading “Debian Installation”

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.

So here is my Solution:

THE DIALOG FORM

I put my Dialog into a JSF faclet to separate all the dialog stuff in one xhtml element which can be included in the main pages. The interesting thing is here the JSF validation which is also supported. The dialog will not close if a validation error occurs. There for I check the #{facesContext.validationFailed} and save the state in a JavaScript variable. The ajax method ‘processCompleteEvent’ checks if a validation exception was thrown. In that case the dialog stays open, otherwise it will be closed after submit. The command button triggers a JSF 2.0 ajax request to avoid any changes on the main page behind the dialog.

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html">

	<script type="text/javascript">
		/*<![CDATA[*/
		$(document).ready(function() {
			// setup dialog
			$("#dialog-myprofile").dialog({
				resizable : false,
				width : 530,
				modal : true,
				autoOpen : false
			});
		});

		// auto close dialog and check validation... 
		var validationError=false;
		function processCompleteEvent(e) {
	          if (e.status == 'success') {
	        	if (!validationError) {
	        	 	$("#dialog-myprofile").dialog("close");
	       	 	}
	          }
	        }
		// open dialog
	 	function openMyProfile() {
			$("#dialog-myprofile").show();
			$("#dialog-myprofile").dialog("open");			
	    	}
		/*]]>*/
	</script>

	<div id="myprofile_view">
		<!-- Dialog Box -->
		<div id="dialog-myprofile" title="#{message['profile.title']}">
			<h:form id="dialog-myprofile-form">
				<ui:include src="/pages/error_message.xhtml" />
				<script>validationError=#{facesContext.validationFailed};</script>
				<h:inputText
					value="#{userController.workitem.item['txtusername']}"
					style="width: 260px;" />

				<!-- Save Action -->
				<h:commandButton actionListener="#{userController.doProcess}"
					 value="#{message.save}">					
					<f:ajax execute="@form" render="@form"
						onevent="processCompleteEvent">
					</f:ajax>
				</h:commandButton>
				<input type="button"
					onclick="$('#dialog-myprofile').dialog('close');"
					value="#{message.close}" />
			</h:form>
		</div>
	</div>
</ui:composition>

 

HOW TO OPEN THE DIALOG FROM THE MAIN PAGE

To open the Dialog from my main template I use a h:commandLink with an onclick event to open the jQuery dialog. See the following code snippet:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core"
<h:head>
.....
	<script type="text/javascript" src="../jquery-ui-1.10.0.custom.min.js"></script>
	<script type="text/javascript" src="../jquery-1.9.0.js"></script>
.....
</h:head>
<h:body>
   <f:view id="main_view">
.....
	<h:form id="main_form">
...
		<h:commandLink onclick="openMyProfile();">
			<h:outputText id="profile_userlink"
				value="#{message.open_profile}" />
			<f:ajax render=":dialog-myprofile-form" />
		</h:commandLink> 
	</h:form>
...
	<ui:include src="/pages/profile/myprofile_dialog.xhtml" />
   </f:view>
</h:body>
</html>

The trick here is again the ajax integration of the commandLink.

<f:ajax render=":dialog-myprofile-form" />

The f:ajax tag will rerender the dialog form. This is an important part of this solution, because you need to reset the old data of the dialog when the dialog is reopened. For example when the user opens the dialog, types in some data and close the dialog without submitting the data. In this scenario it is necessary to reload the dialog form data. This is done by the ajax render command.

So that’s it. I hope this will help someone.

Using @multipartconfig in a servlet running on 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>
.....

 

 

How to Submit an Embedded Form in jQuery Dialog using 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.

So my first approach was to change my form post action into a ajax post action. This can be done easily during the initialisation of the dialog. See the following code snippet:

/**
 * Method to initialize the feedback dalog.
 * @see contact_dialog.xhtml
 */
function initContactDialog() {
    // set default settings for profile dialog
    $("#dialog-contact").dialog({
        resizable : false,
        height : 530,
        width : 550,
        modal : true,
        autoOpen : false
    });


    // hide contact dialog per default
    $("#dialog-contact").hide();
        
    // the following method modifies the submit request into a ajax request
    // So the dialog will be closed after the submit was successfull without
    // affects to the main page.
    $('#dialog-contact-form').submit(function() {
        
        // show up waiting panel
        $(".ajax-wait-panel").addClass("ajax-waiting"); 
   
        $.ajax({
               type: "POST",
               url: "http://localhost:8080/myrestservice",
               data: $("#dialog-contact-form").serialize(), // serializes the form's elements.
               success: function(data)
               {
                   $(".ajax-wait-panel").removeClass("ajax-waiting"); 
                   $("#dialog-contact").dialog("close");
               },
               error: function(data)
               {
                   alert('An error occured. Could not send data!'); // show response from post.
                   $(".ajax-wait-panel").removeClass("ajax-waiting"); 
               }
             });

        return false; // avoid to execute the actual submit of the form.
    });
    
}

With the initContactDialog() method I initialize the dialog and bind a function to the submit event of my form. The function changes the submit into a ajax call and closes the dialog after the ajax request was finished.

This is quite easy and the dialog will automatically close when the Ajax submit was finished.

Here is the html part of my dialog form:

    <!-- Dialog Box -->
        <div id="dialog-contact"  title="#{global.contact_title}">
            <form id="dialog-contact-form" method="post" name="contact_form">

                <h:panelGrid columns="2">

                    <h:panelGroup>
                        <dl>
                            <dt>#{global.contact_firstname}:</dt>
                            <dd>
                                <input type="text" name="txtfirstname" value="" />
                            </dd>
                        </dl>
                    </h:panelGroup>
                    <h:panelGroup>
                        <dl style="">
                            <dt>#{global.contact_lastname}:</dt>
                            <dd>
                                <input type="text" name="txtlastname" value="" />
                            </dd>
                        </dl>
                    </h:panelGroup>
                    <h:panelGroup>
                        <dl style="">
                            <dt>#{global.contact_email}:</dt>
                            <dd>
                                <input type="text" name="txtemail" value="" />
                            </dd>
                        </dl>
                    </h:panelGroup>
                </h:panelGrid>
                <dl style="margin: 0 0 0 0px;">
                    <dt>#{global.contact_message}:</dt>
                    <dd>
                        <textarea style="width: 450px; height: 80px;" name="_description" />
                    </dd>
                </dl>
                <input type="submit" value="send" />

            </form>
            <div>
                <h2>#{global.please_wait}</h2>
            </div>
        </div>

I open the dialog with the following JavaScript function:

 /**
 * helper method to open the contact dialog. 
 * The method creates a new empty contact workitem.
 */
function openContact() {    
   $("#dialog-contact").show();
   $("#dialog-contact").dialog("open");
}

AJAX ‘WAIT-PANEL’

As you can see in my script and in the html snippet I have added a div section with the class ‘ajax-wait-panel’. This div overlays the form of my dialog when the ajax call is started. So the user will see a ‘Please wait’ message until the ajax request is finished. I simply add the class ‘ajax-waiting’ to the div section in the moment the request starts and remove the class when the submit was finished. So this is the css part of my solution:

/* Ajax-wait-panel can be useded in jquery dialogs
   for long runnign ajax request.
   Start by setting display:none to make this hidden.
   Background we set to 80% white with
   our animation centered, and no-repeating */
 .ajax-wait-panel {
    display:    none;
    position:   absolute;
    z-index:    1000;
    top:        0;
    left:       0;
    height:     100%;
    width:      100%;
    background: rgba( 255, 255, 255, .6 ) 
                url('ajax-loader.gif') 
                50% 50% 
                no-repeat;
    cursor: wait;
}

.ajax-wait-panel  h2 {
    position: absolute;
    top: 50%;
    margin-top: -80px;
    color: #666;
    text-align: center;
    width: 100%;
}
/* Class to be added when ajax wait panel should 
   be displayed */
.ajax-waiting {
     display: block;
}