UIImage* backgroundImage = [[UIImage imageNamed:@”stretchableImage.png”] stretchableImageWithLeftCapWidth:44 topCapHeight:45];
A blog for developers, i will post some cool tricks and tips about developing in general, but more often about iOS
Wednesday, September 1, 2010
iOS - Adding a stretchable UIImage as background
Thursday, September 10, 2009
Using jQuery to build a feature carrousel
- 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.
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);
};
});