PingMyCompany named as one of the most underrated sites of 2008 by Mashable.com

December 23rd, 2008

Mashable.com recently added Zigron’ s PingMyCompany.com to its list of most underrated websites of 2008.

You can read the the story and the list here on Mashable.com

Writing Custom jsf Components

December 17th, 2008

What is JSF

JSF is a server side UI Component based framework for java based web applications. It adapts Component centric approach to develop java web user interfaces, hence simplifying the development. JSF follows the MVC design pattern and creates the manageable separation between the view, application data and logic.

Since the true power of JSF lies in the UI component model and JSF allows us to use prebuilt components or we can build our own, depending on our requirements.

Let’s start with creating a custom component, which would also help us understand who the compoenent model works in jsf.

Writing a Custom JSF Component

Lets start with a simple component which takes the email address as an input.

A component is made up of three main classes

o UIComponent subclass.

o Renderer

o UIComponentTag subclass

First of all we start building a UIComponent subclass, since our component is and input component we would extend this class by javax.faces.component.UIInput.

Here is how our class looks like

public class EmailComponent extends UIInput {

public static final String

EMAIL_FAMILY = “EMAILFAMILY”;

public EmailComponent() {

super();

addValidator(new EmailValidator());

}

public String getFamily() {

return EMAIL_FAMILY;

}

}

The only thing that needs explanation in this class is getFamily() method, this method is used to get the component family which is used to look up the renderer for this component when HTML is to be generated for this component.

addValidator(); is used to make sure that the user enters a valid email address. The EmailValidator class looks like this,

public class EmailValidator implements Validator {

public void validate(FacesContext context,

UIComponent component,

Object value)

throws ValidatorException {

if (null != value) {

if (!(value instanceof String)) {

throw new IllegalArgumentException(

“The value must be a String”);

}

String email = (String) value;

Pattern emailPattern = Pattern

.compile(“[a-z0-9!#$%&'*+/=?^_`{|}~-]+” +

“(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)” +

“*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)” +

“+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?”);

Matcher emailMatcher = emailPattern

.matcher(email);

if (!emailMatcher.matches()) {

throw new ValidatorException(

new FacesMessage(

“Please enter a valid Email Address”));

}

}

}

}

The important thing to know in this validator is if the string does not match the Matcher, then a new FacesMessage is created and a ValidatorException is thrown. JSF will interpret the ValidationException and get the message from it.

Another important thing is, this validator is not part of building a custom component.

We have created a UIComponent Subclass, now next step is to create a renderer, renderer is responsible for turning the component into HTML and taking posted HTML and turning it into values suitable for the component, these processes are also referred as encoding and decoding.

Below is the code for the renderer, I think the comments on the code are explaining it well.

