You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Martin Ahrer <ma...@gmx.at> on 2007/12/07 20:32:55 UTC

Multiple managed beans per JSP (View)

I'm trying to do a simple query by example page. It is a single page let's
name it querybyexample.jsp. It is backed by 2 beans form (handling editing a
selected object) and query (handling the database query).

It contains a form for entering and submitting the query parameters which
has a rendered attribute with the expression #{form.entity==null}.

As the user submits the form, the same page (there are no navigation rules)
is rendered again showing the query result table (also part of
queryexample.jsp). It has a rendered attribute with the expression
#{form.entity==null}.

A row selection for this table invokes #{query.select} which initializes
form.entity with the reference of the selected row (from the DataModel held
by the query bean). As a result as the page re-renders the query form and
query result table will not show (both have rendered=#{form.entity==null}
which is now false).

Now the form (also part of queryexample.jsp) for editing the selected row
will be visible (it uses rendered=#{form.entity!=null}. All of it's input
elements use value expressions like #{form.entity.propertyName...}.  As the
user submits the form, an action #{form.store} updates the DB and assigns
form.entity=null. So the query form and query result table reappear and the
row form disappears :)

So now comes trouble: With the next row selection from the query result
table things get messed up, the form for editing the selected row shows the
data for the (previous) first selection, seems that some internal view state
does not fit.
To investigate this I split the JSP, querybyexample.jsp now only contains
the query form + query result table and form.jsp contains the form for
editing the selection. This setup works with the same managed beans.

So now my question is what is causing this strange behaviour and what is
needed to have multiple beans work with a single view (page).

Thx

-- 
View this message in context: http://www.nabble.com/Multiple-managed-beans-per-JSP-%28View%29-tf4964056.html#a14219191
Sent from the MyFaces - Users mailing list archive at Nabble.com.