Hybirs E-Commerce , Cebu IT and other free verse

According the dashboard statistics, my last post is already six months ago. I guess I have been so busy or did not bother to add any content to this site. Right now I am working on Java E-Commerce , Hybris in particular. E-Commerce is one internet innovation that will become a huge market in the future. According to surveys, Hybris leads in huge E-Commerce enterprise, while Magento ( PHP ) leads in medium sized enterprise.

As for the IT industry in Cebu, Philippines, it still on a rapid expansion. With several BPO companies and new buildings constructed until this day. A lot of foreign investors are moving in, such as Japan, USA, Europe as the main investors.

I think that’s all for now, just a short post to keep this site alive ūüôā
Viewership has increased or doubled from 2015 to 2016, not bad for a small site with very few contents. Most views are coming from the UI / UX posts.

ELException in Spring Webflow

If an ELException has occurred in Spring Webflow, check the error message and the method where the error has occurred. In a case that I have encountered, the flowScope variable in the flow.xml file did not match the defined variable in the Service interface file. Below is an example of a correct flow.xml and service.java variable mapping. If in case the return of methodA is changed to Integer instead of String, this will throw an ELExeption on runtime. However, the code will compile without any errors.

Service Interface file (Interface.java)


public interface InterfaceService {

//....

String methodA(){

//....

}

String methodB(String parameterB){

//....

}

Service Implementation file (Implementation.java)


public class Implementation implements InterfaceService {

//implements methodA and methodB

Spring webflow (flow.xml) file


<evaluate expression="InterfaceService.methodA()" result="flowScope.stringValue" />
<evaluate expression="InterfaceService.methodB(stringValue)"/>

EL is an abreviation of Expresion Language in Spring Webflow. The flowScope variable is one of several variables provided by Spring Webflow. Other Spring Webflow variables such as requestScope, flashScope and viewScope can also cause an ELException when a mismatch of data types occur.

Spring documentation on EL ( Expression Language ) and flowScope found in 4.4.1
http://docs.spring.io/autorepo/docs/webflow/2.3.x/reference/html/el.html

Resolving library and dependency errors in ant+ivy

In the case when there are library and dependency errors in java files or in any xml configuration, here is how to the fix issues when using ant+ivy.

First is to look for the ivy.xml files under the libraries folder. Then, highlight all ivy.xml files , right click and select “resolve”. Ivy will then retrieve and resolve the libraries and dependencies by using an eclipse process, which will take several minutes. After the process has ended, check if the errors still exist. In some cases, this basic troubleshooting is the simple solution.

Apache Ant is a Java build script, which is similar / or a competitor to Maven. The Ant build scripts do not have the library dependency download ( from the internet ) function that Maven has, but with Ivy, Ant can now have the library dependency dowload function.

See the sample screenshot of the ivy.xml files

ivy_resolve

 

 

Spring MVC and Spring Webflow basic and simple explanation

Spring MVC basic and simple explanation

1. As a pre-requisite, org.springframework libraires are to be downloaded and added in the project.

2. All mappings are declared in the Controller Class, not in any xml files.

3. @RequestMapping annotation maps the specific URI as accessed by the the browser.

Ex. Map the URI “/welcome” and when the complete URI http://localhost:8080/spring2/welcome
is accessed by the browser, the Controller Class with “welcome” @RequestMapping is accessed.

4. A specific method will return the ModelAndView Class, where the jsp file name is
the String constructor initialization of the ModelAndView class.

Ex. ModelAndView model = new ModelAndView(“HelloWorldPage”);
where HelloWorldPage is the name of the jsp file

5. All other general configurations are set in spring-mvc-config.xml and web.xml files.

See a more comprehensive tutorial here:

http://www.mkyong.com/spring-mvc/spring-mvc-hello-world-annotation-example/

 

Spring Web MVC and Spring Webflow combined.

Spring Web MVC is the url->to-> controller mapping, while Spring Webflow is the transition controller of a page to another page using a flow configuration.

If both frameworks are combined, the¬†Spring Web MVC will return the initial page, then in this initial page, an option to transfer to another page is processed by the Spring Webflow¬†using xml configuration, then the Spring libraries takes care of the rest….

here’s a neat post where Spring Web MVC and Spring Webflow is combined, for comparison.

https://tamasrathonyi.wordpress.com/2010/09/22/spring-web-mvc-with-spring-webflow/

Struts + Spring + Hibernate Integration

Posted on 2014/07/20, Updated on 2015/08/30

Update: For new software development or building a new website from ground-up, there is better design alternative instead of using the Struts framework. Using JSTL is a better alternative, and here is a post in Webpage development using JSTL, Javascript, and JQuery. For older webpage systems, created before 2014, the Java and Struts combination is popular, and therefore a lot of legacy systems runs using these technologies.

Let’s Remember these important files that are needed in configuration of a Java Web application.
( Which includes Spring, Hibernate, and Struts )

web.xml – Servlet class to URL mapping
applicationContext.xml – Spring mapping of Bean/Object injection
struts.xml – maps the defined action to the servlet ( action class is needed in struts ) to the result jsp
hibernate.cfg.xml– database connection such as JDBC name , user/password to access the database name is defined here
<classname>.hbm.xml – the database table hibernate mapping file

index.jsp – the initial action URL, the startpage

Steps:

1.) Define org.springframework.web.context.ContextLoaderListener as the listener and org.apache.struts2.dispatcher.FilterDispatcher as the filter in web.xml

2.) Basically Spring is used here to create the predefined values, as these can be done by using the bean property injection in applicationContext.xml

