Hi,

I didn't know how to search for this specific problem, so I started a new 
thread. I hope you don't mind.

I have a form which allows the user to enter some values, which are attached to 
a bean (called testactionToCreate). As the name says, this form should allow 
the user to create a new testaction. To specify a testaction the user can 
choose a testcase from a dropdown-list, but he doesn't need to. But as soon as 
he chooses a testcase, some fields on the page should be filled with the values 
of the testcase. Then the user adds some data and submits the form.
That's the idea.

The dropdown-list gets its entries from a stateful bean, the testcaseSelector. 
In this bean I defined a valueChangeListener which sets some values of the 
injected testactionToCreate. This works fine. After those values are set, the 
testactionToCreate is outjected.

Now comes my problem: I only see the attributes set by testcaseSelector if they 
are displayed in an output field like h:outputText.

Next step would be to save the testactionToCreate. The save method is defined 
in a third bean, called createTestaction. When the save method is invoked all 
attributes set by the testcaseSelector are null. And that's a problem, too. But 
I think it's related to the first problem.

Here is some code:

The entity bean (testactionToCreate):
@Entity
  | @Table(name="TESTACTIONS")
  | @Name("testaction")
  | @Scope(ScopeType.SESSION)
  | public class Testaction implements Serializable, Cloneable {
  |     private long m_ID;
  |     //... the attribute list is too long. Ask me, if you need more
  |     private Long m_TCaseID;
  |     private Long m_TObjID;

The bean saving the entitiy bean (createTestaction):
@Stateless
  | @LoggedIn
  | @Name("createTestaction")
  | public class CreateTestactionAction implements CreateTestaction, 
Serializable {     
  |     @PersistenceContext(unitName = "aresDatabase")
  |     private EntityManager em;
  |     
  |     @In
  |     @Valid
  |     private User user;
  |     
  |     @Valid
  |     @In(required=false)
  |     @Out(required=false)
  |     private Testaction testactionToCreate;
  |     
  |     @In(required=false)
  |     private Release selectedRelease;
  |     
  |     @Factory("testactionToCreate")
  |     public void initTestactionToCreate() {
  |             if(testactionToCreate != null) {
  |                     return;
  |             }
  |             testactionToCreate = new Testaction();
  |             testactionToCreate.setTesterUsrID(user.getID());
  |             testactionToCreate.setValidatorUsrID(user.getID());
  |     }
  |     
  |     @IfInvalid(outcome=Outcome.REDISPLAY)
  |     public String createTestaction() {
  |                 // do something and return an outcome
  |         }

The bean managing the dropdown-list (testcaseSelector):
@Stateful
  | @Scope(ScopeType.SESSION)
  | @LoggedIn
  | @Name("testcaseSelector")
  | public class TestcaseSelection implements TestcaseSelector, Serializable {
  |     @PersistenceContext(unitName = "aresDatabase")
  |     private EntityManager em;
  |     
  |     @In(required=false)
  |     private Release selectedRelease;
  |     
  |     @In(required=false) @Out(required=false)
  |     private Testaction testactionToCreate;
  |     
  |     private Long lastSelectedReleaseID;
  |     
  |     @In(required=false) @Out(required=false, scope=ScopeType.SESSION)
  |     private Testcase selectedTestcase; 
  |     
  |     private List<Testcase> testcases;
  |     
  | 
  |     public void valueChanged(ValueChangeEvent event) {
  |             setSelectedTestcaseNumber((Long)  event.getNewValue());
  |             if(selectedTestcase != null && testactionToCreate != null) {
  |                     
testactionToCreate.setTObjID(selectedTestcase.getTObjID());
  |                     
testactionToCreate.setTCaseToken(selectedTestcase.getToken());
  |                     
testactionToCreate.setTCaseDescr(selectedTestcase.getDescr());
  |             }
  |     }

And the form:
<h:form>
  |             <div id="errors"><h:messages layout="table" /></div>
  |             <div class="buttonLine">
  |                     <h:commandButton 
action="#{createTestaction.createTestaction}" />
  |             </div>
  |             
  |             <div id="release">
  |                     <h:outputText value="#{ares_messages.filter_release}: " 
/>
  |                     <h:selectOneMenu                 
value="#{releaseSelector.selectedReleaseNumberOnly}" onchange="submit()">
  |                             <f:selectItems 
value="#{releaseSelector.releaseItemsOnly}" />
  |                     </h:selectOneMenu>
  |             </div>
  |             
  |             <table cellpadding="0" cellspacing="0" border="0">
  |                     <tr>
  |                             <th><h:outputText 
value="#{ares_messages.label_testaction_TesterUsrID}" /></th>
  |                             <th><h:outputText 
value="#{ares_messages.label_testaction_TCaseID}" /></th>
  |                             <th><h:outputText 
value="#{ares_messages.label_testaction_TObjID}" /></th>
  |                             <th><h:outputText 
value="#{ares_messages.label_testaction_QATID}" /></th>
  |                             <th><h:outputText 
value="#{ares_messages.label_testaction_SevID}" /></th>
  |                             <th><h:outputText 
value="#{ares_messages.label_testaction_DevUsrID}" /></th>
  |                             <th><h:outputText 
value="#{ares_messages.label_testaction_CompID}" /></th>
  |                             <th> </th>
  |                     </tr>
  |                     <tr>
  |                             <td>
  |                                     <h:selectOneMenu 
value="#{testactionToCreate.testerUsrID}">
  |                                             <f:selectItems 
value="#{selectMenuHelper.testersWithEmptyEntry}" />
  |                                     </h:selectOneMenu>
  |                             </td>
  |                             <td>
  |                                     <h:selectOneMenu 
value="#{testcaseSelector.selectedTestcaseNumber}"
  |  onchange="submit()"
  |  valueChangeListener="#{testcaseSelector.valueChanged}">
  |                                             <f:selectItems 
value="#{testcaseSelector.testcaseItems}" />
  |                                     </h:selectOneMenu>
  |                             </td>
  |                             <td><h:outputText 
value="#{testactionToCreate.TObjID}" /></td>
  |                             <td><h:outputText 
value="#{testactionToCreate.QATID}" /></td>
  |                             <td>
  |                                     <h:selectOneMenu 
value="#{testactionToCreate.sevID}">
  |                                             <f:selectItems 
value="#{selectMenuHelper.severities}" />
  |                                     </h:selectOneMenu>
  |                             </td>
  |                             <td>
  |                                     <h:selectOneMenu 
value="#{testactionToCreate.devUsrID}">
  |                                             <f:selectItems 
value="#{selectMenuHelper.developers}" />
  |                                     </h:selectOneMenu>
  |                             </td>
  |                             <td><h:outputText 
value="#{testactionToCreate.compID}" /></td>
  |                             <td> </td>
  |                     </tr>
  |             </table>
  |             
  |             <table cellpadding="0" cellspacing="0" border="0">
  |                     <tr>
  |                             <th><h:outputText 
value="#{ares_messages.label_testobject_Token}" /></th>
  |                             <th><h:outputText 
value="#{ares_messages.label_testaction_TCaseToken}" /></th>
  |                     </tr>
  |                     <tr>
  |                             <td><h:outputText value="pending" /></td>
  |                             <td><h:inputText 
value="#{testactionToCreate.TCaseToken}" style="width: 100%;" /></td>
  |                     </tr>
  |             </table>

I tried several SessionTypes (PAGE, EVENT, SESSION and CONVERSATION) for the 
outjection of the bean testactionToCreate. I tried also to define 
testactionToCreate as a @Role of Testaction. Anything worked.

Has anybody an idea how to solve this problem?

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976039#3976039

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976039
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to