I have a <h:commandButton>
on my page connected with action in my bean. It work just fine, but I wanted to add confirmation message. When I used:
<h:commandButton onclick="confirm('Are you sure?')">
it alco works just fine. But when I try to get string from bean, by making it looks like this:
<h:commandButton onclick="confirm('#{bean.confirmQ}')">
it doesn't display this string. In getter for this string I invoke method to take some info from DB, and I format it then I return it. When I use this approach nothing is shown, not even empty box, and page looks like just refreshing.
Here is code from bean:
private String confirmQ;
public String getConfirmQ() {
WycenioneAuta wa = getWycenioneAuto();
String question = "are you sure \n" + wa.getName + "?";
confirmQ = question;
return confirmQ;
}
public void setConfirmQ(String confirmQ) {
this.confirmQ = confirmQ;
}
Escape the line by writing String question = "are you sure \\n" + wa.getName + "?";
If your String variable is confirmQ , then the right EL pointing to that variable is #{bean.confirmQ}
and not #{bean.confirm}
as you've written.