Simple Conversation example
pmander Sep 17, 2008 3:23 PMI'm trying to do a really basic conversation example with seam. I want to prove that I can integrate seam into existing applications. This is using Seam 1.2.1 under websphere 6.1. I'm just using seam in the webcontainer for now and so don't require any ejb3 stuff. I am also using trinidad...
I have a bean that is described as follows:
`@Name("myBean")
public class PageBean {
@Begin(join=true)
@Create
public void create() {}
@In(value = "customerService", required = true, create = true)
private CustomerService service;
@Out(required = false, scope = ScopeType.CONVERSATION, value="currentCustomer")
private Customer currentCustomer;
@In(value = "customerSearch", create = true)
private CustomerSearch customerSearch;
public String searchCustomer() throws CustomerException {
currentCustomer = service.getCustomer(customerSearch);
return null;
}
}
`
My page is as follows:
`<ui:composition>
<tr:document>
<tr:form>
<tr:panelFormLayout>
<tr:inputText label="Customer Number:"
value="#{customerSearch.customerNumber}" />
</tr:panelFormLayout>
<tr:commandButton text="Search For Customer"
action="#{myBean.searchCustomer}" />
<tr:panelGroupLayout rendered="#{currentCustomer != null}">
<tr:commandButton
action="customer" text="#{currentCustomer.familyName}">
</tr:commandButton>
</tr:panelGroupLayout>
</tr:form>
</tr:document>
</ui:composition>`
So basically I search for a customer, a button with the customer's family name is displayed, I click on the button, this then navigates to another page. The other page then just outputs some of the customer's details by referencing #{currentCustomer}.
Now current customer is not annotated or described as a component but I declare that it is outputted to conversation context. However, the customer page cannot get access to this object.
What am I doing wrong here?
I have a bean that is described as follows:
`@Name("myBean")
public class PageBean {
@Begin(join=true)
@Create
public void create() {}
@In(value = "customerService", required = true, create = true)
private CustomerService service;
@Out(required = false, scope = ScopeType.CONVERSATION, value="currentCustomer")
private Customer currentCustomer;
@In(value = "customerSearch", create = true)
private CustomerSearch customerSearch;
public String searchCustomer() throws CustomerException {
currentCustomer = service.getCustomer(customerSearch);
return null;
}
}
`
My page is as follows:
`<ui:composition>
<tr:document>
<tr:form>
<tr:panelFormLayout>
<tr:inputText label="Customer Number:"
value="#{customerSearch.customerNumber}" />
</tr:panelFormLayout>
<tr:commandButton text="Search For Customer"
action="#{myBean.searchCustomer}" />
<tr:panelGroupLayout rendered="#{currentCustomer != null}">
<tr:commandButton
action="customer" text="#{currentCustomer.familyName}">
</tr:commandButton>
</tr:panelGroupLayout>
</tr:form>
</tr:document>
</ui:composition>`
So basically I search for a customer, a button with the customer's family name is displayed, I click on the button, this then navigates to another page. The other page then just outputs some of the customer's details by referencing #{currentCustomer}.
Now current customer is not annotated or described as a component but I declare that it is outputted to conversation context. However, the customer page cannot get access to this object.
What am I doing wrong here?