?? addressbookaction.java
字號:
package crud;
import crud.dao.AddressDao;
import crud.model.Address;
import crud.model.StatesList;
import java.util.Collection;
import java.util.List;
import com.opensymphony.xwork2.ActionSupport;
/**
* Address form handler.
*/
public class AddressBookAction extends ActionSupport
{
static final long serialVersionUID = -726287915382955298L;
/** adddress information is stored in this object.
* @see crud.model.Address
*/
private Address address;
/** provider of data access to the Address records table.
*/
private AddressDao dao;
/** The Spring injected Address data access object.
*/
public void setAddressDao(AddressDao dao)
{
this.dao = dao;
}
/** a collection of US States.
* @see crud.model.StatesList
*/
StatesList statesList;
/** Spring injected list of states.
* @param a list of State objects.
* @see crud.model.StatesList
* @see crud.model.State
*/
public void setStatesList( StatesList list )
{
this.statesList = list;
}
/** Accessor for a collection os US States names and abbreviations.
* @see crud.model.States
* @see crud.model.State
* @return a collection of States.
*/
public StatesList getStatesList()
{
return this.statesList;
}
/** Accessor for the address entry object.
* @see crud.model.Address
*/
public Address getAddress()
{
return this.address;
}
/** Accessor for the address entry object.
* @see crud.model.Address
*/
public void setAddress( Address ae )
{
this.address = ae;
}
/** reset (clear) the current Address.
*/
public String reset() throws Exception
{
super.clearErrorsAndMessages();
this.address = null;
setMessage( getText(MESSAGE) );
return SUCCESS;
}
/** update (save) the current Address.
*/
public String update() throws Exception
{
dao.updateAddress( this.address );
setMessage( getText(ADDRESS_SAVED) );
return SUCCESS;
}
/** find an address (by example).
*/
public String find() throws Exception
{
List list = dao.getAddress( this.address );
if( list.size() > 0 )
setAddress( (Address) list.get(0) );
setMessage(getText(ADDRESS_FOUND, "0", new String[] { String.valueOf(list.size() ) }));
return SUCCESS;
}
/** remove an address.
*/
public String remove() throws Exception
{
int rowCount = dao.deleteAddress( this.address );
if( rowCount > 0 )
this.address = null;
setMessage(getText(ADDRESS_DELETED, "0", new String[] { String.valueOf(rowCount) }));
return SUCCESS;
}
public String execute() throws Exception
{
setMessage(getText(MESSAGE));
return SUCCESS;
}
/** Default 'ready' message.
*/
public static final String MESSAGE = "addressbook.default.message";
/** Operation 'successful' message.
*/
public static final String ADDRESS_SAVED = "addressbook.updated.message";
/** Delete operation 'successful' message.
*/
public static final String ADDRESS_DELETED = "addressbook.deleted.message";
/** Find operation 'successful' message.
*/
public static final String ADDRESS_FOUND = "addressbook.found.message";
/**
* Field for Message property.
*/
private String message;
/** Accessor for the Message property.
* @return Message property
*/
public String getMessage() { return message; }
/** Accessor for the Message property.
* @param message Text to display on the AddressForm page.
*/
public void setMessage(String message) { this.message = message; }
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -