Wie initialisiere ich das Eingabetextfeld zur Laufzeit mit einem Wert aus der Datenbank ohne die Verwendung von @PostContruct?

Ich weiß sehr gut, dass

Any scoped managed bean method annotated with @PostConstruct will be called
after the managed bean is instantiated, but before the bean is placed in scope.

Erwäge

<h:inputText binding="#{bean.input}" >
</h:inputText>

wo die verwaltete Bean ist

public class Bean {
    private HtmlInputText input; 
    public PreInitializeBean(){
        input = new HtmlInputText();
        input.setMaxlength(15);
        input.setStyle("background: pink;");
        input.setValue(fetchValueFromDatabase());
    }

    private Object fetchValueFromDatabase() {
        String resultValue = null;
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            Connection con = DriverManager.getConnection(
                    "jdbc:oracle:thin:@localhost:1521:xe", "system", "system");


            System.out.println("Connection Object: "+con);
            // retieving data from RESULT table
            PreparedStatement ps = con
                    .prepareStatement("select * from RESULT",
                            ResultSet.TYPE_SCROLL_SENSITIVE,
                            ResultSet.CONCUR_UPDATABLE);

            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                System.out.print("<br>" + rs.getInt(1) + " " + rs.getString(2) + " "
                        + rs.getString(3) + " " + rs.getString(4));
                resultValue = rs.getString(2);
            }

            con.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return resultValue;
    }

    public HtmlInputText getInput() {
        return input;
    }

    public void setInput(HtmlInputText input) {
        this.input = input;
    }

}

Ich erhalte nichts im Eingabetextfeld, wenn ich das Initialisierungsmaterial im Konstruktor mache, aber ich erhalte den erwarteten Wert (einen Wert im Eingabetextfeld), wenn ich das tue, platziere ich ihn in eine mit @ PostContruct markierte Methode.
Ersetzen Sie die Konstruktormethode mit:

    @PostConstruct
    public void init() {
        input = new HtmlInputText();
        input.setMaxlength(15);
        input.setStyle("background: pink;");
        input.setValue(fetchValueFromDatabase());
    }

@ Luiggi scheint Hilfe anzubietenHie als Antwort auf einen Kommentar, den ich gemacht habe.

Hinweis Das funktioniert auch gut.

private String input;

public Bean(){
    this.input= fetchValueFromDatabase();
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage