Tuesday, 12 July 2011

The following piece of PHP code shows how to send a POST request to a website passing some requests parameters. It may be useful if you needed to process the page that is normally requested using POST method e.g. form submission result page.

The request is similar to what your browser would send if you populated a form using POST method on a webpage.

Monday, 11 July 2011

So I started learning Spring MVC by example using the Spring MVC Showcase. I downloaded STS and cloned the GIT repo to get the local copy of the code. I loaded the Maven project and built it successfully.

When I tried to start the VMware vFabric tc Server Developer Edition 2.5 I got the following exception:

Publishing the configuration...Error copying file to C:/Program Files/springsource/vfabric-tc-server-developer-2.5.0.RELEASE/spring-insight-instance/backup\catalina.policy: C:\Program Files\springsource\vfabric-tc-server-developer-2.5.0.RELEASE\spring-insight-instance\conf\catalina.policy (The system cannot find the path specified)C:\Program Files\springsource\vfabric-tc-server-developer-2.5.0.RELEASE\spring-insight-instance\conf\catalina.policy (The system cannot find the path specified)Error copying file to C:/Program Files/springsource/vfabric-tc-server-developer-2.5.0.RELEASE/spring-insight-instance/backup\catalina.properties: C:\Program Files\springsource\vfabric-tc-server-developer-2.5.0.RELEASE\spring-insight-instance\conf\catalina.properties (The system cannot find the path specified)C:\Program Files\springsource\vfabric-tc-server-developer-2.5.0.RELEASE\spring-insight-instance\conf\catalina.properties (The system cannot find the path specified)Error copying file to C:/Program Files/springsource/vfabric-tc-server-developer-2.5.0.RELEASE/spring-insight-instance/backup\context.xml: C:\Program Files\springsource\vfabric-tc-server-developer-2.5.0.RELEASE\spring-insight-instance\conf\context.xml (The system cannot find the path specified)C:\Program Files\springsource\vfabric-tc-server-developer-2.5.0.RELEASE\spring-insight-instance\conf\context.xml (The system cannot find the path specified)Error copying file to C:/Program Files/springsource/vfabric-tc-server-developer-2.5.0.RELEASE/spring-insight-instance/backup\jmxremote.access: C:\Program Files\springsource\vfabric-tc-server-developer-2.5.0.RELEASE\spring-insight-instance\conf\jmxremote.access (The system cannot find the path specified)

(...)

Solution

I'm running 64-bit version of STS on Windows 7. By default programs don't use the Admin account. It was enough to run the STS as Admin (Right click on shortcut -> "Run as Administrator").That's it! Simple, isn't it? :)

As you can see I'm using both built-int and custom rules (callback_type_check).

This works fine with my 'Add Item' form.

However, I wanted to reuse the validation logic at other place, where the user can provide multiple items to add at once in a file where each row represents a single item. So I read line by line from the file and want to validate each line. To do that I reset values in $_POST array and perform validation:

The function simply remembers the rules that were loaded from config file when validation object was created, creates a new validation object and resets the rules. I call it after each row is validated.