9

I would like to use partial processing but it does not work in my code. Does anybody knows why?

<h:form id="frmVehicle" prependId="false">
   <p:toolbar styleClass="form_toolbar">   
      <p:toolbarGroup>
        <p:commandButton id="save" process="@(form :not(.noprocess))" ajax="false" value="#{uimsgs.save}" action="#{vmsVehicleActionBean.save()}"
      </p:toolbarGroup>
    </p:toolbar>
    <p:messages id="vmsgs" severity="error,warn" autoUpdate="true" />
    <p:tabView id="tabViewSections" orientation="left" styleClass="ses-ui-tabs-left">
      <p:tab title="#{vms_uimsgs['vehicle.tab.data']}">
        <p:panelGrid id="gridHeader" columns="4" columnClasses="form-label,form-input,form-label,form-input" styleClass="form-grid" >
           <p:outputLabel for="kmStatus" value="#{vms_uimsgs['vehicle.kmStatus']}" />
           <p:inputText id="kmStatus" value="#{vmsVehicleActionBean.vehicle.kmStatus}"/>
           <p:outputLabel for="powerKw" value="#{vms_uimsgs['vehicle.power']}" />
           <p:inputText id="powerKw" styleclass="noprocess" value="#{vmsVehicleActionBean.powerKw}">
              <p:ajax event="keyup" update="powerPs" />
           </p:inputText>
           <p:outputLabel value="kw" />
           <p:inputText id="powerPs" styleclass="noprocess" value="#{vmsVehicleActionBean.powerPs}"> 
             <p:ajax event="keyup" update="powerKw" />
           </p:inputText>
           <p:outputLabel value="ps" />
         </p:panelGrid>
       </p:tab>
     </p:tabView>
 </h:form>

The two setters (kw & ps ) are still processed. Any idea?

jobe
  • 325
  • 2
  • 14
  • 25
  • You did not mentioned what issue you are getting here? – Subodh Joshi May 17 '13 at 05:17
  • Oh sorry. My problem is that my setter is always called when i click on my button. I would like to process every textinput except those two (ps &kw). Only the entity should be saved and the setters on the vehicle entity processed. – jobe May 17 '13 at 06:24
  • `noupdate` is not the same as `noprocess`. – BalusC May 17 '13 at 11:50
  • it's working with that: process="@this powerPs powerKw". But as i will have 20 fields, i don't want to name 18. I would like to except 2. – jobe May 19 '13 at 21:53
  • I know now where the problem is. If i put my commandButton in my panelGrid it works. But i don't want that. is there another possibility? – jobe May 19 '13 at 22:41
  • @user1667910 What version of Primefaces ? – Rong Nguyen May 20 '13 at 01:32
  • @RongNK: 3.5.4. I also notices that, when i put the commandbutton in the same container (here greadHeader) and remove ajax="false", it works. But then, with ajax="false", my Entity (vehicle) is not updated correctly. ->My action is not called. – jobe May 20 '13 at 09:06
  • 1
    AFAIK, `ajax="true"` is default, and when you use `ajax="false"` you can not use `partial processing` ! – Rong Nguyen May 20 '13 at 09:11
  • Ok. interesting. Do you have an idea how my could should look like? And why my action (save) is not done when ajax=false? – jobe May 20 '13 at 12:19
  • @user1667910 what did you mean `why my action (save) is not done` (not fire or anything else)? – Rong Nguyen May 20 '13 at 15:53
  • yes, not fired/executed. – jobe May 20 '13 at 20:29
  • @user1667910 `ajax="false"` is similar to `full-page request/response`. If you set `ajax="false"`, the `process attribute` has no meaning. You can try that ! – Rong Nguyen May 21 '13 at 01:50
  • Did you try the selector `@(form :not(.noprocess)` in firebug (or any other developer tool) to see if your jquery selector actually works for the resulting html? – Jens May 24 '13 at 15:27
  • shouldn't there be an extra closing bracket: process="@(form :not(.noprocess))" instead of process="@(form :not(.noprocess)" – zargarf May 24 '13 at 15:49

1 Answers1

1

Well i created an example thats works for the standard Primefaces showcase. In your page i see something strange. styleclass="noprocess" are you sure you use this? The API says styleClass with a capital C.

Here is an example wich works oke:

