Seam 1.3.0.ALPHA UI example doubt
fernando_jmt Jun 15, 2007 9:59 PMI lost a lot of time trying to find out the reason for the problem I described here:
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=110611
(Problem of UnsupportedOperationException when using @ManyToMany and <s:convertEntity/>)
I tried a lot of things (debug, simplify my code, with EJB, with POJO) but I did not found the reason.
Well I do the following in order to show you the problem, and maybe you can tell me what is happening:
a) I have got Seam 1.3.0.ALPHA
b) I check UI example has the right enviroment I want to test (@ManyToMany between Person and Colour).
c) I deployed it to Jboss 4.2.0.GA and all work fine. Note that s:selectItems sample uses Seam Framework.
d) I made a POJO action component in the UI example, it looks like:
@Name("personAction")
@Scope(ScopeType.CONVERSATION)
public class PersonAction {
 @In(create=true)
 private EntityManager entityManager;
 private Person person;
 private Integer id;
 @Transactional
 public String update() {
 entityManager.joinTransaction();
 entityManager.merge(person);
 entityManager.flush();
 return "Success";
 }
 public Person getInstance() {
 if (person != null) {
 return person;
 } else {
 entityManager.joinTransaction();
 person = entityManager.find(Person.class, id);
 return person;
 }
 }
 public Integer getId() {
 return id;
 }
 public void setId(Integer id) {
 this.id = id;
 }
}
e) I created a selectItemsAction.xhtml based on selectItems.xhtml, it looks like:
<h:form>
 <s:decorate template="decorateField.xhtml">
 <ui:define name="label">Favourite Colours</ui:define>
 <ui:define name="description">A colour is an entity</ui:define>
 <h:selectManyListbox value="#{personAction.instance.favouriteColours}" >
 <s:selectItems value="#{colours.resultList}" var="colour" label="#{colour.name}" />
 <s:convertEntity />
 </h:selectManyListbox>
 </s:decorate>
 <h:commandButton value="Apply" action="#{personAction.update}">
 <s:conversationPropagation type="join" />
 </h:commandButton>
 <h:messages globalOnly="true" />
 <p><s:link view="/index.xhtml" propagation="end">Back to index</s:link></p>
 </h:form>
f) Minor changes:
pages.xml
<page view-id="/selectItemsAction.xhtml">
 <begin-conversation join="true"/>
 <param name="personId" converterId="javax.faces.Integer" value="#{personAction.id}" />
 </page>
template.xhtml (link to start the update process, exactly like selectItems):
<li><s:link view="/selectItemsAction.xhtml" propagation="join"> <code>s:selectItems POJO Action</code> <f:param name="personId" value="1" /> </s:link></li>
g) I just deploy again and trying selectItemsAction.xhtml it does not work, it gives UnsupportedOperationException (stacktrace is in the post I put at the beginning of this post) .
Now, my question is why POJO action which I added to UI example does not work?
What am I doing wrong?
As I tell you before, this also does not work using EJB(my case), and this only happens with Seam 1.3.0.ALPHA, because it works fine in Seam 1.2.1. And as I tell above, it works with Seam Framework.
Please help me, at this time I don't know how to solve this.
Thanks in advance.
 
    