- some large images for the features background.
- some small images to use as menu items.
- some images with the same height/width as the large one, but transparent with the text you want to show with the background image.
A blog for developers, i will post some cool tricks and tips about developing in general, but more often about iOS
Thursday, September 10, 2009
Using jQuery to build a feature carrousel
Wednesday, August 19, 2009
fast coding with Java
Java projects have a very slow startup time. We need to configure many things, put our frameworks to work together, configure the dependencies and many other stuff.
Just imagine how much times you wanted to start a new project and gave up because you had so much things to download and configure?
Some script languages, like ruby and python, have a application generator, that make it easy to start coding with almost any configuration.
So why cant we do the same with Java? Why do we have to download every framework again and configure all the xml's files every time?
This is the main purpose of the Rocket Science project.
There you will find a basic project, featuring all you need to start coding right after you donwload the package.
This basic project features nice urls, page templates, inversion of control, json serialization and jquery with jquery UI.
Just unpack the ZIP file and import the project into eclipse, and you are done to start coding.
Soon we will release a pre-configured AppEngine/GWT project that works in the same way.
Monday, July 27, 2009
Authenticate user using the google accounts
public class LoginInfo implements Serializable { private boolean loggedIn = false; private String loginUrl; private String logoutUrl; private String emailAddress; private String nickname;
import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @RemoteServiceRelativePath("login") public interface LoginService extends RemoteService { public LoginInfo login(String requestUri); }
import com.google.gwt.user.client.rpc.AsyncCallback; public interface LoginServiceAsync { public void login(String requestUri, AsyncCallbackasync); }
import com.google.appengine.api.users.User; import com.google.appengine.api.users.UserService; import com.google.appengine.api.users.UserServiceFactory; import com.google.gwt.sample.stockwatcher.client.LoginInfo; import com.google.gwt.sample.stockwatcher.client.LoginService; import com.google.gwt.user.server.rpc.RemoteServiceServlet; public class LoginServiceImpl extends RemoteServiceServlet implements LoginService { public LoginInfo login(String requestUri) { UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); LoginInfo loginInfo = new LoginInfo(); if (user != null) { loginInfo.setLoggedIn(true); loginInfo.setEmailAddress(user.getEmail()); loginInfo.setNickname(user.getNickname()); loginInfo.setLogoutUrl(userService.createLogoutURL(requestUri)); } else { loginInfo.setLoggedIn(false); loginInfo.setLoginUrl(userService.createLoginURL(requestUri)); } return loginInfo; } }
LoginServiceAsync loginService = GWT.create(LoginService.class); loginService.login(GWT.getHostPageBaseURL(), new AsyncCallback() { public void onFailure(Throwable error) { } public void onSuccess(LoginInfo result) { loginInfo = result; if(loginInfo.isLoggedIn()) { loadUserData(); } else { loadLogin(); } } });
Friday, July 24, 2009
AGILEBOTS - Another GWT Interface Libary
- Easy menu-like frontpage
- Dynamic HELP
- FormFields
- Tooltips
Wednesday, July 22, 2009
DivPanel - Creating a new Widget
public class DivPanel extends SimplePanel {
private WidgetCollection children = new WidgetCollection(this);
public DivPanel() {
super();
}
public Widget getWidget(int index) {
return getChildren().get(index);
}
public int getWidgetCount() {
return getChildren().size();
}
public int getWidgetIndex(Widget child) {
return getChildren().indexOf(child);
}
public Iterator
return getChildren().iterator();
}
public boolean remove(int index) {
return remove(getWidget(index));
}
@Override
public boolean remove(Widget w) {
// Validate.
if (w.getParent() != this) {
return false;
}
// Orphan.
orphan(w);
// Physical detach.
Element elem = w.getElement();
DOM.removeChild(DOM.getParent(elem), elem);
// Logical detach.
getChildren().remove(w);
return true;
}
public void add(Widget child){
add(child,getElement());
}
protected void add(Widget child, Element container) {
// Detach new child.
child.removeFromParent();
// Logical attach.
getChildren().add(child);
// Physical attach.
DOM.appendChild(container, child.getElement());
// Adopt.
adopt(child);
}
protected WidgetCollection getChildren() {
return children;
}
}
public class DockDiv extends DivPanel{
public final static int NORTH = 0;
public final static int SOUTH = 1;
public final static int EAST = 2;
public final static int WEST = 3;
public final static int CENTER = 4;
private Element north = DOM.createDiv();
private Element south = DOM.createDiv();
private Element east = DOM.createDiv();
private Element west = DOM.createDiv();
private Element center = DOM.createDiv();
private Element row = DOM.createDiv();
private Element container = DOM.createDiv();
public DockDiv(){
container.appendChild(north);
container.appendChild(row);
container.appendChild(south);
row.appendChild(west);
row.appendChild(center);
row.appendChild(east);
getElement().appendChild(container);
east.getStyle().setProperty("float", "left");
west.getStyle().setProperty("float", "left");
center.getStyle().setProperty("float", "left");
}
public void add(Widget child){
add(child,center);
}
public void add(Widget child, int pos){
switch (pos) {
case NORTH:
add(child,north);
break;
case SOUTH:
add(child,south);
break;
case EAST:
add(child,east);
break;
case WEST:
add(child, west);
break;
default:
add(child, center);
break;
}
}
public Element getRegion(int region){
switch (region) {
case NORTH:
return north;
case SOUTH:
return south;
case EAST:
return east;
case WEST:
return west;
default:
return center;
}
}
@Override
public void setWidth(String width) {
super.setWidth(width);
north.getStyle().setProperty("width", width);
row.getStyle().setProperty("width", width);
south.getStyle().setProperty("width", width);
}
public void setCenterSize(String west, String center, String east){
if (west != null && !west.equals("")){
this.west.getStyle().setProperty("width", west);
}
if (center != null && !center.equals("")){
this.center.getStyle().setProperty("width", center);
}
if (east != null && !east.equals("")){
this.east.getStyle().setProperty("width", east);
}
}
}
Friday, July 17, 2009
Composites - When you need to group widgets
public class LabelTextField extends Composite {
private HorizontalPanel hPanel;
private Label lblField;
private TextBox txtField;
public LabelTextField(Label lbl, TextBox txt) {
lblField = lbl;
txtField = txt;
hPanel = new HorizontalPanel();
hPanel.add(lblField);
hPanel.add(txtField);
initWidget(hPanel);
}
public String getValue(){
return txtField.getText();
}
public String getLabel(){
return lblField.getText();
}
}
Thursday, July 16, 2009
How to upload the chat application to google AppEngine
Wednesday, July 15, 2009
How to create a simple chat using GWT and AppEngine - Second Part
public final class PMF {
private static final PersistenceManagerFactory pmfInstance = JDOHelper.getPersistenceManagerFactory("transactions-optional");
private PMF(){ }
public static final PersistenceManagerFactory getFactory(){
return pmfInstance;
}
public static final PersistenceManager getManager(){
return getFactory().getPersistenceManager();
}
public static final void saveObject(Object obj){
getManager().makePersistent(obj);
}
}
@Persistent
private Date sentAt;
public String shoutToServer(Shout s){
s.setSentAt(new Date());
PMF.saveObject(s);
return s.getMessage();
}
public List
Query query = PMF.getManager().newQuery(Shout.class);
query.setOrdering("sentAt ascending");
List
return resultset;
}
public List
PersistenceManager manager = PMF.getManager();
Query q = manager.newQuery(Shout.class);
ArrayList
List
for (Shout a: resultset){
if (a.getSentAt().after(now)){
result.add(a);
}
}
return result;
}
public List
public List
void getAllShouts(AsyncCallback
void getNewerThan(Date now, AsyncCallback
final VerticalPanel messagesPanel = new VerticalPanel();
private Date lastUpdatedAt;
Timer t;
private void checkMessages(){
t.schedule(1000);
}
private void configureTimers(){
t = new Timer(){
@Override
public void run() {
shoutService.getNewerThan(lastUpdatedAt, new AsyncCallback
public void onFailure(Throwable caught) {
checkMessages();
}
public void onSuccess(List
if (result.size() > 0){
for (Shout i: result){
messagesPanel.add(new HTML(i.getMessage()));
}
lastUpdatedAt = result.get(result.size()-1).getSentAt();
}
checkMessages();
};
});
}
};
}
configureTimers();
shoutService.getAllShouts(new AsyncCallback
public void onFailure(Throwable caught) {
checkMessages();
}
public void onSuccess(List
for (Shout i: result){
messagesPanel.add(new HTML(i.getMessage()));
if (i.getSentAt().after(lastUpdatedAt)){
lastUpdatedAt = i.getSentAt();
}
}
checkMessages();
}
});
Tuesday, July 14, 2009
How to create a simple chat using GWT and AppEngine - First Part
- Client
- Server
- add a new line to the table in the html
- Create a Panel and add it to the line created
- Create a model class to represent the message sent - We will call this class "Shout"
- Create a service to send this shout to the server
- implements the client call to the service
what we are doing here is creating a new container to put our panel with the messages.
public void onModuleLoad() {
final VerticalPanel messagesPanel = new VerticalPanel();
final Button sendButton = new Button("Send");
final TextBox nameField = new TextBox();
// Add the nameField and sendButton to the RootPanel
// Use RootPanel.get() to get the entire body element
RootPanel.get("nameFieldContainer").add(nameField);
RootPanel.get("sendButtonContainer").add(sendButton);
RootPanel.get("messagesContainer").add(messagesPanel);
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class Shout implements Serializable{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String message;
public Shout(){}
public Shout(String message){
this.message = message;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Long getId() {
return id;
}
}
@RemoteServiceRelativePath("shout")
public interface ShoutService extends RemoteService{
String shoutToServer(Shout s);
}
public interface ShoutServiceAsync {
void shoutToServer(Shout s, AsyncCallback
}
@SuppressWarnings("serial")
public class ShoutServiceImpl extends RemoteServiceServlet implements ShoutService{
public String shoutToServer(Shout s){
return s.getMessage();
}
}
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final GreetingServiceAsync greetingService = GWT
.create(GreetingService.class);
private final ShoutServiceAsync shoutService = GWT.create(ShoutService.class);
sendButton.setEnabled(false);
Shout s = new Shout(nameField.getText());
nameField.setText("");
shoutService.shoutToServer(s, new AsyncCallback
public void onFailure(Throwable caught) {};
public void onSuccess(String result) {
messagesPanel.add(new HTML(result));
sendButton.setEnabled(true);
};
});