This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 252416 - Use fx:constant for constants that are not the same type as the enclosing class' type
Summary: Use fx:constant for constants that are not the same type as the enclosing cla...
Status: NEW
Alias: None
Product: javafx
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.0.2
Hardware: All All
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-15 10:41 UTC by tiainen
Modified: 2015-05-15 10:41 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Sample application that demonstrates the issue (60.70 KB, application/unknown)
2015-05-15 10:41 UTC, tiainen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tiainen 2015-05-15 10:41:02 UTC
Created attachment 153683 [details]
Sample application that demonstrates the issue

Constants that are not the same type as the enclosing class' type are not considered as valid constants candidates and give the following error:

"Constant 'ENTER_VALUE' is not defined for 'Constants'"

A simple class with some constant fields:
package netbeansfxmlconstantserror;

public class Constants {

    public static final String EMPTY = "";
    public static final String ENTER_VALUE = "Enter value";

}

A simple fxml that tries to use the constant:
<?xml version="1.0" encoding="UTF-8"?>

<?import netbeansfxmlconstantserror.Constants?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.BorderPane?>

<BorderPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:id="root">
    <center>
        <Label><text><Constants fx:constant="ENTER_VALUE"/></text></Label>
    </center>
</BorderPane>


Browsing the netbeans code, I could see that a check is explicitly done to verify that the defined constant is of the same type of the enclosing class.

http://hg.netbeans.org/main-golden/file/828c5a176b92/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/beans/BeanModelBuilder.java#l772