views:

122

answers:

5

A coworker and I have started tech spec'ing a webapp project we're going to be working on together in our spare time. We've (mostly) settled on using: Eclipse for Java EE, ICEfaces (so that means JSF), Tomcat, Hibernate, MySQL. At work we use: IntelliJ IDEA, Struts, JSP, WebLogic, JDO, and Oracle. The only common solution we'll be using is Spring Framework.

The reason we're using what we are is because: (1)our application will rely heavily on Ajax (2) we want to try to use only open-source software that allows commercial use (3) we want the learning experience/resume builders.

So my question is this: Based on what we use and know from work and what we will be using in this side project, are there any obvious pitfalls, tips, tricks, or pieces of advice that would be helpful to consider before we start? Also appreciated would be suggestions for good Eclipse plug-ins (the one I've got so far is ICEfaces integration).

Hopefully this isn't too much of a general discussion question but I have come to respect this site's knowledge level a lot and would appreciate any advice people would be willing to give.

A: 

My suggestion is create something simple and then go fancy with it. When you try to be over optimistic [without good priorities] in specifying a project, you're pretty much writting it's failure. Start simple, with a design that scales, and scale up to what you want it to become.

Additionally use the right tool when you need it. If you aren't attempting to do a full scale enterprise app, don't use EJB.

I have no idea where this "ajax magic" is coming from but it needs to stop. AJAX is a way to communicate small information between the client and the server inorder to request and send information in an asynchronous manner. [i.e. no need for a page reload to grab frequently updating data]

My suggestion: Add in the AJAX later.

monksy
About AJAX: I think our app is a great candidate for using it. We're not just jumping on the bandwagon to avoid to page reloading :)
john
+1  A: 

You say your app will rely heavily on AJAX. Note that with every AJAX interaction you're generating a browser/server message, and potentially generate a lot more browser/server traffic. That will impact your server and network load.

AJAX can be seductive - e.g. dynamically populating drop-downs a la Google Suggest, updating page fragments etc. But watch the impact on your network and your servers.

Brian Agnew
We're definitely taking that into account. One thing we like about icefaces is AJAX Push.
john
A: 

I use Struts2 and for AJAX I simply create another action/corresponding JSP. Typically, I'll use jQuery and just perform a get on the URL with any additional query string parameters, which ends up as something like this:

JavaScript snippet from JSP requiring AJAX

function getNextPage(currentPage) {
    var nextPage = currentPage + 1;
    var url = "ajaxGetNextPage.action?page=" + nextPage;
    $.ajax({
       type: 'POST',
       url: url,
       success: function(text){
           $('#searchResults').html(text);
       }
    });
}

<input type="button" value="NextPage" onclick="getNextPage($('#currentPage').attr('value'))"/>

Action

public class NextPageAction extends ActionSupport {
    private int page -1; // with getter/setter
    private EntityDao dao; // whatever your Hibernate DAO impl is...getters/setters
    private List<Entity> entities; // whatever the entity POJO is    

    @Override
    public String execute() throws Exception {
        if(page > 0)
             entities = dao.findPagedEntities(page);
        return SUCCESS;
    }
}

JSP page (import struts tags)

<input type="hidden" id="currentPage" value="<s:property value="page"/>"/>
<s:iterator value="entities">
      <div><s:property/></div>
</s:iterator>

This is just an example with incomplete snippets, but you should get the gist from this. If you use decorators/site mesh, make sure that you exclude all ajax paths.

Droo
A: 

Ajax4JSF (a4j) might have some pitfalls, but i find it to be the easiest and fastest to implement.

Not sure how compatible is it with Icefaces though.

medopal
A: 

I would suggest you to use Google Web Toolkit. I have been using it for a while and think that is an interesting approach. You can write java that is then cross compiled + optimized to run as javascript and html.

Give it a look.

Sheldon