public class EmailRenderer extends Renderer {

//THIS METHOD IS RESPONSIBLE FOR TAKING ANY PARAMETERS THAT WERE PASSED

//IN FROM A FORM POST AND SETTING THE VALUE ON THE COMPONENT

public void decode(FacesContext context,

UIComponent component) {

assertValidInput(context, component);

if (component instanceof UIInput) {

UIInput input = (UIInput) component;

String clientId = input

.getClientId(context);

Map requestMap = context

.getExternalContext()

.getRequestParameterMap();

String newValue = (String) requestMap

.get(clientId);

if (null != newValue) {

input.setSubmittedValue(newValue);

}

}

}

//THIS METHOD IS RESPONSIBLE FOR BUILDING THE HTML TO REPRESENT //THE COMPONENT IN THE BROWSER

//BASICALLY THERE ARE THREE ENCODING METHODS ENCODEBEGIN(), //ENCODECHILDREN() AND ENCODEEND().

//SINCE OUR COMPONENT DOESN’T HAVE ANY CHILDREN WE DON’T NEED //PREVIOUS TWO METHODS.

public void encodeEnd(FacesContext ctx,

UIComponent component) throws IOException {

assertValidInput(ctx, component);

ResponseWriter writer = ctx

.getResponseWriter();

writer.startElement(“input”, component);

writer.writeAttribute(“type”, “text”, “text”);

String id = (String) component

.getClientId(ctx);

writer.writeAttribute(“id”, id, “id”);

writer.writeAttribute(“name”, id, “id”);

String size = (String) component

.getAttributes().get(“size”);

if (null != size) {

writer.writeAttribute(“size”, size, “size”);

}

Object currentValue = getValue(component);

writer.writeAttribute(“value”,

formatValue(currentValue), “value”);

writer.endElement(“input”);

}

protected Object getValue(UIComponent component) {

Object value = null;

if (component instanceof UIInput) {

value = ((UIInput) component)

.getSubmittedValue();

}

// if its not a UIInput or the submitted value

// was null then get the value (it should

// always be a UIInput)

if (null == value

&& component instanceof ValueHolder) {

value = ((ValueHolder) component)

.getValue();

}

return value;

}

private String formatValue(Object currentValue) {

//THIS METHOD SHOULD PERFORM THE CONVERSION NEEDED.IN OUR //CASE WE JUST NEED A STRING.

return currentValue.toString();

}

private void assertValidInput(

FacesContext context, UIComponent component) {

if (context == null) {

throw new NullPointerException(

“context should not be null”);

} else if (component == null) {

throw new NullPointerException(

“component should not be null”);

}

}

}

We are done with the first two classes, now the last class is the subclass of UIComponentTag.

Below is the code for this class

public class EmailInputTag extends UIComponentTag {

private String size;

private String value;

private static final String EMAIL_COMP_TYPE =

“EMAIL_INPUT”;

private static final String EMAIL_RENDER_TYPE =

“EMAIL_RENDERER”;

@Override

public String getComponentType() {

return EMAIL_COMP_TYPE;

}

@Override

public String getRendererType() {

return EMAIL_RENDER_TYPE;

}

protected void setProperties(

UIComponent component) {

FacesContext context = FacesContext

.getCurrentInstance();

super.setProperties(component);

if (null != size) {

component.getAttributes().put(“size”, size);

}

if (null != value) {

if (isValueReference(value)) {

ValueExpression ve= context.getApplication().getExpressionFactory().createValueExpression
(context.getELContext(),
value,String.class);

component.setValueExpression(“value”, ve);

} else {

((UIInput) component).setValue(value);

}

}

}

public String getSize() {

return size;

}

public void setSize(String size) {

this.size = size;

}

public String getValue() {

return value;

}

public void setValue(String value) {

this.value = value;

}

}

Two important methods here, getComponentType() and getRendererType().

getComponentType() returns the type of the component that should be created by the tag,this type is sent to the factory for the resolution of the class name and then the instance is created,

getRendererType() returns the type of the renderer and the instance is created the same way as mentioned above. These two methods are responsible for making the connection between the renderer and the component.

Now we are done with all the coding now we have to do some configuration, in faces-config.xml file we have to register our custom component with its renderer, like this.

<component>

<component-type>

EMAIL_INPUT

</component-type>

<component-class>

com.zigron.component.EmailComponent

</component-class>

</component>

Note the <component-type> tag, this is the component type we defined in com.zigron.tag.EmailInputTag class.

And the renderer like this,

<render-kit>

<renderer>

<description>

Renderer for the Email Input component.

</description>

<component-family>EMAILFAMILY</component-family>

<renderer-type>

EMAIL_RENDERER

</renderer-type>

<renderer-class>

com.zigron.renderer.EmailRenderer

</renderer-class>

</renderer>

</render-kit>

One more missing piece is a the tld that would define the tag for JSP, I would paste a part of the email.tld here.

<tlib-version>0.01</tlib-version>

<jsp-version>1.2</jsp-version>

<short-name>Email Input Example Component Tag Library</short-name>

<uri>http://www.zigron.com/jsf/component/email</uri>

<description>

This tag library has the tags for the custom jsf component, which is just a simplest example, hence most of the attributes are ignored in this tld

</description>

<tag>

<name>emailInput</name>

