[
https://issues.apache.org/struts/browse/SHALE-425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40560
]
Matthias Wuttke commented on SHALE-425:
---------------------------------------
Hi!
Thank you very much for your responses. First: Should I have posted my
suggestion to a mailing list or is it ok to discuss such things here?
I think it is not confusing to have multiple view controllers, each of them
with separate responsibilities. Imagine a "treeController" that is able to
handle a navigation tree (load data for the tree component, respond to events,
etc.) and a "detailController" that deals with the form displayed besides the
navigation (saving form data using Hibernate, etc.). Both of them might need
prerender() methods, for example to load data for list items after the other
form fields have been validated and applied to the model and before the page
gets rendered. Both of them seem to have "equal rights" for being the "main"
controller. Of course I could just create a single main backing controller bean
that just returns these two beans, but it did not seem to be a big deal for me
to allow multiple controllers being mapped per page.
This is especially because I personally do not like the to default naming the
Shale View imposes on me for my controllers (being a big fan of "convention
over configuration, though): I think "admin$compactDisc_list" is far too long
for a bean name, and I think template names should be allowed to contain a "-"
like in "admin/compactDisc-list.xhtml".
By the way, I'm using MyFaces, Facelets, Shale and Spring together and I
noticed some issues with Shale Tiger and Spring:
- Shale only supports "request"-scoped beans for ViewControllers. My
listController is in session-scope because I want settings like sort order,
list cursor and filter settings to be persistent across multiple invocations
(especially useful for a list-detail scenario where the user is returned to the
right page of list data after completing the detail form).
- I cannot override defaults in the faces-config.xml contained in
shale-view.jar with Spring. This is because the Spring VariableResolver first
asks the underlying (Shale/JSF) resolver. I'm afraid I cannot write
<!-- Shale View-Controller-Mapping -->
<bean name="org$apache$shale$view$VIEW_MAPPER"
class="teuto.base.shale.MemoryViewControllerMapper">
<property name="mappings">
<props>
<prop
key="/admin/compactDisc-list.xhtml">compactDiscListController</prop>
</props>
</property>
</bean>
but I need to declare the following in my faces-config.xml
<managed-bean>
<managed-bean-name>org$apache$shale$view$VIEW_MAPPER</managed-bean-name>
<managed-bean-class>teuto.base.shale.MemoryViewControllerMapper</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
The same goes for "org$apache$shale$view$VIEW_CALLBACKS" (which I need to set
to org.apache.shale.tiger.view.faces.ViewControllerCallbacks2 in order to make
Shale Tiger work, which should not be necessary, but might also be because of a
Spring problem - don't know).
These limitations made me not use Shale View (which I very much would like to
use), but instead implement an own mechanism for delegating PhaseListener
events to controller beans. I'm not sure whether you are interested, but if you
like I would share the code with you. :-)
Matthias
> ViewControllerMapper allows mapping only to one bean
> ----------------------------------------------------
>
> Key: SHALE-425
> URL: https://issues.apache.org/struts/browse/SHALE-425
> Project: Shale
> Issue Type: Improvement
> Components: View
> Affects Versions: 1.0.4
> Reporter: Matthias Wuttke
> Priority: Minor
>
> ViewControllerMapper.mapViewId(String viewId) allows only to map a view to a
> single bean. A key feature of JSF (IMHO) is the ability to have multiple
> backing beans / view controllers that contribute to a single page. An
> extension of this interface could allow other mapping strategies to associate
> multiple beans with a given page that can then receive phase change events. A
> possiblte mapping strategy would be a XmlViewControllerMapper which takes a
> XML file that associates view ids with bean names.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.