0

I have an xhtml file, where i want to perform readOnly, but after rendering the value for the field is not set. similar issues like this exist on SO. look up links below Make a p:calendar readonly

JSF readonly inputText issue

I have tried all suggestions from these links here is my piece of code

                <h:outputLabel id="vatDeductionLabel" for="vatDeduction" value="Suma ubezpieczenia"/>
                <h:selectOneMenu id="vatDeduction" label="Suma ubezpieczenia" readonly="#{facesContext.currentPhaseId.ordinal eq 6}"
                                 value="#{DfeOper062MBean.dataModel.dfeOper062DataModel.requestParameters.vatDeduction}">
                </h:selectOneMenu>

now without readonly it works,but i need to set it to either disabled after rendering and setting value or read only. when i try the above code using either facesContext.currentPhaseId.ordinal eq 6 or facesContext.renderResponse.

i get the error in my log

Caused by: javax.el.PropertyNotFoundException: /pages/operations/dfeoper062/dfeOper062.xhtml @100,130 readonly="#{facesContext.currentPhaseId.ordinal eq 6}": The class 'com.sun.faces.context.FacesContextImpl' does not have the property 'currentPhaseId'.

Any suggestion as to how to handle this situation? thank you

POM jsf version

   <dependency>
                <groupId>javax.faces</groupId>
                <artifactId>jsf-api</artifactId>
                <version>1.2.15</version>
                <scope>provided</scope>
            </dependency>
valik
  • 2,014
  • 4
  • 24
  • 55
  • 1
    What is your JSF version? What is your EL version? – Kukeltje Jul 21 '20 at 16:52
  • According to [the javadoc](https://jakarta.ee/specifications/platform/8/apidocs/javax/faces/context/FacesContext.html#getCurrentPhaseId--) that method was available since version 2.0. This exception clearly means that you're using an older version. – BalusC Jul 21 '20 at 16:56
  • @BalusC: That is what I suspected too, but if I remember correctly. I've seen an EL related issue where the EL did not resolve correctly from an abstract class (or an interface, not sure) – Kukeltje Jul 21 '20 at 17:00
  • @Kukeltje: happens only on interface default methods, you'd need method invocation instead, but this is here not the case. – BalusC Jul 21 '20 at 17:18
  • @Kukeltje i hava updated my task to show my version in pom file – valik Jul 21 '20 at 20:03
  • @BalusC i am using 1.1.5 for jsf, its a legacy project and im not allowed to upgrade the version, what could be another solution – valik Jul 21 '20 at 20:05
  • You are not allowed to update a very insecure system but you are allowed (required) to change this very old system? I'd give the assigment back to my superior... ;-) (and the version you post is the facelets version, not the JSF version) – Kukeltje Jul 21 '20 at 20:08
  • @Kukeltje i have corrected the maven version in my post to jsf , and yes :) i understand , its would break the system to upgrade the version, as it is very huge, – valik Jul 21 '20 at 20:14
  • Would there be another way to do this without upgrading versions ? may be without using current PhasId or response in read only @Kukeltje – valik Jul 21 '20 at 20:39
  • Maybe create a phaselistener and in it add/set a variable with the phaseId on the requestContext and use that in the page? Or extend the FacesContext with your own or ... – Kukeltje Jul 21 '20 at 21:32

0 Answers0