Wednesday, December 22, 2010

get2post (get request to post request conversion)

Sometimes for some reasons there is the need to convert a get request to a post request when the target site accepts only post requests. There is a simple way to do this with javascript by creating a form on the fly and posting it.

The function function get2post(requestUrl, target) can be called in this way:
get2post('http://www.yoururl.com?param1=value1&param2=value2');

or, you can specify a popup window or target by calling it in this way:
open('about:blank','Popup','resizable=yes,width=1015,height=700,scrollbars=yes');
get2post('http://www.yoururl.com?param1=value1&param2=value2', 'Popup');

You can look at the test page over here: get2post

In order to use this function, copy and paste the script below to your html site.
<script>
/* Author: Redi Gokaj
* Description: This function transforms a get request into a post request using javascript.
* http://www.redigokaj.com
*/

function get2post(requestUrl, target)
{
if (target == null) target = '_parent';

var postUrl = requestUrl.split("?")[0];
var parameters = requestUrl.split("?")[1].split("&");

var postForm = document.createElement("form");
document.body.appendChild(postForm);
postForm.setAttribute("action", postUrl);
postForm.setAttribute("method", "post");
postForm.setAttribute("target", target);
postForm.style.display = "none";

for (i = 0; i < parameters.length; i++)
{
var formElement = document.createElement("input");
var name = parameters[i].split("=")[0];
var value = parameters[i].split("=")[0];

formElement.name = name;
formElement.value = value;
postForm.appendChild(formElement);
}

postForm.submit();
}

</script>

Friday, August 27, 2010

Java compiler level does not match the version of the installed Java project facet.

When porting the Eclipse workspace to another computer or another java version there may happen an error like this:

"Java compiler level does not match the version of the installed Java project facet. Unknown Faceted Project Problem (Java Version Mismatch)"

Different solutions can be searched or applied but I would recommend you to check firstly if the JDK is properly installed and after checkcing this you need to right-click to the error and chose Quick Fix. After that there are shown 2 optional choices which one of them is to use your current JDK version. By choosing that you fix your workspace problem.

Sunday, June 6, 2010

gtk-recordMyDesktop audio problem

     When using gtk-recordMyDesktop in Ubuntu some people face problems when recording together with audio. The problem that I faced was a bad recording and sometimes skipping seconds during the audio record. After searching around you may find some solutions, but each is responsible for the specific problem that it explains. In my case, I found another simpler solution without making modifications. When using gtk-recordMyDesktop you can disable audio recording, but record your audio with "Sound Recorder" that comes installed in Ubuntu. In the end of your recording session you will have 2 files, one containing the video and the other containing the audio. Now its time to mix them. By using "MKV files creator" (you can find it in the software repository) you can merge audio and video directly without losing quality. The operation is done in an instant, so you don't even need to wait.

Friday, June 4, 2010

1 - Setting up the Eclipse environment

Watch in HD

1 - Setting up eclipse environment from Redi Gokaj on Vimeo.



This post contains the first tutorial on the Eclipse series for Dynamic Web Applications. Setting up eclipse environment together with Apache Geronimo 2.2 is the first step. All the work is done in Ubuntu.


In order to make PrimeFaces work we need to add to web.xml these:

<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>

And in order to use PrimeFaces in jsp tags, we need to add the following taglib:
<%@ taglib uri=”http://primefaces.prime.com.tr/ui” prefix=”p” %>

http://www.primefaces.org/downloads.html - Here you can find the JARs required to make it work

RSA & RDA - Logical to Physical Data Model Transformation

Watch in HD




Rational Software Architect Logical to Physical Data Model Transform from Redi Gokaj on Vimeo.

     The purpose of this video is to explain a scenario which shows the way how to create a database project using an object oriented approach. Rational Software Architect and Rational Data Architect (Infosphere Data Architect) are used for this tutorial. Using RDA and RSA you may watch this simple tutorial about creating a logical model. After that, converting it to a physical model. The third step will be creating the database, and after that creating the entities mapped with the database. With a sample web application, these entities are used and tested.

Thursday, June 3, 2010

How to develop software in a team

     When a team comes up and decides to work on a software it is very important to know how to work and how to synchronize with each other. The size of the project is not important in fact, what’s most important is the way the team members communicate socially and professionally. Below I will show a strategy which is from my experience and my researches, and of course I’m giving this strategy based on my opinion.

     In fact, to work successfully in a team there are many rules which we need to follow, but in this post there will be just a strategy for software developing. As a sample I will take the windows platform.

     Now, let’s get started in the first step. We need to have a network connection between the team mates. If they are not found in a room, we need to set a Virtual Private Network (VPN) using internet. A free for non commercial use is Log Me In Hamachi. Using this software you are given an IP and you can invite your team mates so you will create a virtual network to communicate with your team mates. In this case you can even share your database server and make this work on a single computer.

     The next step is the platform where you will deposit your codes, so in this case I chose Visual SVN Server which is again free and you can easily install and manage it. In your Visual SVN Server manager you can set users which can access your repository. I recommend that you use HTTPS access in order to make it more secure.

     The third step is to install a SVN client which in this case can be Tortoise SVN and you can connect to the created repository. The database server and the Visual SVN Server can stay just at the computer that you chose as a server. Instead, the SVN client should be installed in all computers that want to connect to the repository on the server.

     Finally let’s mention the steps one by one:

      1. Install Hamachi in order to create a VPN
      2. Install Visual SVN server in order to create a repository to share your source codes
      3. Install Tortoise SVN or any other SVN client that you may want

     As you see this was really easy, but remember that this was just your environment setup. In order to have success and finish without having problems there are more advices that you need to follow.

 
Work with Diagrams

     Before starting to develop your project, you need to spend time on designing it. Diagrams are very helpful in making you understand the current status of the project. Also, you may need diagrams later in order to check if the planned ideas are being developed well.

 

Always use TO-DO Lists

     There are two kind of to-do lists that you may use: a short term and an long term one. The long term to-do list will help you understand the current status of project completion. Instead, the short term to-do list will help you manage time and work better in a weekly based cycle. So, each week assign tasks to all the team members and make a check about this tasks at the end of each week. By writing everything the possibility that you forget something decreases to zero percent.

 

Write down your ideas

     Always write down your ideas that you may have in any instant. From daily stress and work you may forget things that may be precious for your project.

 

     This was all I could give you as an advice in a wide point of view. Comments, suggestions and critics are welcome in order update this post and make it more valuable. I wish you luck and a happy team work!

 

Links:

https://secure.logmein.com/US/products/hamachi2/

http://www.visualsvn.com/server/

http://tortoisesvn.tigris.org/

Tuesday, June 1, 2010

SMART CITY: 1st prize in IBM Turkey, Software Academy 2010



IBM Turkey, Software Academy 2010

SMART CITY Project won the 1st prize. Below are the "JStorm" team members:

Gizem Gülşen - Gültürk Karlı - Redi Gokaj - Engin Yağız Hatay
Ress.Asst. Semih Utku


 









Purpose:




The purpose of the “Smart City” is to have an online platform which makes the life of citizens easier. This is a web based project which will be implemented for the IBM Software Academy 2010. It is related to the city management in order to create a web based smart city. Touristic guide, places to see, news, jobs, public transportation and other facilities are the main idea of this project. The “Smart City” is a web portal where all the public and expert functions come together in one place by sharing and solving ideas. In the same time, it will be the face of the city by showing detailed scenery of every aspect which takes place in the real life. The mobile solutions make the reach to the system easier and faster by being connected everywhere.



Scope:




This project's scope is to connect together with other platforms and use data everywhere. Any data source, that can help to extract information about the city, should be tracked and kept connected to the smart city platform. This platform is expected to act as the center of the city where all the information is presented here. Using SOA all the connections are made possible between different platforms and systems. Health care, transportation, education, police departments, government and all the parts of the city are planned to be connected here in order to have an “ALL in ONE” portal to make the life easier. The design is done using open principles in order to make it easier to expand and include everywhere.



News links from online sources (in Turkish):


http://www-05.ibm.com/tr/industries/education/news/yazilim_akademisi_2010.html


http://www.businews.eu/tag/yazilim-akademisi

http://www.turk.internet.com/portal/yazigoster.php?yaziid=27951

http://www.yazilimakademisi.org/2010/

http://forum.shiftdelete.net/sdn-haberleri-makaleleri-yeni/152498-ibm-genc-yazilimcilari-yaristirdi.html