<h:form id="form">
    <p:toolbar id="tool">
        <p:toolbarGroup id="group">
            <p:commandButton value="All" ajax="true" id="btnAll" process="@(input:not(.noprocess))" actionListener="#{personBean.savePerson}" />
        </p:toolbarGroup>
    </p:toolbar>
    <p:messages id="vmsgs" severity="error,warn" autoUpdate="true" />
    <p:tabView id="tabViewSections">
        <p:tab title="test" id="tab">
            <p:panel header="Partial Process">
                <p:panelGrid id="grid" columns="2">
                    <f:facet name="header">
                        <p:messages />
                    </f:facet>
                    <h:outputLabel for="firstname" value="Firstname:" />
                    <p:inputText id="firstname" value="#{personBean.firstname}" />
                    <h:outputLabel for="surname" value="Surname: *" />
                    <p:inputText id="surname" value="#{personBean.surname}" styleClass="noprocess">                         
                    </p:inputText>
                </p:panelGrid>
            </p:panel>
        </p:tab>
    </p:tabView>
</h:form>

And then bean:

public class PersonBean {  

    private String firstname;  

    private String surname;  

    public String getFirstname() {  
        return firstname;  
    }  
    public void setFirstname(String firstname) {  
        this.firstname = firstname;
        System.out.println("Setted firstname: " +firstname);
    }  

    public String getSurname() {  
        return surname;  
    }  
    public void setSurname(String surname) {  
        this.surname = surname;  
        System.out.println("Setted surname: " +surname);
    }  

    public void savePerson(ActionEvent actionEvent) {  
         System.out.println("Fire action event");

    }  
}
Tankhenk
  • 634
  • 5
  • 20
  • In my code, when i use process="@(input:not(.noprocess))" and ajax="true" the action is not executed. if i put @(form:not(.noprocess)) it's executed but my inputtext are updated. – jobe May 21 '13 at 21:15
  • Did you changed your xhtml to styleClass instead of styleclass? – Tankhenk May 22 '13 at 06:13
  • Btw how do you test that your action event is not getting fired? – Tankhenk May 22 '13 at 06:52
  • yes, it was already styleClass at the begining, just here was it wrong copied. It test it with a system.err.println in my code. – jobe May 22 '13 at 07:26
  • Well strange. My example above works fine here. Maybe there is something wrong in your beans? Maybe you can add them to the question. Just like RongNk says if you set ajax="false" the whole partial submit doesn't work and the whole page is submitted. – Tankhenk May 22 '13 at 07:57
  • Hello. I tried with exactly the same code as you. The setter is correctly (only firstname) processed but the save Person event is never called. Again, if i replace @(input... with @(form, the action is performed, but both input are processed. My bean has the following anotations: ManagedBean, ViewScoped but I dont think thats the problem. – jobe May 24 '13 at 06:37
  • Did you tried the whole example i posted? Look at the commandbutton. You're doing something wrong there action="#{vmsVehicleActionBean.save()" change this to actionListener="#{vmsVehicleActionBean.save" Take a look here for differences between action and actionListener http://stackoverflow.com/questions/3909267/differences-between-action-and-actionlistener – Tankhenk May 24 '13 at 08:02
  • Forgot to mention but can you post your bean save method? – Tankhenk May 24 '13 at 08:27
  • I used exactly your bean and your xhtml code. So the methods are the same. I really don't understand. Are you sure the save method works for you? Or has it something with config to do? I'm using primefaces 3.5.4 with jboss 7.1 – jobe May 24 '13 at 09:12
  • and surprisingly, that works: process="@this,:form:tabViewSections:firstname". But has i have 50 inputs, i dont write to list all of them. – jobe May 24 '13 at 09:21
  • Yeah im sure it does ;-) And it also runs fine on JBOSS. But using Myfaces 2.1.7 and PF 3.5 – Tankhenk May 24 '13 at 09:32
  • Don't know. And you also see your styleclasses appear in your html? And you included your custom css correctly? – Tankhenk May 28 '13 at 06:50
  • I think so. And the partial processing works, because i see "Setted firstname: test" in the console and not surname. What i don't see is "Fire action event". It maybe has nothing to do with partial processing? I used the exactly same code as the one you proposed. I'm now using Primefaces 3.5.5 and the problem is still there. – jobe May 31 '13 at 06:49