Here’s a detailed explanation at this site: http://www.tutorialspoint.com/struts_2/struts_spring.htm

Website Login Security : Comparison of Java and PHP

Login and authentication is the basic and important function in almost all websites. I will just give a summary of my research and how login and authentication is done in JAVA and PHP.

JAVA

By using Spring Securities and Spring MVC jars ( by using Maven or downloading the jar files from the internet ), Website login can be easily created by following tutorial instructions. The basic tutorial with authentication can be created in just one day ( according to my experience ). SQL authentication is not yet included from the basic, but can be easily added. Knowledge of Spring MVC and Servlet Filters are also needed to understand the concept.

Spring Security tutorials by Mkyong
http://www.mkyong.com/tutorials/spring-security-tutorials/

The basic Spring Security example
http://www.mkyong.com/spring-security/spring-security-hello-world-example/

PHP

I also researched on how to this in PHP, and saw results with core PHP and another using Laravel. PHP is known to have very unstable and messy code ( which is why maintainability is an issue ). But with Laravel Framework, PHP code is improved.

PHP hardcode using MYSQL database for secure login
http://www.wikihow.com/Create-a-Secure-Login-Script-in-PHP-and-MySQL

PHP authentication using Laravel
http://laravel.com/docs/5.0/authentication

Laravel features discussed including login and authentication
http://code.tutsplus.com/tutorials/why-laravel-is-taking-the-php-community-by-storm–pre-

PHP and JAVA codes are very different in syntax and implementation, and both languages has its advantage and disadvantage.

Webpage development in Java using Spring MVC, JSTL, Javascript and JQuery

How this website is structured in development:

1.) VIEW format – This is the front page view as shown in the browser. components: HTML and CSS for page layout, Spring MVC tags and JSTL for JSP for Java integration to Controller side.

2.) VIEW logic – Javascript and Jquery is used to create button/checkbox logic and is integrated to the HTML

3.) CONTROLLER – Built using Java classes using J2EE/HTTP libraries with Servlet Request and Response parameters. Spring annotations are also included to bind the Controller and the Models

4.) MODEL – Java classes that are POJOs ( Plain-Old-Java-Objects ) which has fields, setters and getters. Models are data storages on the transaction level. These are integrated to the JSP page and can also be used to be integrated to the Database frameworks such as Hibernate and Spring with Hibernate.

Before JSTL, the Java, Spring, Hibernate and Struts design was popular. Struts was used to bind the UI components to the Java and Spring server side code. Here is my post on Struts, Spring, and Hibernate configuration.