At line 21 changed 1 line. |
In this step, you'll generate a an HTML Template to display information from the Person object. It will contain Tapestry's syntax for rendering form elements - which is just HTML with "jwcid" attributes. The AppGen tool that's used to do this is based off a StrutsGen tool - which was originally written by [Erik Hatcher|http://www.blogscene.org/erik/]. It's basically just a couple of classes and a bunch of XDoclet templates. All these files are located in extras/appgen. |
In this step, you'll generate a an HTML Template to display information from the Person object. It will contain Tapestry's syntax for rendering form elements - which is just HTML with "jwcid" attributes. The [AppGen] tool that's used to do this is based off a StrutsGen tool - which was originally written by [Erik Hatcher|http://www.blogscene.org/erik/]. It's basically just a couple of classes and a bunch of XDoclet templates. All these files are located in extras/appgen. |
At line 26 changed 1 line. |
* Execute __ant -Dobject.name=Person -Dappgen.type=pojo__ to generate a bunch of files in __extras/appgen/build/gen__. In fact, it'll generate all the files you need to complete this tutorial. However, let's just grab the ones you need. |
* Execute __ant -Dobject.name=Person -Dappgen.type=pojo -Dapp.module=__ to generate a bunch of files in __extras/appgen/build/gen__. In fact, it'll generate all the files you need to complete this tutorial. However, let's just grab the ones you need. |
At line 32 changed 1 line. |
* Copy the contents of Person.properties into web/WEB-INF/classes/ApplicationResources_en.properties. These are all the keys you will need for titles/headings and form properties. Here is an example of what you should add to ApplicationResources_en.properties: |
* Copy the contents of Person.properties into web/WEB-INF/classes/ApplicationResources.properties. These are all the keys you will need for titles/headings and form properties. Here is an example of what you should add to ApplicationResources.properties: |
At line 36 changed 3 lines. |
personForm.id=Id |
personForm.firstName=First Name |
personForm.lastName=Last Name |
person.id=Id |
person.firstName=First Name |
person.lastName=Last Name |
At line 53 changed 1 line. |
* Copy personForm.html and personForm.page to web/pages/personForm.jsp and web/pages/personForm.page. Copy personList.html and personList.page to web/pages/personList.jsp and web/pages/personList.page. ''Notice that each of the new filename's first character is lowercase.'' |
* Copy personForm.html and personForm.page to web/pages/personForm.html and web/pages/personForm.page. Copy personList.html and personList.page to web/pages/personList.html and web/pages/personList.page. |
At line 72 changed 1 line. |
import org.appfuse.service.Manager; |
import org.appfuse.service.PersonManager; |
At line 76 changed 1 line. |
private Manager manager; |
private PersonManager personManager; |
At line 87 changed 2 lines. |
manager = (Manager) ctx.getBean("manager"); |
page.setManager(manager); |
personManager = (PersonManager) ctx.getBean("personManager"); |
page.setPersonManager(personManager); |
At line 120 changed 2 lines. |
assertNotNull(manager); |
Person person = (Person) manager.getObject(Person.class, new Long(1)); |
assertNotNull(personManager); |
Person person = personManager.getPerson("1"); |
At line 154 added 1 line. |
import org.apache.tapestry.engine.ILink; |
At line 155 changed 1 line. |
import org.apache.tapestry.event.PageRenderListener; |
import org.apache.tapestry.event.PageBeginRenderListener; |
At line 160 changed 1 line. |
public abstract class PersonForm extends BasePage implements PageRenderListener { |
public abstract class PersonForm extends BasePage implements PageBeginRenderListener { |
At line 162 removed 1 line. |
public abstract void setPersonManager(PersonManager mgr); |
At line 174 changed 6 lines. |
public void cancel(IRequestCycle cycle) { |
if (log.isDebugEnabled()) { |
log.debug("Entering 'cancel' method"); |
} |
|
cycle.activate("mainMenu"); |
public ILink cancel(IRequestCycle cycle) { |
log.debug("Entering 'cancel' method"); |
return getEngineService().getLink(false, "persons"); |
At line 182 changed 4 lines. |
public void delete(IRequestCycle cycle) { |
if (log.isDebugEnabled()) { |
log.debug("entered 'delete' method"); |
} |
public ILink delete(IRequestCycle cycle) { |
log.debug("entered 'delete' method"); |
At line 187 changed 1 line. |
getPersonManager().removePerson(getPerson().getId().toString()); |
getPersonManager().removePerson(getPerson().getPersonId().toString()); |
At line 189 changed 3 lines. |
MainMenu nextPage = (MainMenu) cycle.getPage("mainMenu"); |
nextPage.setMessage(getMessage("person.deleted")); |
cycle.activate(nextPage); |
PersonList nextPage = (PersonList) cycle.getPage("persons"); |
nextPage.setMessage(getText("person.deleted")); |
return getEngineService().getLink(false, nextPage.getPageName()); |
At line 194 changed 6 lines. |
public void edit(IRequestCycle cycle) { |
Object[] parameters = cycle.getServiceParameters(); |
Long id = (Long) parameters[0]; |
|
if (log.isDebugEnabled()) { |
log.debug("getting person with id: " + id); |
public ILink save(IRequestCycle cycle) { |
if (getDelegate().getHasErrors()) { |
return null; |
At line 201 removed 9 lines. |
|
setPerson(getPersonManager().getPerson(id.toString())); |
cycle.activate(this); |
} |
|
public void save(IRequestCycle cycle) { |
if (getValidationDelegate().getHasErrors()) { |
return; |
} |
At line 211 changed 1 line. |
boolean isNew = (getPerson().getId() == null); |
boolean isNew = (getPerson().getPersonId() == null); |
At line 218 changed 3 lines. |
MainMenu nextPage = (MainMenu) cycle.getPage("mainMenu"); |
nextPage.setMessage(getMessage(key)); |
cycle.activate(nextPage); |
PersonList nextPage = (PersonList) cycle.getPage("persons"); |
nextPage.setMessage(getText(key)); |
return getEngineService().getLink(false, nextPage.getPageName()); |
At line 222 changed 3 lines. |
PersonForm nextPage = (PersonForm) cycle.getPage("personForm"); |
nextPage.setMessage(getMessage(key)); |
cycle.activate("personForm"); // return to current page |
setMessage(getText(key)); |
return null; // return to current page |
At line 230 changed 1 line. |
You'll notice a number of keys in this file - "person.deleted", "person.added" and "person.updated". These are all keys that need to be in your i18n bundle (ApplicationResources_en.properties). You should've added these at the beginning of this tutorial. If you want to customize these messages, to add the a person's name or something, simply add a {0} placeholder in the key's message and then use setMessage(format(key, stringtoreplace)) method. |
You'll notice a number of keys in this file - "person.deleted", "person.added" and "person.updated". These are all keys that need to be in your i18n bundle (ApplicationResources.properties). You should've added these at the beginning of this tutorial. If you want to customize these messages, to add the a person's name or something, simply add a {0} placeholder in the key's message and then use setMessage(format(key, stringtoreplace)) method. |
At line 278 changed 1 line. |
[personForm-final.png] |
[JSFBeans/personForm-final.png] |
At line 329 added 1 line. |
<verifytext description="verify success message" text="${person.updated}"/> |
At line 363 added 1 line. |
<prepareDialogResponse description="Confirm delete" dialogType="confirm" response="true"/> |
At line 365 added 1 line. |
<verifyNoDialogResponses/> |