[JBoss Seam] - how to catch unhandled exception in the conversation bean
by ellenzhao
In my view code, the inputText fields are tied to the field setters of managed entities. My conversation bean manages UseCase-related states.
Let's say there is a UseCase called updateAFood. There is an action button "submit" which calls this method in the conversation bean:
| private List<Exception> errors = new ArrayList<Exception>();
| private UseCaseStack;
|
| public void tryFinishUpdateAFood(){
| if (there is no exception from entity bean's setter methods) {
| this.finishUpdateAFood();
| } else {
| this.errors.addAll(exceptions from entity beans' setter methods);
| }
| }
|
| private void finishUpdateAFood(){
| Conversation.instance().end();
| this.useCases.removeUseCase(UseCase.updateAFood);
| this.food.setStatus(CRUDStatus.UPDATED.getSymbolInDB());
| }
|
Here is my utility class UseCaseStack.java
| public class UseCaseStack {
|
| private UseCase[] stack;
| private int nEntries;
| private int size;
|
| public UseCaseStack() {
| size = 10;
| stack = new UseCase[size];
| nEntries = 0;
| }
|
| public Integer size() {
| return nEntries;
| }
|
| public Boolean isEmpty() {
| return nEntries == 0;
| }
|
| public void push(UseCase uc) {
| if (nEntries == size) {
| UseCase[] newstack = new UseCase[2 * size];
| for (int i = 0; i < size; i++)
| newstack = stack;
| stack = newstack;
| size *= 2;
| }
|
| this.stack[nEntries++] = uc;
| }
|
| public UseCase pop() {
| nEntries--;
| UseCase uc = this.stack[nEntries];
| this.stack[nEntries] = null;
| return uc;
| }
|
| public UseCase peek() {
| if (this.nEntries == 0) {
| return UseCase.startApp;
| } else {
| return this.stack[nEntries - 1];
| }
| }
|
| public UseCase previous() {
| if (this.nEntries <= 1) {
| return UseCase.startApp;
| } else {
| return this.stack[nEntries - 2];
| }
| }
|
| public Boolean contains(UseCase uc) {
| boolean result = false;
| for (int i = nEntries - 1; i >= 0; i--) {
| if (this.stack.equals(uc)) {
| result = true;
| break;
| }
| }
| return result;
| }
|
| public void removeUseCase(UseCase uc) {
| for (int i = nEntries - 1; i >= 0; i--) {
| if (this.stack.equals(uc)) {
| for (int j = i; j < nEntries - 2; j++)
| this.stack[j] = this.stack[j + 1];
|
| this.nEntries--;
| break;
| }
| }
| }
|
| public void removeUpto(UseCase uc) {
| while (pop() != uc);
| }
| }
|
| public enum UseCase { .... }
|
Any hint on how to catch the exceptions from the entity bean's setter classes in the conversation bean would be highly appreciated!
Regards,
Ellen
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4075549#4075549
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4075549
18Â years, 10Â months
[JBoss Seam] - Newbie Get Question
by nynymike
I'm getting an error when I try to process my GET request:
Invalid expression: '#(accountDao.mailbox)'. Parsed Expression of unexpected type java.lang.String
at org.apache.myfaces.el.ELParserHelper.parseExpression(ELParserHelper.j
ava:84)
at org.apache.myfaces.el.ValueBindingImpl$2.newInstance(ValueBindingImpl
.java:82)
at org.apache.myfaces.shared_impl.util.BiLevelCacheMap.get(BiLevelCacheM
ap.java:123)
at org.apache.myfaces.el.ValueBindingImpl.(ValueBindingImpl.java:1
15)
at org.apache.myfaces.application.ApplicationImpl$1.newInstance(Applicat
ionImpl.java:64)
at org.apache.myfaces.shared_impl.util.BiLevelCacheMap.get(BiLevelCacheM
ap.java:123)
at org.apache.myfaces.application.ApplicationImpl.createValueBinding(App
licationImpl.java:617)
at org.jboss.seam.jsf.SeamApplication11.createValueBinding(SeamApplicati
on11.java:143)
at org.jboss.seam.core.Expressions$1.getFacesValueBinding(Expressions.ja
va:119)
The url is:
http://localhost:8080/voicemail/viewAccount.seam?mailbox=2125551212&cid=1
|
My pages.xml is as follows:
| <page view-id="/viewAccount.xhtml">
| <param name="mailbox" value="#(accountDao.mailbox)"/>
| </page>
|
In components.xml I have:
| <factory name="account"
| value="#{accountDao.instance}"/>
| <fwk:entity-home name="accountDao"
| entity-class="us.ziacom.vm.model.Account">
| </fwk:entity-home>
|
| <component name="exampleAccount"
| class="us.ziacom.vm.model.Account"/>
|
My entity bean defines "mailbox" as a String:
| private String mailbox;
|
I must be missing something here... what am I doing wrong? I've tried everything in the last three hours...
thanks in advance!
Mike
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4075536#4075536
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4075536
18Â years, 10Â months