# JetCracker

Life-time learner's blog

## [JSF 2] [Overriding Renderer] How to add custom attributes to component

I’ve been working with JSF for almost a year, and sometimes standard components are not enough for rendering rich  HTML5  pages.

For example, if we need to have a placeholder attribute on a particular HTML5 input element, we just write:

<input type="text" name="login" value="" placeholder="User name"/>


Unfortunately, standard JSF 2 library’s component InputText was designed for HTML4 and doesn’t support attribute ‘placeholder’ (as well as other non-standard attributes, such as ‘autofocus’, ‘autocomplete’). So, the following code won’t work because the ‘placeholder’ attribute will be ignored by standard JSF TextRenderer.

<h:inputText value="#{loginBean.login}" placeholder="User name"/>


What if we really need to have placeholder in our input components? One solution would be using third-party libraries, such as PrimeFaces, or RichFaces. The provide placeholder (they call it ‘Water Mark’) and a lot of other features out of the box.

This solution has its drawbacks. Third-party libraries (like PrimeFaces) are quite difficult to cusomize, for the one thing. Besides, they have got their own issues and may not work as we expect. Also, sometimes in some projects we are not able to use these libraries.

We used PrimeFaces 3.1.1 library in our project Reshaka.Ru, and the library really disappointed me. File Upload component doesn’t work properly, dialogs are incorrectly rendered in most browsers. There are many bugs, and it seems to me that PrimeFaces team is not going to fix them. That’s why in our future projects, I won’t use it.

Let’s get back to the main point. 🙂 In order to add custom attribute, we can override standart JSF component Renderer.

## [Java] [Glassfish 3] Wrong character encoding in multipart servlet request

Hello!

It’s been a long time since I posted here, but I’m currently very busy with my study, work and projects.
Recently we had a problem with processing multipart HTTP requests in Java servlet. We are using Glassfish 3.1.1 as application server. The thing is despite of the fact that HTTP request had UTF-8 encoding, all string data actually were in ISO-8859-1 (a.k.a. ISO-LATIN-1).

I tried several different approaches to set encoding to UTF-8… until I came across the following: http://java.net/jira/browse/GLASSFISH-18516. As I understood, It says that there is a known issue in Glassfish 3.1.2 with incorrect interpretation of character encoding of multipart HTTP request parameters. Instead of UTF-8 it applies ISO-8859-1 ignoring settings in configuration files (web.xml, glassfish-web.xml) and in HTTP request. Turns out, this issue also affects Glassfish 3.1.1, which is used in our project.

## [MPI] Calculating integral in parallel

Problem: write a programme to calculate the integral with MPI:



Actually, the programme must be able to calculate any integral. But before writing a parallel programme, we should write a serial one to make sure it works and the algorithm is correct.

There are plenty of algorithms for calculating integrals. One of the most advanced (efficient), among non-parallel, is the method of local stack. Read more of this post

## [MPI] Solving the advection equation in parallel

In chemistry, engineering and earth sciences, advection is a transport mechanism of a substance or conserved property by a fluid due to the fluid’s bulk motion.

Mathematics describes the process of advection with the advection equation:

$\frac{\partial\psi}{\partial t}+\nabla\cdot\left(\psi{\bold u}\right)=0$

In my course on Parallel programming, I had to implement a solution to a particular advection equation, with  the initial and boundary conditions defined. Read more of this post

## The Magic of 42

Hi there!

It’s been quite a long time since I posted here (more than one month). Honestly, I was really busy and there were some problems with the Internet in my dorm.

The month was full of events!

Firstly, I got a position of software engineer (intern) in NetCracker in department Solution Delivery. Secondly, we almost finished with the first release of Reshaka.Ru which is currently being tested. In addition, we moved to another room at the dormitory. I changed my roommates – now they all programmers and my friends too. Some time I will tell you more about all these events. But now let’s get down to business!

## PHP: Syntax highlighting with GeSHi

One day I needed to add some source code examples to the web-site. But there was no features for highlighting syntax. I decided to create my own tool for highlighting source code. Here I will show you how to do it using PHP with GeSHi. Read more of this post

## MPI: Calculating sum 1/n! in parallel

Hello.
I’ve spend several hours to understand how to programme in MPI and how to calculate the sum of 1/n! in parallel (it’s my task from university). (By the way, why do I have study this shit? I don’t think I will be working in the field of parallel/distributed computing.)

But finally I wrote a decent programme, which showed not bad results. And I am very excited to share with you! Read more of this post

## [My old trash] Resizing images in Delphi.

Hello!

A hundred years ago I was working on a PHP web site. I needed to place there a lot of images but all of them have different resolutions and sizes. For example, pictures from photo camera were very heavy (~ 5 Mb) and maximum file size that was allowed on the hosting was 3 Mb. So, before placing those photos to my hosting I needed to scale them down so that they met the limits.

You might have suggested using a PhotoShop or anything like that to get this job done. But I didn’t have the money to use this software (actually, I still don’t have). There were also a lot of free photo editors, which provided the function to scale images in bulk, but they were too overloaded and not so handy. Besides, I was very curious about how to make such a tool that would solve my problem.

Here I’m going to show you how to create a tool in Delphi that will automatically scale all images (only jpeg) in the directory that you specify. Why Delphi? Simply because it was the only programming language I was good enough at. Read more of this post

Learn programming to solve real problems!

Don’t learn to program.  Learn to program the sexy way.

View original post

## [For fun] China++ xD

Dynamic memory management in China++
It is pretty awesome!
More at: http://kevinxi.wordpress.com/