Help

Controls

PermLinkWikiLink

Built with Seam

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.

Forum: Seam Users Forum ListTopic List
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-

 

Ryan J. McDonough
http://damnhandy.com

6 Replies:
06. Mar 2008, 14:30 CET | Link

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.

Rating:  * * * * *
06. Mar 2008, 15:18 CET | Link

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
http://damnhandy.com

06. Mar 2008, 15:29 CET | Link

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

30. Jul 2008, 09:03 CET | Link

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.

30. Jul 2008, 09:07 CET | Link

You have to use Event instead of Session for the binding-class..

30. Jul 2008, 09:24 CET | Link

Can I use the Factory-Annotation to produce parts of the UI dynamically? Then I do not need the binding attribute..