Friday, 6 April 2012

Apache Click
Apache Click is a modern and open source Java/J2EE and html page based component oriented web application framework. The framework is built on top of the Java Servlet API. For details on apache click framework and APIs visit on Apache Click .
RIA with Apache Click
We are here to develop Rich Internet Applications by extending the Apache Click capabilities and integration of Java/J2EE, JavaScript, jQuery, CSS, AJAX and other UI to for developing User Interfaces.
ImageRadio Control - Radio Group with Image
Apache Click ImageRadio is an extended form of Radio class. The new class ImageRadio provides a new control for Apache Click by extending the The control will be similar implementation as Radio with the instead of label you have to provide the image source and the source will be rendered as an image on user interface. The implementation logic has been shared in the below discussions:
package com.components; import; import org.apache.commons.lang.StringUtils; import; import; public class ImageRadio extends Radio{ private static final long serialVersionUID = 1L; // ----------------------------------------------------- Instance Variables protected String src; protected int x = -1; protected int y = -1; // ----------------------------------------------------- Constructors public ImageRadio(String name) { super(name); } public ImageRadio(String name, String src) { super(name); setSrc(src); } public ImageRadio() { super(); } // ----------------------------------------------------- Methods public String getSrc() { return src; } public void setSrc(String src) { this.src = src; } public int getX() { return x; } public int getY() { return y; } @Override public void bindRequestValue() { Context context = getContext(); String xValue = context.getRequestParameter(getName() + ".x"); if (xValue != null) { this.checked = true; try { this.x = Integer.parseInt(xValue); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } String yValue = context.getRequestParameter(getName() + ".y"); try { this.y = Integer.parseInt(yValue); } catch (NumberFormatException nfe) { nfe.printStackTrace(); } } } @Override public boolean onProcess() { if (isDisabled()) { Context context = getContext(); if (context.hasRequestParameter(getName() + ".x")) { setDisabled(false); } else { return true; } } bindRequestValue(); if (isChecked()) { dispatchActionEvent(); } return true; } @Override public void render(HtmlStringBuffer buffer) { // ----------------------------------------------------- Radio Button buffer.elementStart(getTag()); buffer.appendAttribute("type", "radio"); buffer.appendAttribute("name", getName()); buffer.appendAttribute("id", getId()); buffer.appendAttribute("title", getTitle()); if (getTabIndex() > 0) { buffer.appendAttribute("tabindex", getTabIndex()); } appendAttributes(buffer); if (isDisabled()) { buffer.appendAttributeDisabled(); } buffer.elementEnd(); // ----------------------------------------------------- Image Button buffer.elementStart(getTag()); buffer.appendAttribute("type", "image"); buffer.appendAttribute("id","i"+ getId()); buffer.appendAttributeDisabled(); if (getTabIndex() > 0) { buffer.appendAttribute("tabindex", getTabIndex()); } String src = getSrc(); if (StringUtils.isNotBlank(src)) { if (src.charAt(0) == '/') { src = getContext().getRequest().getContextPath() + src; } buffer.appendAttribute("src", src); } appendAttributes(buffer); if (isDisabled()) { buffer.appendAttributeDisabled(); } buffer.elementEnd(); } }
The above class is extending the class and during the render(HtmlStringBuffer buffer) method there are two radio controls has been added without label and the second radio attribute has been changes to image. Below we are using this custom class into the new component.
package; import; import; import com.components.ImageRadio; public class HomePage extends BorderPage { private Form form = new Form("form"); private RadioGroup radioGroup = new RadioGroup("Select Card Type:"); public HomePage() { addControl(form); radioGroup.add(new ImageRadio("VISA", "/images/VisaCardLogo.gif")); radioGroup.add(new ImageRadio("MC", "/images/MCLogo.gif")); radioGroup.add(new ImageRadio("DIS", "/images/DiscoverLogo.gif")); radioGroup.setValue("VISA"); radioGroup.setVerticalLayout(true); form.add(radioGroup); } }
After the Java component code now we need to use it on the home.htm page. Below is the code on htm to render the form on user interface:
<html> <head><title>Home Page</title> </head> <body> $form </body> </html>
HTML User Interface
Finally you can see the output of the above code. Here are the attached image below:

  • Apache Click:
  • Apache Click with ClickClick:
  • Apache Click jQuery Integration:

Please share your comments or suggestion. You can visit our website and leave you comment over there. To visit our website visit on:
VaaCom: A Blog on Technology

1 comment:

  1. Cominform is your partner for efficient, custom-tailored business software-solutions. The Cominform team develops on innovative platforms and in line with cutting-edge standards. Here are options for Web Desktop, Rich Internet Application, SAML Cordova Plugin , SQL Cordova Plugin , SAML Phonegap Plugin and SQL Phonegap Plugin.


Microsoft Dynamics CRM - Java Web Client Implementation

CRM - Microsoft Dynamics A Cloud based Customer Relationship Management(CRM) software package developed by Microsoft. Microsoft Dynamics ...