[jboss-user] [JBoss Seam] - problem using entityqueries
jamesjmp
do-not-reply at jboss.com
Thu Sep 6 12:30:07 EDT 2007
hello,
This issue is somehow strange, so I provide you with the related code to make my explanation clear.
I´ve defined this entity-query in my components.xml file.
<framework:entity-query name="RstReportTemplate2"
| ejbql="select rstReport from RstReport rstReport"
| order="code">
| </framework:entity-query>
If I use it directly from a view xhtml file it works ok. For example
| </rich:dataTable>
| <rich:dataTable id="RstReportTemplate2"
| var="rstReport"
| value="#{RstReportTemplate2.resultList}"
| rendered="#{not empty RstReportTemplate2.resultList}">
| <h:column>
| #{rstReport.code}
| </h:column>
| </rich:dataTable>
I want to use it from a POJO. I´ve a POJO that uses this query this way:
@Name("RstReportTemp")
| public class RstReportTemplate {
|
| @In("#{RstReportTemplate2.resultList}") List<RstReport> rstRepTemplates;
|
| public RstReportTemplate() {
| }
|
| public void processTemplate() {
| Iterator<RstReport> rstReportTemp = rstRepTemplates.iterator();
| if (rstRepTemplates != null) {
| while (rstReportTemp.hasNext()) {
| // business logic code
| }
|
| }else {
| System.out.println("THERE ARE --NO-- RECORDS MATCHING RstReportTemplate2");
| }
| }
|
| }
|
When invoking to this POJO from a pojoview.page.xml with an action it works fine
<action execute="#{RstReportTemp.processTemplate}"/>
Now, here is my problem. I want to invoke that method, RstReportTemp.processTemplate, from the wire method of a POJOHome.
I´m doing it this way:
@Name("rstReportHome")
| public class RstReportHome extends EntityHome<RstReport> {
|
| public void wire() {
| ...
| RstReportTemplate repTemp = new RstReportTemplate();
| repTemp.processTemplate(rep);
| ..
| }
| ...}
This time the query doesn´t return any value, in fact the resulting List rstRepTemplates is null.
I don´t understand why the same query (with no restrictions) works fine when used directly from a view or from a POJO which is invoked by an execute of a .page.xml, but doesn´t behave the same way when it is used from a POJO which has been invoked from a different POJO.
I don´t want to have my business logic code in the POJOHome java class, that´s why I´m using another one and invoking from the wire method.
thanks in advance,
Jaime
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081749#4081749
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081749
More information about the jboss-user
mailing list