Can't access some (header) fields in a JSF controller?

I cannot access some (header) fields in controllers.
For example

My controller (* .java)

package com.co.controller;

public class MyController {
    // fields
    private String FIELD;
    private String F1;

    // .... Controller code

    // Setters and Getters
    public String getFIELD() {
        return FIELD;
    }
    public void setFIELD(String fIELD) {
        FIELD = fIELD;
    }
    public String getF1() {
        return F1;
    }
    public void setF1(String f1) {
        F1 = f1;
    }
}

My screen (* .xhtml)
When I try to use

<h:panelGrid>
    <h:outputText value="#{myController.FIELD}" />
    <h:outputText value="#{myController.F1}" />
</h:panelGrid>

Result - Field F1: NOT Available HOWLY
FIELD Field: available

There was an error

Property 'F1' not found on type com.co.controller.MyController 

Also when I try to use

<h:panelGrid>
    <h:outputText value="#{myController.FIELD}" />
    <h:outputText value="#{myController.F1}" />
</h:panelGrid>

Result - Field F1: available HOWEVER
FIELD field: NOT Available

What for?

+3
source share
3 answers

BeanELResolver, which converts your EL expressions to property access, is tied to the JavaBean specification . It states (in section 8.8):

, Java-, . , , , , .

. FeatureDesriptor . , bean:

  • FIELD, ,
  • f1,
  • f1

f1, JavaBeans, PropertyNotFoundException.

, camelCase / .

. : JavaBean?

+4

, ManagedBean get/set, CamelCase . JSF xhtml, . , , /.

private String FE123;

public String getFE12345() {
    return FE123;
}

public void setFE12345(String fE123) {
    this.FE123 = fE123;
}

,

   <h:outputText value="#{managedBean.FE12345}" />

   <h:outputText value="#{managedBean.FE123}" />

:

getField();
getFIELD();

JSF , FIELD I. . , managedBean.FIELD. getField,

<h:outputText value="#{managedBean.field}" />

getF1();

JSF , 1, . , , JSF / . - ManagedBean , get/set , bean :

 <h:outputText value="#{managedBean.f1}" />

, ,

+2

.

.

private String FIELD;

 public String getField() {
        return FIELD;
    }

XHTML

<h:outputText value="#{seasonSearchController.field}" />

javadoc , .

:

setFoo ( PropertyType);// PropertyType getFoo();//

getter GetFoo setFoo - . Accessor . . , 8.3.

8.3.1

:

public <PropertyType> get<PropertyName>(); 
public void set<PropertyName>(<PropertyType> a);

"get" "" , , -, "". "get" "set " . , .

If we find only one of these methods, then we will consider it as a read-only defining property or a writeonly property called "By default, we assume that the properties are neither bound or restricted (see section 7). Thus, a simple property read-write "foo" can be represented in two ways:

public Wombat getFoo(); 
public void setFoo(Wombat w);
+1
source

All Articles