0
<h:form id="frm">
   <p:calendar id="date" value="#{Test.txtDate}" />
</h:form>
@Named("Test")
@SessionScoped

public class Test implements Serializable {
    private Date txtDate;

    public Date getTxtDate() {
        return txtDate;
    }

    public void setTxtDate(Date txtDate) {
        this.txtDate = txtDate;
        System.out.println("Date: " + txtDate);
    }

    public Test () {

    }
}

setter does not run when value is selected, i need as value is changed, the setter should be fired.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 1: I see ja CDI bean 2: I don't see any maven 3: You don't "fire" a setter, you "call" a setter 4: Why do you use `f:ajax` in a `p:calendar`? So please improve your title, tags, question and add version info. – Kukeltje May 25 '20 at 07:59
  • "I don't see any maven" : Would u please give me a hint, i built a new project, created bean and simply asked the question. Reason for new project was to give reproduceable code. – Nasir Abbas May 25 '20 at 08:56
  • I totally fail to see what sort of hint you want. You use 'maven' in the title but there is no maven config/error/... at all in your question. Nor did you use the maven tag. So my hint would be to remove maven from the title. And there are lots of other remarks to improve your question. And a hint for the solution is the proposed duplicate – Kukeltje May 25 '20 at 09:00
  • my problem is when i select a date, it does not run setter, i mean on selecting/changing a value in any input field, when a setter will be run?? – Nasir Abbas May 25 '20 at 09:03
  • I never intended you to completely remove ajax from the `p:calendar`, but I would have expected you to (at least try to) replace `f:ajax` with a `p:ajax`. Please take a step back and start with a good JSF tutorial and then add PrimeFaces. The setter will be called when it can be called. Reasons for it not to be called and what to debug is in the duplicate. – Kukeltje May 25 '20 at 09:10
  • 1
    @Kukeltje Thanx a lot, i hv got the answer of my question from the link u suggested above. – Nasir Abbas May 25 '20 at 09:45

0 Answers0