Forums de discussion
Customer @Annotation does not work in backing bean
Eric Chow, modifié il y a 7 années.
Customer @Annotation does not work in backing bean
Junior Member Publications: 79 Date d'inscription: 25/02/05 Publications récentes
Hello,
I tried to create an annotation for using in JSF backing bean but it seems not render or not take effect.
Does the Liferay 7 support annotation?
Best regards,
Eric
I tried to create an annotation for using in JSF backing bean but it seems not render or not take effect.
Does the Liferay 7 support annotation?
Best regards,
Eric
Juan Gonzalez, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentes
Hi Eric,
can you ellaborate about which annotation do you want to use and the purpose of the same?
Thanks.
can you ellaborate about which annotation do you want to use and the purpose of the same?
Thanks.
Eric Chow, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Junior Member Publications: 79 Date d'inscription: 25/02/05 Publications récentes
Hi Juan,
I just want to use annotation to inject the ResourceBundle into the JSF backing bean. But it seems not inject anything into that property.
Or I miss something. Please help.
Best regards,
Eric
I just want to use annotation to inject the ResourceBundle into the JSF backing bean. But it seems not inject anything into that property.
Or I miss something. Please help.
Best regards,
Eric
@Qualifier
@Retention(RUNTIME)
@Target({ TYPE, METHOD, FIELD, PARAMETER })
public @interface AppMessageBundle {
}
public class AppMessageBundleProvider {
private ResourceBundle bundle;
@Produces
@AppMessageBundle
public ResourceBundle getBundle() {
if (this.bundle == null) {
FacesContext context = FacesContext.getCurrentInstance();
Locale locale = context.getViewRoot().getLocale();
bundle = ResourceBundle.getBundle("i18n", locale);
}
return this.bundle;
}
}
@ManagedBean(name="circularBean")
@ViewScoped
public class CircularHandler {
@Inject
@AppMessageBundle
protected ResourceBundle bundle;
}
Juan Gonzalez, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentesEric Chow:
Hi Juan,
I just want to use annotation to inject the ResourceBundle into the JSF backing bean. But it seems not inject anything into that property.
Or I miss something. Please help.
Best regards,
Eric@Qualifier @Retention(RUNTIME) @Target({ TYPE, METHOD, FIELD, PARAMETER }) public @interface AppMessageBundle { }
public class AppMessageBundleProvider { private ResourceBundle bundle; @Produces @AppMessageBundle public ResourceBundle getBundle() { if (this.bundle == null) { FacesContext context = FacesContext.getCurrentInstance(); Locale locale = context.getViewRoot().getLocale(); bundle = ResourceBundle.getBundle("i18n", locale); } return this.bundle; } }
@ManagedBean(name="circularBean") @ViewScoped public class CircularHandler { @Inject @AppMessageBundle protected ResourceBundle bundle; }
So you are talking about CDI, not "simple" annotations.
Please can you try our CDI demo portlet and check if it works?
Eric Chow, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Junior Member Publications: 79 Date d'inscription: 25/02/05 Publications récentes
Hi Juan,
Those annotations "@Named, @ViewedScope , etc" are worked fine and I am using in my projects.
But my problem is that it does not work if I want to implement my own annotation for using in the backing bean.
It can't be inject my own implementation annotation into the backing bean. Please refer to my code in my previous post.
Best regards,
Eric
Those annotations "@Named, @ViewedScope , etc" are worked fine and I am using in my projects.
But my problem is that it does not work if I want to implement my own annotation for using in the backing bean.
It can't be inject my own implementation annotation into the backing bean. Please refer to my code in my previous post.
Best regards,
Eric
Juan Gonzalez, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentes
Can you attach a simple sample portlet so we can try to reproduce?
Thanks!
Thanks!
Eric Chow, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Junior Member Publications: 79 Date d'inscription: 25/02/05 Publications récentesJuan Gonzalez:
Can you attach a simple sample portlet so we can try to reproduce?
Thanks!
Hi Juan,
Sorry not reply for a long time. I just prepared a portlet. Please test it.
Best regards,
Eric
Pièces jointes:
Eric Chow, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Junior Member Publications: 79 Date d'inscription: 25/02/05 Publications récentes
Hi Juan,
Did you test the portlet about the CDI in the backing bean?
Best regards,
Eirc
Did you test the portlet about the CDI in the backing bean?
Best regards,
Eirc
Juan Gonzalez, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentes
Unfortunately not. Will try to check it ASAP.
Juan Gonzalez, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentes
Hi Eric.
I could make your custom annotations working using mentioned cdi-portlet demo as a base.
As what I saw in the provided web.xml, seems you're using this portlet in a Jboss app server. In case your JBoss provides a CDI implementation, you should import the needed CDI libraries using jboss-deployment-structure like made here: jboss-deployment-structure.xml.
Additionally, you should add a filter in web.xml (and remove PortletServlet, as it's being added automatically by Liferay). Take a look at the web.xml for JBoss in demo portlet for more info.
In order to make this easier, I would recommend using jsf-cdi portlet as a base for your first portlet so you can avoid this known issues when configuration isn't appropiate. Remember to use "jboss" Maven profile when building so all files are configured for JBoss.
Hope it helps!
I could make your custom annotations working using mentioned cdi-portlet demo as a base.
As what I saw in the provided web.xml, seems you're using this portlet in a Jboss app server. In case your JBoss provides a CDI implementation, you should import the needed CDI libraries using jboss-deployment-structure like made here: jboss-deployment-structure.xml.
Additionally, you should add a filter in web.xml (and remove PortletServlet, as it's being added automatically by Liferay). Take a look at the web.xml for JBoss in demo portlet for more info.
In order to make this easier, I would recommend using jsf-cdi portlet as a base for your first portlet so you can avoid this known issues when configuration isn't appropiate. Remember to use "jboss" Maven profile when building so all files are configured for JBoss.
Hope it helps!
Eric Chow, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Junior Member Publications: 79 Date d'inscription: 25/02/05 Publications récentes
Hi Juan,
Thanks for your testing. I am not using JBoss server but tested it in Liferay 7.0 + Tomcat.
The resource bundle cannot be injected into the backing bean? It always return null!
Best regards,
Eric
Thanks for your testing. I am not using JBoss server but tested it in Liferay 7.0 + Tomcat.
The resource bundle cannot be injected into the backing bean? It always return null!
Best regards,
Eric
Juan Gonzalez, modifié il y a 7 années.
RE: Customer @Annotation does not work in backing bean
Liferay Legend Publications: 3089 Date d'inscription: 28/10/08 Publications récentesEric Chow:
Hi Juan,
Thanks for your testing. I am not using JBoss server but tested it in Liferay 7.0 + Tomcat.
The resource bundle cannot be injected into the backing bean? It always return null!
Best regards,
Eric
Same sucessfull results in Liferay 7 + Tomcat.
As I said, please use our jsf-cdi applicant demo portlet as a base and write here your doubts/results.
Thanks!