6 Replies Latest reply: Aug 8, 2011 8:49 AM by srikannan balamurugan RSS

    a4j:support action is not called

    Maximilian Faupel Newbie

      Hi,

       

      I have a h:selectOneMenu that refreshes the content of a a4j:repeat. That works fine. When I add a4j:support to the h:selectOneRadio on the a4j:repeat, an ajax request is sent, but the action is not called. I have no validation on that page and the converters work well. I don't use ajax4jsf very long so it could be that I misunderstood something.Thank you in advance.

       

      Maximilian

       


      <s:decorate id="itemDecorate" template="/layout/display.xhtml">
          <ui:define name="label">
              Items
          </ui:define>
          <h:selectOneMenu     id="selectItem"
                              value="#{item}">
              <s:selectItems     id="items" 
                              var="item" 
                              noSelectionLabel=""
                              label="#{item.street}"
                              value="#{itemList.resultList}" />
              <s:convertEntity />
              <a4j:support event="onchange" reRender="blocksPanelGroup" />
          </h:selectOneMenu>
      </s:decorate>
      
      <h:panelGroup id="blocksPanelGroup">
          <a4j:repeat var="block" value="#{item.blocks}">
              <s:decorate id="blockCriterionDecorate" 
                          template="/layout/display.xhtml">
                  <ui:define name="label">
                      #{block.name}
                  </ui:define>
                  <h:selectOneRadio     id="blockCriterion"> 
                      <s:selectItems     var="criterion" 
                                      label="#{criterion.description}" 
                                      value="#{block.criterions}" />
                      <s:convertEntity />
                      <a4j:support     event="onchange"
                                      action="#{blockAction.save}" />
                  </h:selectOneRadio>
              </s:decorate>
          </a4j:repeat>
      </h:panelGroup>
      
        • 2. Re: a4j:support action is not called
          Maximilian Faupel Newbie

          Hi Nick,

           

          thank you for your answer, but I already know that. I read about 100 posts and tried everything. I have an output for faces messages in my template and I did override the equals and hashCode methods in my entities.

           

          That's what I put in my template:

          a4j:outputPanel ajaxRendered="true">

              <h:messages/>

          </a4j:outputPanel>

           

          I also put a <a4j:log /> tag on my page, but I can only see, that an ajax request is sent and I can't see any errors.

           

          Thanks

          Maxi

          • 3. Re: a4j:support action is not called
            Nick Belaevski Master

            OK, so we can exclude the most frequent coding issues. Can you please check this issue: https://issues.jboss.org/browse/RF-3314 to see if it's applicable to your case?

            • 4. Re: a4j:support action is not called
              Maximilian Faupel Newbie

              Two of my entities are in seams page scope. If I change that to conversation or session scope, the problem is still the same.

              • 5. Re: a4j:support action is not called
                Maximilian Faupel Newbie

                Hi Nick,

                 

                I wrote a little example to reproduce the error. I hope you can see what I made wrong.

                 

                 

                @Entity
                @Scope(ScopeType.SESSION)
                public class City implements Serializable {
                    /**
                     * 
                     */
                    private static final long serialVersionUID = -5262788797651793204L;
                    
                    private Long id;
                    private Integer version;
                    private String name;
                    private List<Street> streets = new ArrayList<Street>();
                
                    @Id
                    @GeneratedValue
                    public Long getId() {
                        return id;
                    }
                    public void setId(Long id) {
                        this.id = id;
                    }
                
                    @Version
                    public Integer getVersion() {
                        return version;
                    }
                    public void setVersion(Integer version) {
                        this.version = version;
                    }
                
                    public String getName() {
                        return name;
                    }
                    public void setName(String name) {
                        this.name = name;
                    }
                
                    @OneToMany(mappedBy = "city")
                    public List<Street> getStreets() {
                        return streets;
                    }
                    public void setStreets(List<Street> streets) {
                        this.streets = streets;
                    }
                    
                    @Override
                    public int hashCode() {
                        final int prime = 31;
                        int result = 1;
                        result = prime * result + ((id == null) ? 0 : id.hashCode());
                        result = prime * result + ((name == null) ? 0 : name.hashCode());
                        return result;
                    }
                    
                    @Override
                    public boolean equals(Object obj) {
                        if (this == obj) 
                            return true;
                        
                        if (!(obj instanceof City)) 
                            return false;
                        
                        City subject = (City) obj;
                        
                        return EqualsUtil.areEqual(this.id, subject.id) &&
                               EqualsUtil.areEqual(this.name, subject.name);
                    }
                }
                

                 

                 

                @Entity
                @Scope(ScopeType.SESSION)
                public class Street implements Serializable {
                    /**
                     * 
                     */
                    private static final long serialVersionUID = -7650360829992051220L;
                    
                    private Long id;
                    private Integer version;
                    private String name;
                    private City city;
                
                    @Id
                    @GeneratedValue
                    public Long getId() {
                        return id;
                    }
                    public void setId(Long id) {
                        this.id = id;
                    }
                
                    @Version
                    public Integer getVersion() {
                        return version;
                    }
                    public void setVersion(Integer version) {
                        this.version = version;
                    }
                
                    public String getName() {
                        return name;
                    }
                    public void setName(String name) {
                        this.name = name;
                    }
                
                    @ManyToOne
                    public City getCity() {
                        return city;
                    }
                    public void setCity(City city) {
                        this.city = city;
                    }
                    
                    @Override
                    public int hashCode() {
                        final int prime = 31;
                        int result = 1;
                        result = prime * result + ((id == null) ? 0 : id.hashCode());
                        result = prime * result + ((name == null) ? 0 : name.hashCode());
                        return result;
                    }
                    
                    @Override
                    public boolean equals(Object obj) {
                        if (this == obj) 
                            return true;
                        
                        if (!(obj instanceof Street)) 
                            return false;
                        
                        Street subject = (Street) obj;
                        
                        return EqualsUtil.areEqual(this.id, subject.id) &&
                               EqualsUtil.areEqual(this.name, subject.name);
                    }
                }
                

                 

                 

                public final class EqualsUtil {
                    public static boolean areEqual(boolean b1, boolean b2) {
                        return b1 == b2;
                    }
                
                    public static boolean areEqual(char c1, char c2) {
                        return c1 == c2;
                    }
                
                    public static boolean areEqual(long l1, long l2) {
                        return l1 == l2;
                    }
                
                    public static boolean areEqual(float f1, float f2) {
                        return Float.floatToIntBits(f1) == Float.floatToIntBits(f2);
                    }
                
                    public static boolean areEqual(double d1, double d2) {
                        return Double.doubleToLongBits(d1) == Double.doubleToLongBits(d2);
                    }
                    
                    public static boolean areEqual(Object o1, Object o2) {
                        return o1 == null ? o2 == null : o1.equals(o2);
                    }
                }
                

                 

                 

                @Local
                public interface CityLocal
                {
                    public void initCityList();
                    public List<City> getCityList();
                    public void selectStreet(Street street);
                    public void destroy();
                }
                

                 

                 

                @Stateful
                @Name("cityAction")
                @Scope(ScopeType.SESSION)
                @Restrict("#{identity.loggedIn}")
                public class CityAction implements CityLocal {
                
                    @Logger
                    private Log log;
                    
                    @PersistenceContext
                    private EntityManager em;
                    
                    @DataModel
                    private List<City> cityList;
                    
                    @Factory("cityList")
                    @Begin(join = true)
                    @SuppressWarnings("unchecked")
                    public void initCityList() {
                        cityList = em.createQuery("from City c").getResultList();
                    }
                
                    public List<City> getCityList() {
                        return cityList;
                    }
                
                    public void selectStreet(Street street) {
                        log.info("selecting street {0}", street.getName());
                    }
                
                    
                    @Destroy
                    @Remove
                    public void destroy() {
                    }
                }
                

                 

                 

                <h:form id="cityForm">
                    <rich:panel>
                        <h:panelGrid columns="1">
                            <a4j:outputPanel ajaxRendered="true">
                                <h:messages />
                            </a4j:outputPanel>
                            <a4j:log />
                            <s:decorate id="cityDecorate" template="/layout/display.xhtml">
                                <ui:define name="label">
                                    Cities
                                </ui:define>
                                <h:selectOneMenu id="selectCity" value="#{city}">
                                    <s:selectItems id="cityItems" var="city" noSelectionLabel=""
                                        label="#{city.name}" value="#{cityList}" />
                                    <s:convertEntity />
                                    <a4j:support event="onchange" reRender="streetPanelGroup" />
                                </h:selectOneMenu>
                            </s:decorate>
                
                            <h:panelGroup id="streetPanelGroup">
                                <a4j:repeat var="street" value="#{city.streets}">
                                    <h:panelGrid columns="2">
                                        <h:outputText value="#{street.name}" />
                                        <a4j:commandButton id="select" value="select"
                                            action="#{cityAction.selectStreet(street)}" />
                                    </h:panelGrid>
                                </a4j:repeat>
                            </h:panelGroup>
                        </h:panelGrid>
                    </rich:panel>
                </h:form>
                
                • 6. Re: a4j:support action is not called
                  srikannan balamurugan Newbie

                  Hi Nick

                            i have problem in my code. Im using rich:modalPanel in my Code. inside that modal h:command Button is not working. it not hit the flow written in the flow.xml file.please refer some solution to me for this problem   

                   

                  Header 1

                  <?

                  xml version='1.0' encoding='UTF-8'

                  ?>

                  <!

                  DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

                   

                  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

                   

                    

                    

                  <

                  ui:composition xmlns=

                  "http://www.w3.org/1999/xhtml"

                   

                  xmlns:ui="http://java.sun.com/jsf/facelets"

                   

                  xmlns:h="http://java.sun.com/jsf/html"

                   

                  xmlns:f="http://java.sun.com/jsf/core"

                   

                  xmlns:a4j="http://richfaces.org/a4j"

                   

                  xmlns:rich="http://richfaces.org/rich">

                   

                    

                   

                  <f:subview>

                   

                  <h:form>

                   

                   

                  <h:panelGrid width="800px" columns="2" border="0">

                   

                  <rich:panel header="" style=" background-color:#E6E6DC;">

                   

                  <br></br>

                   

                  <br></br>

                   

                  <center><h:dataTable value="${flowScope.detail.skillList}"

                   

                  var="c" rowClasses="order-table-odd-row,order-table-even-row"

                   

                  width="500px" border="1">

                   

                   

                  <h:column style="width: 500px;">

                   

                   

                  <f:facet name="header">Skill Name</f:facet>

                   

                   

                  <h:outputText value="#{c.skillName}" />

                   

                   

                  </h:column>

                   

                   

                  <h:column style="width: 500px;">

                   

                  <f:facet name="header">Level</f:facet>

                   

                  <h:outputText value="#{c.level}" />

                   

                  </h:column>

                   

                   

                  <!-- <h:column >-->

                   

                  <!-- <f:facet name="header">Tick and Delete</f:facet>-->

                   

                  <!-- <h:selectBooleanCheckbox value="#{o.del}" >-->

                   

                  <!-- </h:selectBooleanCheckbox>-->

                   

                  <!-- </h:column>-->

                   

                   

                  </h:dataTable> <br></br>

                   

                  <br></br>

                   

                  <a href="#" onclick="#{rich:component('pop')}.show()">Add</a> <rich:spacer

                   

                  width="300px" /> <h:commandLink id="link" action="delSkill">

                   

                  <h:outputText value="Delete" />

                   

                  </h:commandLink> <br></br>

                   

                  <br></br>

                   

                  <h:commandButton value="Save" action="save2"

                   

                  styleClass="submitButton" /></center>

                   

                  </rich:panel>

                   

                  </h:panelGrid>

                   

                   

                  </h:form>

                   

                   

                  <rich:modalPanel id="pop" minHeight="200" minWidth="450"

                   

                  domElementAttachment="form">

                   

                  <f:facet name="header">

                   

                  <h:outputText value="Add Skill" />

                   

                  </f:facet>

                   

                  <f:facet name="controls">

                   

                  <h:outputLink value="#"

                   

                  onclick="#{rich:component('pop')}.hide(); return false;">

                  X Close

                   

                  </h:outputLink>

                   

                  </f:facet>

                   

                   

                  <a4j:form id="addSkill">

                   

                    

                   

                  <h:panelGrid id="lpg" columns="2">

                   

                  <h:outputText value="Skill Name" />

                   

                  <h:inputText id="skillname" value="${flowScope.skill.skillName}"

                   

                  styleClass="inputbox" required="true"

                   

                  requiredMessage="Enter Skillname" />

                   

                  <h:outputText value="" />

                   

                  <h:message for="skillname" styleClass="errors" />

                   

                    

                   

                  <h:outputText value="Level" />

                   

                  <h:inputText id="level" value="${flowScope.skill.level}"

                   

                  styleClass="inputbox" required="true"

                   

                  requiredMessage="Enter Level" />

                   

                  <h:outputText value="" />

                   

                  <h:message for="level" styleClass="errors" />

                   

                    

                   

                  <h:outputText value="" />

                   

                  <a4j:commandButton value="Add" action="panel1"

                   

                  styleClass="submitButton" />

                   

                  </h:panelGrid>

                   

                  </a4j:form>

                   

                   

                  </rich:modalPanel>

                   

                  </f:subview>

                   

                  </

                  ui:composition

                  >

                   

                  Header 1

                  <

                  flow xmlns=

                  "http://www.springframework.org/schema/webflow"

                   

                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                   

                  xsi:schemaLocation="http://www.springframework.org/schema/webflow

                  http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"

                   

                   

                   

                  <view-state id="loginPage" view="/WEB-INF/pages/loginPage.xhtml">

                   

                   

                  <on-entry>

                   

                  <evaluate expression="new com.bankofireland.internalportal.beans.Login()"

                   

                  result="flowScope.userlogin"></evaluate>

                   

                  </on-entry>

                   

                   

                  <transition on="submit" to="loginDecision">

                   

                  <evaluate expression="userService.validate(flowScope.userlogin)"

                   

                  result="flowScope.error" />

                   

                  </transition>

                   

                  </view-state>

                   

                   

                  <decision-state id="loginDecision">

                   

                  <if test="flowScope.error" then="welcome1" else="loginpage" />

                   

                  </decision-state>

                   

                    

                    

                   

                  <view-state id="welcome1" view="/WEB-INF/pages/welcome.xhtml">

                   

                  <on-entry>

                   

                  <evaluate expression="new com.bankofireland.internalportal.beans.Detail()"

                   

                  result="flowScope.detail" />

                   

                  <evaluate expression="new com.bankofireland.internalportal.beans.Skill()"

                   

                  result="flowScope.skill" />

                   

                   

                  </on-entry>

                   

                   

                  <transition on="autosave" to="savedecision">

                   

                  <evaluate expression="saveDetail.save(flowScope.detail)"

                   

                  result="flowScope.saveerror" />

                   

                  </transition>

                   

                  <!-- <transition on="add" >-->

                  <!-- <evaluate expression="saveDetail.test(flowScope.detail)"/></transition>-

                   

                   

                   

                  <transition on="panel1">
                     <evaluate expression="saveDetail.adduser(flowScope.skill,flowScope.detail)" />
                  
                  <evaluate expression="new com.bankofireland.internalportal.beans.Skill()" result="flowScope.skill" />
                  
                   
                     </transition>
                  

                   

                   

                   

                   

                  </view-state>

                   

                  <decision-state id="savedecision">

                   

                  <if test="flowScope.saveerror" then="thirdpage" else="welcome1" />

                   

                  </decision-state>

                   

                  <view-state id="thirdpage" view="/WEB-INF/pages/thirdpage.xhtml" />

                   

                  </

                  flow

                  >

                  >