http://www.ortakalan.com.tr/haber.asp?K=&M=&S=&HID=3148

Saturday, May 22, 2010

Sorting JPA Collections

Assume that your database you have a "News" table and a "Comment" table. In your Java entities you have mapped the News and the Comment table as two classes. Different users post comments to your News and you need to display these comments and the web page were the News is displayed. So, the first operation to be done is to sort them according to the post date. You don't need to write a query for it. Just take the comment collection of that specific news and use the @OrderBy annotation in order to sort.

@JoinTable(name="NEWSCOMMENT",joinColumns=@JoinColumn(name="NEWSID"),inverseJoinColumns=@JoinColumn(name="COMMENTID"))

@ManyToMany(fetch=FetchType.EAGER)

@OrderBy("POSTDATE ASC")

private List<Comment> commentCollection;

News news = ... //Here you get your news object

List<Comment> comments = news.getCommentCollection(); //By this operation you accomplish the ordering of the comments shown to the news

In @OrderBy("POSTDATE ASC") the POSTDATE is an attribute of the table of Comments.

Thursday, April 29, 2010

Migrate from JSF 1.1 to JSF 1.2

Sometimes there is a problem faced by upgrading the version of your JSF in a Dynamic Web Project. After you create a JSF 1.1 project, later it maybe impossible to change it to JSF 1.2 without recreating the project. In fact, a message comes in Eclipse or RSA.
"Cannot change version of project facet Java Server Faces to 1.2"
So, we need to manually modify the project properties. Firstly, below i will give the faces-config.xml for JSF 1.2:



xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">



After that we need to go to the .settings folder inside our Eclipse project. Inside this folder we need to open the file: org.eclipse.wst.common.project.facet.core.xml.
" ./settings/org.eclipse.wst.common.project.facet.core.xml "
Find the line: < installed facet="jst.jsf" version="1.1" />
and change it to: < installed facet="jst.jsf" version="1.2" />

That's all. Now you can run your project as a JSF1.2 project.

Friday, April 16, 2010

Windows Mobile 7 Application using ASP.Net WebService

This is a video tutorial which shows a simple example on how to use an asp.net web service using a Windows Mobile 7 application.
HD Quality:Windows Mobile 7 - Web Service

Thursday, April 8, 2010

Proportional image resizing in Java

In order to resize images in Java a simple code is used. In fact, depending on the quality of the photos you want to resize there can be different resize codes and libraries. But a common used is the one I'll show in this post. Together with the resize code I'll also give the code which makes the proportional resize. Proportional resizing is a "must" in order not to loose the shape of the image. Lest's start with the resize code which is shown below:


private static BufferedImage resizeImage(BufferedImage image, int width, int height)
{
BufferedImage resizedImage = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D g = resizedImage.createGraphics();
g.drawImage(image, 0, 0, width, height, null);
g.dispose();
return resizedImage;
}


This is enough in order to resize the image, but before calling this function we need to set the proper width and height according to the proportional resize we will make.


//imageFile is any file taken from the buffer or a disk path. It should be of type java.io.File.

//thumbnailWidth & thumbnailHeight should be defined as values in order to have the new image's sizes.


BufferedImage originalImage = ImageIO.read(imageFile);

int originalWidth = originalImage.getWidth();
int originalHeight = originalImage.getHeight();

float widthRatio = originalWidth/thumbnailWidth;
float heightRatio = originalHeight/thumbnailHeight;

BufferedImage resizeImageJpg = null;

if (widthRatio > heightRatio)
{

float newThumbnailHeight = (float)originalHeight/(float)originalWidth * thumbnailWidth;

resizeImageJpg = resizeImage(originalImage, thumbnailWidth, (int) newThumbnailHeight);
}
else
{

float newThumbnailWidth = (float)originalWidth/(float)originalHeight * thumbnailHeight;

resizeImageJpg = resizeImage(originalImage, (int) newThumbnailWidth, thumbnailHeight);
}

ImageIO.write(resizeImageJpg, "jpg", new File("filename..."));

Wednesday, April 7, 2010

Welcome to my blog!

Welcome to my blog site. Thank you for viewing it, and I hope I will see you again around here:). Have a nice time!