<tag-class>com.zigron.tag.EmailInputTag</tag-class>

<body-content>empty</body-content>

<description>

This is the tag for the Email input component.

</description>

<attribute>….</attribute>

…….

</tag>

Now we have to use this tag on JSP, for that we need to import our taglib, with the URI we mentioned in our email.tld, i.e http://www.zigron.com/jsf/component/email

Here is the example JSP code,

<%@taglib prefix=“h”

uri=“http://java.sun.com/jsf/html”%>

<%@taglib prefix=“f”

uri=“http://java.sun.com/jsf/core”%>

<%@taglib prefix=“email”

uri=“http://www.zigron.com/jsf/component/email”%>

<html>

<head>

<title>Custom Email Component</title>

</head>

<body>

<f:view>

<p>

<h:messages id=“messageList” showSummary=“true”/>

</p>

<h:form>

<h:outputLabel for=“test”>

<h:outputText id=“testLabel” value=“Email Address:”/>

</h:outputLabel>

<email:emailInput id=“test” size=“19″

value=#{test.emailAddress}/>

<br/>

<h:commandButton value=“Save”

action=#{test.showEmailAddress}/>

</h:form>

</f:view>

</body>

</html>

In this jsp test is the managed bean registered in faces-config.xml.

Now by combining all the above pieces together our component is now ready to serve.

Just for an over view , here is the step by step explanation

1. The URI prefix is used to find the uri in the tld, (email is the prefix in our example)

2. From the TLD the tag name and class pointing to that tag, under the URI is located, in our case tag name is <name>emailInput</name> in tld and the tag class is <tag-class>com.zigron.tag.EmailInputTag</tag-class>.

3. The getComponentType() method of located tag class(com.zigron.tag.EmailInputTag) is called.

4. The returned value is located in the faces-config.xml file to find out the component class against that component type.( as I mentioned earlier as a Note.)

5. Finally the component class is located from the faces-config.xml.

Download Complete Document Here

Mobile Development & Marketing: Current Issues & Challenges

December 11th, 2008

The world is evolving and the trends changing, making the world faster than ever before and technology more stable. With the invention of first pager in 1959 by Motorola, the world started getting mobile. The launch of first commercial mobile phone by NTT in Japan was the next step to stabilize this mobility.

The innovation in this mobility with SMS happened to be originated in Europe in 1985. SMS was a boom in the later part of 1900s and early 2000s, and still it’s the top cellular activity. There’re above 4 billion mobile phone subscribers, with 74% of them using SMS of which 94% of SMSs are read. Just in UK 1.4 billion text messages now being sent every week.

This is just an overview of mobile phones and SMS,  innovations like iPhone, Blackberry, Android and mobile-internet integration are constantly opening the new horizons of excellence for mobile marketing. Web marketing is one of the most cost effective marketing methods with maximum outreach. Since there’re more mobile phone subscribers than that of internet users, so mobile opens broad ways for marketing from small and medium to large businesses.

Mobile-web integrated marketed is still in the process of development, reason being the lack of awareness among most of mobile phone subscribers, i.e. there’re about 10 million users worldwide using GPRS services that makes only about 0.25% of the total subscribers. But, this low percentage doesn’t mean that mobile marketing is not growing. There’re various methods within mobile marketing including SMS Marketing, Ingame Mobile Marketing, Location Based Services etc.

Ingame Mobile Marketing is the fastly growing area and the future of mobile marketing. The reason is that more than 90% of mobile phone subscribers play mobile games. From simple interactive real-time 3D games to massive multi-player and social networking games, mobile gaming is everywhere. This trend is accelerating the growth of mobile 2.0 on one hand and hence the mobile development on other.

Mobile development being the next big thing is now the focus of small, medium and large business, and hence it’s becoming a competitive industry. The competition is becoming tougher as the industry leaders Nokia and Google have moved to opensource, and this situation is critical for ISVs.

