Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using OWNER in a JSF Managed Bean without create OWNER Interface Porperties keys #260

Open
nando2301 opened this issue Mar 14, 2020 · 0 comments

Comments

@nando2301
Copy link

When I try to use Interface Class and I did not declare properties in that Interface, I can't recover it from JSF Managed Bean to use it in xhtml Page.

AppConfig.java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.nando.meetings.utils;

import org.aeonbits.owner.Config;
import org.aeonbits.owner.Config.HotReload;
import org.aeonbits.owner.Config.Sources;

/**
 *
 * @author fernando
 */
@HotReload
@Sources({"file:/Users/fernando/Desktop/borrar/meetings/conf/meetings.properties"})
public interface AppConfig extends Config {
    
}

AppConfigBean.java (JSF Managed Bean)

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.nando.meetings.bean;

import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import org.aeonbits.owner.ConfigFactory;
import org.nando.meetings.utils.AppConfig;

/**
 *
 * @author fernando
 */
@Named(value = "appConfigBean")
@SessionScoped
public class AppConfigBean implements Serializable {

    /**
     * Creates a new instance of AppConfigBean
     */
    AppConfig appConfig;
    String AppName;

    public AppConfigBean() {
        appConfig = ConfigFactory.create(AppConfig.class);
    }

    public String getAppName() {
        return appConfig.AppName();
    }

}

Part of xhtml page

        <b:row style="margin-bottom: 70px;">
            <b:navBar brand="#{appConfigBean.appName}" brandHref="#{request.contextPath}/faces/index.xhtml"
                      style="" inverse="true" position="top" sticky="true">
                <!-- Following line is needed for TBS 3.0.1 (panel content overflow issue) -->
                <b:navbarLinks pull="right"><b:navLink value="    " href="#"></b:navLink></b:navbarLinks>
                <b:navbarLinks pull="right">
                    <b:navbarLinks>
                        <b:navLink value="#{app.MenuRegistration}"
                                   href="#{request.contextPath}/faces/Registration.xhtml"></b:navLink>
                    </b:navbarLinks>
                </b:navbarLinks>
            </b:navBar>
        </b:row>

This returns and error saying: Create public method.
Then create it as:

@HotReload
@Sources({"file:/Users/fernando/Desktop/borrar/meetings/conf/meetings.properties"})
public interface AppConfig extends Config {

    public String AppName();
    
}

Please add an add-on or procedure to create Interface Class definitions because my Config File Includes App Messages and has aprox 300 properties, that is so hard to define one by one in OWNER Interface Class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant