Tuesday, May 10, 2011

selecting swing components in jquery style

The latest commit #527 I've changed the signature of query method. Now it returns the QueryResult object allowing you to manipulate result in jquery style. Check the example:

DomModel model = ...;
model.query(".loginForm label.important").attr("color", "red");

DomModel model = ...;
model.query("input[type='text']").each(new Visitor() {
  public void visit(Tag tag) {
    JTextField f = tag.getComponent();
    if (StringUtils.isNotEmpty(f.getText()) {
       f.setEnabled(false);
    }
  }
});

Maybe I should think about some animation support, like:

DomModel model = ...;
//start 'shake' effect on components
model.query(".loginForm label.important").animate("shake");

The version 0.5 will include this functionality. It will be released soon as I finish documenting new features. By the way, you can checkout the trunk, build it and use it. I hope no changes in the code will be made until the release (except for bug fixes).

No comments :

Post a Comment