ZDNet also reports that, it’ll not be the great UI as only challenge instead, things that matter more are ideas and methodologies. Though ISV’s are more under pressure, but companies will have equal pressure and will have to face almost same challenges. It’ll be the race of collective innovation [what I can term it as] or Product Innovation [combination of innovation in methodologies, design, productivity etc] so, innovation in over all performance will win!

Live Broadcast Of Usability Event From NUST Islamabad

December 1st, 2008

This post will be serving as a live broadcast for our Usability Event which is going to be held tomorrow Tuesday, December 2, 2008. So, please, bookmark it for the live updates. It’ll be great, but a lot depends on the wifi availability there.

A detailed overview of the event will be a part of our post event activity, and live updates will help us gather more and more public opinions. Bloggers/web analysts/user experience gurus/usability geeks are welcomed to blog about it on their blogs and or write us their views.

Feedback will be highly appreciated, so stay tuned!


Follow us at Twitter: http://www.twitter.com/zigron

Upcoming event : Usability,why Should You Care?

November 27th, 2008

Whether it’s consumer electronics, desktop software or a web application, usability comes first, i.e. the ease with which the user will use that product. The evolving technologies, geographical differences etc though cause a little variation, but standards are almost same everywhere. Usability itself is a standard, and any new, or enhanced product must follow the usability guidelines.

Being a product developer, why should you care about Usability is a single question with hundreds of answers, some known and many hidden. Discussion is the only way to explore all those, and so Zigron Inc. and CDF Software arranged a seminar on Usability in collaboration with NUST Islamabad. Seminar will be held on Tuesday, December 2, 2008 from 5 pm to 8 pm (PST) at NUST Sector H-12, Islamabad Campus.

The seminar will be a sort of discussion on current Usability practices round the world, the difference and similarities, the best and the successful, and the emerging trends. Another interesting part of the seminar will include a documentary on design Helvetica. Panelists of the seminar are people from different software houses of Islamabad and NUST, i.e. Babar Khan (ikonami), Faizan Buzdar (Scrybe), Haris Khan (Zigron), Osama Hashmi (CDF Software), Murad Akhter (Tintash) and Dr. Khalid Latif (NUST).

The purpose of seminar is to discuss the Usability standards with specific reference to modern technologies, to make better use of it within our domains and to create awareness among future entrepreneurs.

To register, please RSVP here or you can also register on Facebook.

Clarity by skewing

November 18th, 2008

Recently I got hold of this website which has applied cartogram on the Presidential Election results. It’s a great way to show relevance, visually.

Some of the images are as below.

2008 presidential election results on a population cartogram:

Electoral college by scaling the sizes of states to be proportional to their number of electoral votes:

Based on County-level election returns:

Save your Eggs…

November 17th, 2008

Few days back we had arranged a group competition to save the eggs when they are throw from the roof top in a box. Six different teams were made and each team was given around 1.45 hours and a very small budget to make these boxes. Goal was to safe eggs by adopting creative design concepts.

I am proud to announce that all eggs were saved which shows Zigron team is quite talented . The competition resulted in a tie as all designs were equally creative thus everyone was declared as winner.

Below is the slide show from the event.

Zigron Launches DareMyCompany.com

November 14th, 2008

After the successful launch of PingMyCompany, Zigron decided to develop a more interactive site where employees of different companies can have real fun. It’s DareMyCompany, whereby one company can dare others to compete in anything. For instance, lately a team of MOHAA players from Zigron had a match with MediaLinkers.

It’s not only about daring companies locally, instead you can dare an overseas company, for instance for design and development contests. So be as innovative as you can to dare companies in the areas where no one has ever dared them.

Each company when registered will have a Dare Profile with all their stats. There’s a ladder also for company’s position, and it gets updated as any two companies have a contest, and post their result.

Soon we will publish the exact rules for using the ladder and how positions are calculated. Till then please enjoy the site and start challenging other firms.

The Reasons Of Absentees: A Letter Of Explanation From WhereverTV Team

November 10th, 2008

Absentee, absentee and absentee… from Zigron’s grand trip or any outdoor activity, even completely out from blogging, it was WhereverTV team habitual of absence. This was the limit and the notice was taken by blog administrator and Haris so here is the inside story of Dream theater.

What kept us away for so many things, is the question that  every mind might have noticed on every event.  Obviously, everybody knew that we’re not there as we’ve been working but so what!!! Others were also working,  and might be working more hard, but still they spared time to do the fun part as well, that we couldn’t. Deadlines, late sittings and immediate requirements is a common thing for IT, but innovations have always been out of the way and so was the case with WhereverTV. What was behind the scene that made us so busy, goes here:

WhereverTV website is a complete portal with all the features implemented so far, standardized and implemented. From secure Paypal & credit card shopping to User Role management in Salesforce, so many integrations like YouTube, TimeZone, java mail all are working perfectly. And above all, the system is logging the events comprehensively, i.e. any activity(I really mean any activity any user performs), scheduling efficiently the events at background and exporting capabilities like to excel and pdf. The presence of webservices definitely shows the strength enough to expose the system to be accessed by wherevertv devices.

Now coming to WhereverTV device, believe me its like Pandora box and it was dared by Mark Cavicchia and Kashif Mueen that they did not only opened this box but also decided to fix, enhance and mould it to their own requirements. From UI development to protocols implementation, it was like waking a sleeping giant. Codecs implementation and then webservices integration are the tasks which seem small but ask WET embedded team how much effort they have put it. (You want to know what this device looks like, click here )

The purpose of exposing these features is not to impress you people by any means, instead to let people know about the reason for WhereverTV team to be absent from trips, outdoors and even from blogging. Go to this link, and imagine that from February to August, we were busy in making this dream happen. And when the release was about to go live, for more than two month, our development rooms were always occupied by developers. So on behalf of WET Team, Please excuse us for all the absentees, unavailibilities and non-participating.

WhereverTV has moved from Beta to Gamma but the game is still on……… Yet so many features, enhancements and upgradings are in the way. Wait and see , how far we can take this ride for you…… But one thing is for sure that we’ll be with you on Zigron blog from now onwards.

Till next blog, adios

Thanks to Zahid Zaman and Adeel Arshad for supporting me to compose this message!

CodeIgniter, does one really need it?

October 21st, 2008

Few weeks ago, I started work to make my own PHP based MVC framework, all I wanted was a simpler and lighter MVC framework. I just intended to write a controller which can communicate with the model and views. In my googling, I found out CodeIgniter reviews, which were something like “a light weight PHP framework”. I started to look into CodeIgniter. I found it exactly as I was looking for. There was no need to re-invent the wheel, so I spent next few nights with the codeIgniter. I had already worked with Symfony and little bit with cakePHP, so the question arises why to look for any other PHP MVC framework? even when these both are the top frameworks in most comparisons. The answer is yes, Actually Symfony is really great framework for medium to large web applications. It’s good if project is very much scalable and got proper time-line. But If you got a project in which you really need to apply RAD ‘Rapid application development’, in which you do not have much time for deployments, framework installations, PEAR installations, framework plugins supports, You don’t want to do Propel build models and re-generate ORM classes or you simply can’t spend time on writing YAML schema files. In addition to these you also do not want your code to get messy, you really don’t want the business-logic and presentation together in single files OR you just want nothing fancy but a simple MVC framework where you just code and execute. So that’s where CodeIgniter fits in.

Not only CI is light weight, but to assist Programmers write faster code, it comes up with already made classes like: File uploading Class, FTP class, Email class (which supports HTML email, attachments), Pagination, Data encryption, calendar classes and few more. These all classes are by default part of CI. To use those classes, programmers need to include them in their actions. CI uses Active Record for database access, which is fairly simple. CI does all error logging just like the giant frameworks. CI also uses Search Engine Friendly URLs by default.

Now with open source PHP frameworks like CI, symfony and cakePHP, coding is done OOPs way, code remains managed and re-usable. Also Web-applications are built faster and scalable. The good thing about PHP related technologies is that they are open-source, which also means greater and world wide support through a healthy and ever growing community.