[JBoss Seam] - Re: selectOneMenu - NPE
by w17chm4n
@Pete
Seam 2.0.0.GA
@Marius
Yes I`m sure that questionCategoryList is outjected. Anyway, this code works on Seam 1.2.1.GA...
questionCategory entity
| @Entity
| @Scope(ScopeType.EVENT)
| @Name("questionCategory")
| @Table(name="QuestionCategories")
| public class QuestionCategory implements Serializable {
|
| @Id @GeneratedValue
| private Long id;
|
| @NotNull @Length(min=3, max=100)
| private String categoryName;
|
| @OneToMany @JoinColumn(name="category_id")
| private List<Question> questionList;
|
| @Temporal(value = TemporalType.TIMESTAMP)
| private Date created;
|
| @Override
| public boolean equals(Object obj) {
| if (!(obj instanceof QuestionCategory) || this.id == null) {
| return false;
| }
|
| return this.id.equals(((QuestionCategory)obj).getId());
| }
|
| public QuestionCategory() {
| this.questionList = new ArrayList<Question>();
| }
|
| public QuestionCategory(String categoryName) {
| this.categoryName = categoryName;
| this.questionList = new ArrayList<Question>();
| }
|
| public Long getId() {
| return id;
| }
|
| public void setId(Long id) {
| this.id = id;
| }
|
| public String getCategoryName() {
| return categoryName;
| }
|
| public void setCategoryName(String categoryName) {
| this.categoryName = categoryName;
| }
|
| public List<Question> getQuestionList() {
| return questionList;
| }
|
| public void setQuestionList(List<Question> questionList) {
| this.questionList = questionList;
| }
|
| public Date getCreated() {
| return created;
| }
|
| public void setCreated(Date created) {
| this.created = created;
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105963#4105963
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4105963
18 years, 8 months
[JBoss Seam] - MDB initialized too early?
by svadu
Hi All,
I have a MDB that tries to use a stateless session bean (which is also a). And I see the following error:
javax.ejb.EJBTransactionRolledbackException: java.lang.IllegalStateException: Attempted to invoke a Seam component outside the an initialized application
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
| at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:249)
| at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:268)
| at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:138)
| at $Proxy111.onMessage(Unknown Source)
Now, I've found a solution here: http://www.jboss.org/?module=bb&op=viewtopic&t=100946
But it looks like it's a vendor specific solution. Is there other (vendor independent) solution?
Thanks in advance!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105959#4105959
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4105959
18 years, 8 months
[JBoss Seam] - Re: Parameters not sent when using s:selectItems
by marius.oancea
Problem is 99% solved by doing the following:
explicitelly added element convertor as Pete sugessted:
<h:selectManyListbox id="theList" value="#{testAction.multiSelect}" >
| <s:selectItems value="#{testAction.allElements}" var="element" label="#{element.name}" />
| <f:converter converterId="elementConvertor" />
| </h:selectManyListbox>
In param tag I called a convertor for the list parameter:
<?xml version="1.0" encoding="UTF-8"?>
| <page xmlns="http://jboss.com/products/seam/pages"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
| <param name="theList" converterId="elementListConvertor" value="#{testAction.multiSelect}" />
| </page>
The convertor is implemented as below:
| @org.jboss.seam.annotations.faces.Converter
| @Name("elementListConvertor")
| public class ElementListParameterConvertor implements Converter, Serializable {
| @In
| private EntityManager entityManager;
|
| @Transactional
| public Object getAsObject(FacesContext context, UIComponent component, String value) {
| if (value != null) {
| String[] allIds = value.split(" ");
| List<Element> theList = new ArrayList<Element>();
| for (int i = 0; i < allIds.length; i++) {
| String id = allIds;
| if (id == null || id.trim().length() == 0) continue;
| theList.add(findElement(id));
| }
| return theList;
| }
| return null;
| }
|
| private Element findElement(String id) {
| List<Element> allElements = TestAction.allElements;
| for (int i = 0; i < allElements.size(); i++) {
| if (allElements.get(i).getId().equals(new Integer(id))) return allElements.get(i);
| }
| return null;
| }
|
| public String getAsString(FacesContext context, UIComponent component, Object value) {
| if (value instanceof List) {
| List<Element> theList = (List<Element>) value;
| String s = "";
|
| for (Iterator iterator = theList.iterator(); iterator.hasNext();) {
| if (s.length() != 0) s += " ";
| Element element = (Element) iterator.next();
| s += element.id;
|
| }
| return s;
| }
| return null;
| }
|
| }
|
Having that done, all works (without need for any conversation propagation and so on).
Also if you call in the browser "localhost:8080/test/xList.seam?theList=1%202" the entries in "select" are selected as expected.
The single point that does not work is the url when you submit the page:
- point the browser to "localhost:8080/test/xList.seam?theList=1%202"
- system shows first two entries in list selected (AS EXPECTED)
- select the third entry and press submit
- system update the browser location to "localhost:8080/test/xList.seam" (WRONG, the correct is localhost:8080/test/xList.seam?theList=1%202%203)
For input Fields and selectOne, the system behaves as expected - parameter is automatically added to the URL. The problem is specific to selectManyListbox component.
Additionally, if you have a :
<s:link view="/xList.xhtml"
| value="Test List"
| propagation="none"/>
the select multi parameter is not automatically added (while an input filed and selectOne is).
Thanx again to Pete Muir for give me the valuable hints.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4105957#4105957
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4105957
18 years, 8 months