[JBoss Seam] - Injection in SeamTest
by franky.b
Hello,
I'm facing some problems with my injected properties in my TestNG tests.
Probably this is very easy to solve, but I currently don't have the "right" idea.
The class to be tested is as follows:
| @Name("entityManager")
| @Scope(ScopeType.CONVERSATION)
| @SuppressWarnings("unchecked")
| public class EntityManager implements Serializable, PagedEntityManager {
|
| /**
| * The injected entity class name.
| */
| @In(value = "#{entityClassName}", create=true)
| private String m_overrideEntityClassName;
|
|
| public void showEntity(){
|
| ...
| //access the injected field
| print(m_overrideEntityClassName);
|
|
| }
|
|
| }
|
Note that the name entityManager is just arbitrary and has nothing to do with EJB or JPA EntityManager!
Now my testclass looks like this
| public class EntityManagerTest
| extends SeamTest {
|
|
| @Test
| public void testPersistEntity() throws Exception {
|
| assert !super.isSessionInvalid();
|
|
| new FacesRequest() {
|
| @Override
| protected void updateModelValues() throws Exception
| {
|
| //try to set the entityClassName
|
| setValue("#{entityClassName}",
| "Client");
|
| }
|
| @Override
| protected void invokeApplication() throws Exception
| {
| //Invoke method that uses previously set entityClassName
| invokeMethod("#{entityManager.showEntity()}");
| }
|
|
|
| }.run();
|
|
| }
|
|
The problem is: entityClassName is never injected into the entityManager. When accessing the private field it in the method showEntity, it is always null.
Am I missing something?
Thanks for any help.
---
Frank
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4124288#4124288
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4124288
18 years, 2 months
[JBoss Seam] - richfaces datascroller and scope
by lsabin
Hi.
I have a problem with the richfaces datascroller. The use case is simple: based on the selection in a listbox the app shows a list of results.
But the datascroller only works when my seam component (searchservice) is in the SESSION scope or if i create a long running conversation. In any other scopes the action (searchservice.searchCircuits) is not called when I click the buttons to paginate.
Is this the way to use the datascroller or can it work with PAGE scopes?
| <h:panelGrid id="panel1" columns="3">
| <h:selectOneListbox id="combonodes" value="#{node}" size="1">
| <s:convertEntity/>
| <s:selectItems value="#{listNodes}" var="_node" label="#{_node.description}" noSelectionLabel="---"/>
| </h:selectOneListbox>
|
| <a:commandButton value="search" action="#{searchservice.searchCircuits(nodo.id)}"
| reRender="resultsPanel"/>
|
| </h:panelGrid>
|
| <h:panelGroup id="resultsPanel">
|
| <rich:datascroller ajaxSingle="false" align="left" for="tablacircuitos" maxPages="20" rendered="#{listCircuits.rowCount>10}" />
|
| <rich:dataTable id="tablacircuitos" rows="10" value="#{listCircuits}" var="_circuit">
|
| ...................
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4124287#4124287
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4124287
18 years, 2 months