blob: 85017d9e24b6be8a126d6a7e84193e1e3f222643 [file] [log] [blame]
package org.apache.struts.using_tags.helloworld.action;
import org.apache.struts.using_tags.helloworld.model.MessageStore;
import com.opensymphony.xwork2.ActionSupport;
/**
* Acts as a Struts 2 controller that responds
* to a user action by setting the value
* of the Message model class, and returns a String
* result.
* @author Bruce Phillips
*
*/
public class HelloWorldAction extends ActionSupport {
private static final long serialVersionUID = 1L;
/**
* The model class that stores the message
* to display in the view.
*/
private MessageStore messageStore;
private static int helloCount = 0;
public int getHelloCount() {
return helloCount;
}
public void setHelloCount(int helloCount) {
HelloWorldAction.helloCount = helloCount;
}
/*
* Creates the MessageStore model object,
* increase helloCount by 1 and
* returns success. The MessageStore model
* object will be available to the view.
* (non-Javadoc)
* @see com.opensymphony.xwork2.ActionSupport#execute()
*/
public String execute() throws Exception {
messageStore = new MessageStore() ;
helloCount++;
return SUCCESS;
}
public MessageStore getMessageStore() {
return messageStore;
}
public void setMessageStore(MessageStore messageStore) {
this.messageStore = messageStore;
}
}