You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
| Online: | 22 Members of 4546 |
| Forum: Seam Users |
06. Mar 2008, 14:08 CET | Link |
I am trying to create a Seam component which is a plain old JavaBean. I have declared the component as such:
@Name("presentationAction")
@Scope(ScopeType.CONVERSATION)
public class PresentationAction {
@Logger
private Log log;
/**
* The PresentationDAO is a Spring Bean using a Seam-Managed
* Hibernate Session
*/
@In("#{presentationDAO}")
public PresentationDAO presentationDAO;
@DataModel("valueList")
public List<PresentationValue> valueList;
/**
* The DataTable that the valueList is bound to
*/
private UIDataTable valueTable;
/**
* The selected fund
*/
@DataModelSelection("selectedObject")
public PresentationValue selectedObject;
/**
* The list of fund components for the selected fund.
*/
@DataModel("componentList")
public List<Component<?>> componentList;
/**
* The selected fund component.
*/
@DataModelSelection("componentList")
private Component<?> selectedComponent;
...
When I run it, the first request is fine. Subsequet requests yeild the following error:
javax.el.PropertyNotFoundException: /presentation.xhtml @26,29 binding="#{presentationA
ction.valueTable}": Target Unreachable, identifier 'presentationAction' resolved to null
at com.sun.
I should note that the DAO is a Spring bean which uses a Seam-Managed persistence context. I looked at chapter 7 of the new Seam in Action book and it alluded to the fact that there is something additional that needs to be taken care of with conversation-scoped JavaBean. But that was in Chapter 3 :( Any suggestions?
Ryan-
6 Replies: | |||
|---|---|---|---|
You can not use binding="#{foo}" to bind JSF UI components directly into conversation-scoped backing beans. The conversation is not available in the RESTORE VIEW phase, when the binding needs to be resolved. Check out my weblog or have a look at the books I wrote. |
|||
Ah, ok that makes sense. In the rich:dataTable declaration I was doing:
<rich:dataTable value="#{presentationAction.valueList}"
binding="#{presentationAction.valueTable}"...
When I should be doing simply:
<rich:dataTable value="#{valueList}"...
The binding attribute shouldn't be required in this case since @DataModelSelection should be able to give me the correct selection? Just want to be sure. So any reference to:
#{presentationAction}
Will always fail with conversation-scoped bean. This now makes sense. We'll see how I fare.
Ryan J. McDonough |
|||
There is addressed in the doc section called 6.8. Conversational components and JSF component bindings It shows a workaround you can use. Good luck |
|||
Another workaround to use binding in association to the Conversation-Scope is: Associate the Bean in faces-config.xml: <managed-bean> <managed-bean-name>myBean</managed-bean-name> <managed-bean-class>myBean </managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean> But I do not know, what Scope the Bean has after this. Session or Conversation?..but it works. So I guess, the better solution is really to have an own class for the binding -attributes with Session-Scope and inject this in the Conversation-Scope. |
|||
Can I use the Factory-Annotation to produce parts of the UI dynamically? Then I do not need the binding attribute.. |
Ryan J. McDonough
http://damnhandy.com