IgorShare Thoughts and Ideas

Consulting and Training

Archive for the ‘GWT’ Category

NWT – .Net Web Toolkit

Posted by Igor Moochnick on 10/26/2011

Now, after waiting for quite some time, we finally can implement the real solution for .Net <-> javascript conversion and bridge the impedance gap in the projects that heavily rely on the powerful rich web UI.

Currently we have solutions like Script# and CofeeScript and others. The pros in cons of these systems have been discussed countless times (ex: HanselminutesJavaScript is Assembly Language for the Web: Semantic Markup is Dead! Clean vs. Machine-coded HTML).

With the recently released project Roslyn (or alternatively Mono Compiler Services) it is possible to have a clean solution to the problem:  I write my data and data model in a language and an environment that allow solid validation and refactoring.

I’m ironing out some kinks in my implementation and, as soon as it’ll be in a stable state, I’m going to release a NWT (NeWT) project that will provide a similar to GWT (Google Web Toolkit) functionality.

Posted in C#, GWT, Javascript, jQuery, Web | 1 Comment »

XML/JSON symmetric REST web services providers for Jersey

Posted by Igor Moochnick on 07/27/2009

Many times I’ve been asked to provide a set of Web Services interfaces where both JSON and XML clients can communicate with the server. Primarily it’s done for a set of reasons:

  1. XML is very convenient to use for inter-service communication.
  2. JSON is great for AJAX (web) clients. It’s perfect for GWT too.

In the recent project we’ve been using XStream for all serialization aspects and, since it can serialize both to XML and JSON, it was plugged into Jersey as a provider too. Following you can see XML and JSON providers implemented using XStream library.

XML Provider (annotated to be a default provider, it’ll be used if no Content-Type or Accept headers provided):

Read the rest of this entry »

Posted in GWT, Java, Jersey, JSON, REST, Tutorials, XML, XStream | 2 Comments »

Adding Watermark to GWT Textbox widget

Posted by Igor Moochnick on 06/30/2009

Let’s see how we can improve our UI by adding some watermarked “spice”:

clip_image001

Let’s define the primary style for the text box (textInput) and the dependent style for the watermark (textInput-watermark):

.textInput {
	border: 1px solid #C9C7BA;
	font-family:Tahoma, Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
	padding-left: 2px;
	padding-top: 2px;
}

.textInput-watermark {
   /* background-image: url('images/overlay.gif');
   background-repeat: no-repeat;
   padding-left: 20px;
   vertical-align: middle; */
   font-style: italic;
   color: DarkGray;
}

Note that the watermark style can contain images as well (see the commented out piece).

After the styles were defined we need to add some code that will apply it to the text box. To do this I’m going to extend the default GWT TextBox. The trick is to hijack the OnBlur and OnFocus events. When the OnBlur is occurring, we’re going to show the watermark and OnFocus – hide it:

public class WatermarkedTextBox extends TextBox implements BlurHandler, FocusHandler
{
	String watermark;
	HandlerRegistration blurHandler;
	HandlerRegistration focusHandler;
	
	public WatermarkedTextBox( )
	{
		super();
		this.setStylePrimaryName("textInput");
	}
	
	public WatermarkedTextBox(String defaultValue)
	{
		this();
		setText(defaultValue);
	}
	
	public WatermarkedTextBox(String defaultValue, String watermark)
	{
		this(defaultValue);
		setWatermark(watermark);
	}
	
	/**
	 * Adds a watermark if the parameter is not NULL or EMPTY
	 * 
	 * @param watermark
	 */
	public void setWatermark(final String watermark)
	{
		this.watermark = watermark;
		
		if ((watermark != null) && (watermark != ""))
		{
			blurHandler = addBlurHandler(this);
			focusHandler = addFocusHandler(this);
			EnableWatermark();
		}
		else
		{
			// Remove handlers
			blurHandler.removeHandler();
			focusHandler.removeHandler();
		}
	}

	@Override
	public void onBlur(BlurEvent event)
	{
		EnableWatermark();
	}
	
	void EnableWatermark()
	{
		String text = getText(); 
		if ((text.length() == 0) || (text.equalsIgnoreCase(watermark)))
		{
			// Show watermark
			setText(watermark);
			addStyleDependentName("watermark");
		}
	}

	@Override
	public void onFocus(FocusEvent event)
	{
		removeStyleDependentName("watermark");
		
		if (getText().equalsIgnoreCase(watermark))
		{
			// Hide watermark
			setText("");
		}
	}
}

Posted in Design, GWT, Java, Tutorials, Web | 10 Comments »

Job trends for GWT and jQuery on a sharp rise

Posted by Igor Moochnick on 06/11/2009

Gotta love this …

jobgraph[1]

Posted in GWT, jQuery | Leave a Comment »

Building GWT web clients [Part 4] – How to connect GWT client to Azure web service?

Posted by Igor Moochnick on 06/08/2009

Stay tuned …

Posted in Azure, Cloud, GWT, Java, JSON, REST, Tutorials | Leave a Comment »

Building GWT web clients [Part 3] – How to connect GWT client to JAX-RS Jersey server?

Posted by Igor Moochnick on 06/08/2009

Stay tuned …

Posted in Cloud, GWT, Java, JAX-RS, Jersey, JSON, REST, Tutorials | 7 Comments »

Building fat GWT web clients [Intro] – How to create a GWT RPC client?

Posted by Igor Moochnick on 05/18/2009

After months of working (mainly fighting with quirks of Java) with GWT I’ve accumulated so much knowledge on the topic so, I feel, it starts spilling over. I’m planning to convert this spill into a series of articles on how to build fat REST-full GWT web fat clients both on Java and .NET.

Here is the list of topics I’ll cover:

  1. Building GWT fat client
  2. Java REST-full Web services
  3. .NET REST-full Web services
  4. Internationalization and localization
  5. IOC/DI
  6. Unit testing and integration testing of all the components of the system
  7. Build automation
  8. and much, much more …

Here is a draft list of technologies I’ll be using:

  1. GWT
  2. Eclipse
  3. Spring
  4. Jersey
  5. Tomcat
  6. XStream
  7. AJAX
  8. JSON/XML
  9. WCF
  10. JUnit/TestND/NUnit
  11. Selenium
  12. Ant
  13. TeamCity
  14. and much, much more …

For starters, let’s see how to create a simple GWT fat client that talks to the REST-full Web services. As an example,

Read the rest of this entry »

Posted in Cloud, GWT, Java, REST, Tutorials, Web | 3 Comments »

Tree event handler in GWT 1.6

Posted by Igor Moochnick on 04/28/2009

The documentation was a little sparse so, if you’d like to subscribe to the click events on the tree nodes you need to add a selection handler.

This is how you add a selection handler to the whole tree:

Tree optionsTree = new Tree();
optionsTree.addSelectionHandler(new SelectionHandler()
{
    @Override
    public void onSelection(SelectionEvent event)
    {
        Window.alert(event.getSelectedItem().getText());
    }
});

Posted in GWT, Java | 4 Comments »

Deploying GWT applications on Tomcat

Posted by Igor Moochnick on 04/19/2009

If you’re looking for some guidance about deploying GWT applications on Tomcat, I found these articles helpful:

  1. Deploy Google Web Toolkit(GWT) Applications using Tomcat
  2. gwt-examples – tomcat6 Documentation

Posted in GWT, Java, Tomcat | Leave a Comment »

 
%d bloggers like this: