Hi,

for about 1 week I'm trying to find the solution to what I'm doing. So :

I'm using: 
Jboss AS 4.2.1
Jboss Seam 2.0.0 CR1

I want to have selectOneMenu in each row of dataTable to have opportunity to 
change the subgroup category of each products.

The problem is in that, when I'm submitting the form NPE is thrown and it looks 
like the selectOneMenu value is not setted. I was also trying to change the 
adnotation in at sungroup to @DataModelSelection and in some way it works, but 
it always chooses the first value.

My files:

products.xhtml


  | <h:dataTable  value="#{products}" var="product" rendered="#{products.size 
>0}">
  |                                     <h:column >
  |                                             <f:facet name="header">Change 
subgroup</f:facet>
  |                                             <h:form>
  |                                                     <h:selectOneMenu 
value="#{GroupsAction.newSubgroup}" >
  |                                                     <s:convertEntity />
  |                                                     <s:selectItems 
value="#{subs}" var="sub" label="#{sub.name}" noSelectionLabel="Select 
subgroup"/>
  |                                                     </h:selectOneMenu>
  |                                                     <h:commandButton 
action="#{GroupsAction.changeSubgroup(product)}" value="Change"/>
  |                                             </h:form>
  |                                     </h:column>             
  |                             </h:dataTable>
  | 

GroupsAction.java


  | 
  | @Stateful
  | @Name ("GroupsAction")
  | @Scope(SESSION)
  | public class GroupsAction implements Groups{
  | 
  |     ...
  | 
  |     //@DataModelSelection(value="subs")
  |     private Podgrupy newSubgroup;
  |     
  |     
  |     @PersistenceContext(type=PersistenceContextType.EXTENDED)
  |     private EntityManager em;
  |     
  |     
  |     @DataModel
  |     private List <Materia> products;
  |     
  |     @DataModel
  |     private List <Podgrupy> subs ;
  |     
  |     @Factory("subs")
  |     @Begin(join=true)
  |     public void findSubs(){
  |             subs = em.createQuery("select pg from Podgrupy pg order by 
pg.grupy.idgrupy").getResultList();
  |     }
  |     
  |     @Begin(join=true)
  |     public String changeSubgroup(Materia m){
  |             System.out.println(newSubgroup.getNazwapodgrupy());
  |             m.setPodgrupy(newSubgroup);
  |             em.merge(m);
  |             em.flush();
  |             return "products";
  |     }
  |     
  |     @Remove @Destroy
  |     public void destroy() {}
  | 
  |     public List<Podgrupy> getSubs() {
  |             return subs;
  |     }
  | 
  |     public void setSubs(List<Podgrupy> subs) {
  |             this.subs = subs;
  |     }
  | 
  |     public Podgrupy getNewSubgroup() {
  |             return newSubgroup;
  |     }
  | 
  |     public void setNewSubgroup(Podgrupy newSubgroup) {
  |             this.newSubgroup = newSubgroup;
  |     }
  | 
  |     ...
  | }
  | 
  | 

 I have read I think all topics at forum which are connected with that problem, 
but I didnt find solution.So anyone have any idea why it dont want to work ?

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

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

Reply via email to