Cant find resource bundle messages - java

This question is very similar (if not the same as):
"Can't find bundle for base name messages" error
ResourceBundle [messages] not found for MessageSource: Can't find bundle for base name messages
Basically, i have this code:
<body>
<f:view>
<f:loadBundle basename="de.vogella.jsf.starter.messages" var="msg" />
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="#{msg.user}"></h:outputLabel>
<h:inputText value="#{user.name}">
<f:validator
validatorId="de.vogella.jsf.starter.validator.LoginValidator" />
</h:inputText>
<h:outputLabel value="#{msg.password}"></h:outputLabel>
<h:inputSecret value="#{user.password}">
</h:inputSecret>
</h:panelGrid>
<h:commandButton action="#{user.login}" value="#{msg.login}"></h:commandButton>
<h:messages layout="table"></h:messages>
</h:form>
</f:view>
And when I try to run, I get
An exception occurred processing JSP page /LoginView.jsp at line 13
10: </head>
11: <body>
12: <f:view>
13: <f:loadBundle basename="de.vogella.jsf.starter.messages" var="msg" />
14: <h:form>
15: <h:panelGrid columns="2">
16: <h:outputLabel value="#{msg.user}"></h:outputLabel> Stacktrace:
Caused by:
java.util.MissingResourceException - Can't find bundle for base name de.vogella.jsf.starter.messages, locale en`
I tried to change file name, change file name in code, adding resource folder (but I think it was already properly included), and putting messages.properties file in all possible folders. Curiously, eclipse itself shows this error, it also has empty suggestion boxes for basename (no default proposals).
In case it helps, my project structure:
http://imgur.com/3eAxWo3

Can you confirm if you have message.properties file in the directory de.vogella.jsf.starter?
If not please add the message.properties in this directory and then compile all. Check if you still get the exception?

I too faced the same issue.
But finally, if you keep the messages.properties file under any package(de.vogella.jsf.starter.model) and include this as follows:
< f:loadBundle basename="de.vogella.jsf.starter.model.messages" var="msg" />
It is Working.

Related

/welcomePrimefaces.xhtml #18,39 <p:layout> Tag Library supports namespace: http://primefaces.org/ui, but no tag was defined for name: layoutl

I was writing the first entity class in the entity package but I didn't want to delete te WelcomePrimefaces because I want to use it to try how to use some codes in it. The WelcomePrimefaces was working well but after I wrote the first Entity Class WelcomePrimeces didn't work.
I get this...
/welcomePrimefaces.xhtml #18,39 <p:layout> Tag Library supports namespace: http://primefaces.org/ui, but no tag was defined for name: layout
I have not change the code it gives me from the begining so I would like to know what is happening here.
this is the code from 18 line.
<p:layout fullPage="true">
<p:layoutUnit position="north" size="100" resizable="true" closable="true" collapsible="true">
Header
</p:layoutUnit>
<p:layoutUnit position="south" size="100" closable="true" collapsible="true">
Footer
</p:layoutUnit>
<p:layoutUnit position="west" size="175" header="Left" collapsible="true">
<p:menu>
<p:submenu label="Resources">
<p:menuitem value="Demo" url="http://www.primefaces.org/showcase-labs/ui/home.jsf" />
<p:menuitem value="Documentation" url="http://www.primefaces.org/documentation.html" />
<p:menuitem value="Forum" url="http://forum.primefaces.org/" />
<p:menuitem value="Themes" url="http://www.primefaces.org/themes.html" />
</p:submenu>
</p:menu>
</p:layoutUnit>
<p:layoutUnit position="center">
Welcome to PrimeFaces
</p:layoutUnit>
</p:layout>
I was expecting netbeans show me the error in the firt Entity Class I was doing, not the error in WelcomePrimefaces.
I alredy have the pool conexion well done to the database with Mysql and persistence with EclipseLink
I am using netbeans 15
Layout was removed in PF 10.0.0 see: ticket: https://github.com/primefaces/primefaces/issues/2168
You can use Layout from PrimeFaces Extensions: https://www.primefaces.org/showcase-ext/views/layout.jsf;

Dynamic JSF UI Components Generation

I'm trying to solve the following problem:
Let's say that I have a settings.xml file that looks as follows:
<SETTINGS>
<username fieldType="TextField" possibleValues="*">username_value</username>
<roletype fieldType="DropDownList" possibleValues="normal,admin,agent">admin</roletype>
<active fieldType="RadioButtons" possibleValues="true,false">true</active>
<SETTINGS>
What I'm trying to achieve is the following:
1- When my page first loads, it will parse this xml file, and layout the UI components based on the fieldType and the possibleValues.
2- When my UI components are loaded, I should be able to configure the value of my fields, which will end up persisting in my settings.xml file.
Is there a ready library that does this? Or do I need to write the code for this myself?
Note: I'm restricted to using JSF 1.x
Thanks in advance.
First of all , i will recommend to change the structure of your XML file as:
<SETTINGS>
<controls>
<control label="username" fieldType="TextField">
<values></values>
<selvalue></selvalue>
</control>
<control label="roletype" fieldType="DropDownList">
<values>
<value>normal</value>
<value>admin</value>
<value>agent</value>
</values>
<selvalue></selvalue>
</control>
<control label="active" fieldType="RadioButtons">
<values>
<value>true</value>
<value>false</value>
</values>
<selvalue></selvalue>
</control>
Now use JAXB to parase this XML file to the different classed, where each xml tab will be act as one independent class.
like :
Settings :
private List<Control> controls;
Control :
String label; // Attribute
String fieldType; // Attribute
Values values; //Property
String selValue; //Property
Values :
List<Value> values; ////Property
Value :
String value; //Property
DynaCritSearchBean : A Bean Class
Settings settings;
Once the data is loaded in to the corresponding class, use the following logic to dynamically create the screen in your XHTML file :
<h:panelGrid>
<c:forEach var="control"
items="#{dynaCritSearchBean.settings.controls}">
<h:panelGroup>
<h:outputText value="#{control.label}" />
</h:panelGroup>
<h:panelGroup>
<c:choose>
<c:when test="#{control.fieldType eq 'TextField'}">
<h:inputText value="#{control.selvalue}" />
</c:when>
<c:when test="#{control.fieldType eq 'DropDownList'}">
<h:selectOneMenu value="#{control.selvalue}">
<f:selectItem itemValue="" itemLabel="--select--" />
<c:forEach var="selOneValue" items="#{control.values.values}">
<f:selectItem itemValue="#{selOneValue}"
itemLabel="#{selOneValue}" />
</c:forEach>
</h:selectOneMenu>
</c:when>
<!-- Same as above logic for Radio button -->
</c:choose>
</h:panelGroup>
</c:forEach>
</h:panelGrid>
Once you submit the form, all selected/entered values are set to corresponding selValue of each Control.
Now, in order to get the XML back, you can use same JAXB concept which is very simple.

JSF: p:dataTable with f:attribute results in "argument type mismatch" error

I want to add conditionally add some arguments to a p:dataTable like described in Conditionally render element's attribute in a composite component. But even without the c:if I get an java.lang.IllegalArgumentException: argument type mismatch (Stacktrace on pastebin).
...
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
...
<p:dataTable var="r" value="#{myBean.values}" >
<f:attribute name="paginator" value="true" />
</p:dataTable>
The error does not occur (and the paginator is available) if I add the attribute directly <p:dataTable ... paginator="true">.
My environment is Primefaces 3.4.1 with JBoss 7.1.1-Final.
Try passing it as EL object:
<f:attribute name="paginator" value="#{true}" />

Output key to localized message returning 0

I'm trying to output a key to a localized message in a jsp template in the following way:
<c:set var="logo-tooltip-title">
<fmt:message key="logo.tooltip.title"/>
</c:set>
<c:out value="${logo-tooltip-title}"/>
With the following in my messages.properties file:
logo.tooltip.title=Test
Does anyone know what I'm doing wrong here? Why does it return 0 instead of Test?
My goal is to output that message as title of the following link:
<a class="logo" href="/site/" title="${logo-tooltip-title}">
<img src="<hst:link path="/img/logo.png"/>" alt="logo" class="headlogo" width="80" height="100" />
</a>
Any thoughts on the best approach to do this?
Thanks!
EDIT:
yes I have set the context param in web.xml:
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>messages</param-value>
</context-param>
resource
Update:
This seems to work:
<fmt:message key="logo.tooltip.title" var="tooltip"/>
<c:out value="${tooltip}"/>
I don't think your problem is specific to HippoCMS.
I tried your syntax and I think you're missing a bundle declaration. If I add an org/ecausarano/Example.properties file to the war resources and:
<fmt:setBundle basename="org.ecausarano.Example" />
<c:set var="message">
<fmt:message key="message.message" />
</c:set>
<c:out value="${message}" />
it works for me.
JSTL tries to do math for "logo - tooltip - title" which results in 0. You've already found out that replacing the - by . solved the issue.

PrimeFaces 3.0 - Need fix or workaround for <p:calendar> 'add 6 years' defect

This question is mainly directed at the PrimeFaces dev team but maybe someone else knows a workaround. I can't upload screenshots on the PrimeFaces support forums but I can link to my question here.
Reported as a defect in PrimeFaces issue tracker. Add a star to cast your vote for the PrimeFaces development team to fix this: link to defect in their issue tracker
Discussed here in PrimeFaces support forum.
Still exists in PrimeFaces 3.0-M3-SNAPSHOT
PROBLEM:
I'm using the PrimeFaces 3.0 <p:calendar> control to allow the user to view and edit Date objects that contain both date and time. There appears to be some defect in the JavaScript control that causes it to add some strange offset to the date somewhere in the vicinity of +6 years.
I have setup some code to demonstrate the problem.
In the first <p:calendar> I use a managed bean Date that is initially null. The control is ok with that. It will open and set the initial value to the current date with hour/minute/second zeroed. I can use the sliders to set the hours, minutes and seconds normally.
In the second <p:calendar> I use a managed bean Date that is initially set to new Date(). This will create a new Date object set to the current server time. The control is not ok with that. Although the date/time displayed in the <p:calendar> box looks correct initially, it will be modified to some bizarre value in the future when the JavaScript picker control is opened. On closing the picker control the date on the managed bean is set to the bizarre value.
Another problem that may or may not be related is when I try to use a custom format for the date:
ddHHmm'Z'MMMyy
This format is used by my customer in their domain and I need to support it somehow. The <p:calendar> JavaScript picker will not even open when I try to click on the box. Something about the pattern (which works just fine in Java SimpleDateFormat) breaks it. The PrimeFaces documentation is silent on this.
QUESTION: Does anyone have any workaround for these <p:calendar> issues?
UPDATE - source code:
The composite component that wraps the <p:calendar>:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface
displayName="calendar"
shortDescription="Wrapper for a PrimeFaces p:calendar">
<composite:attribute
name="dateValue"
displayName="dateValue"
type="java.util.Date"
required="true"
shortDescription="EL expression that evaluates to a java.util.Date on a backing bean" />
<composite:attribute
name="pattern"
displayName="pattern"
type="java.lang.String"
default="dd/MM/yyyy HH:mm:ss"
shortDescription="Pattern used to format the underlying Date value. See SimpleDatePattern class documentation for pattern syntax. NOTE: p:calendar does not appear to support some complex patterns." />
<composite:attribute
name="ajaxRenderTargets"
displayName="ajaxRenderTargets"
type="java.lang.String"
default="#none"
shortDescription="Space-separated list of element ids that need to be rendered by Ajax when the calendar value changes. See f:ajax render attribute documentation." />
<composite:attribute
name="tooltip"
displayName="tooltip"
type="java.lang.String"
default=""
shortDescription="String to be used as the tooltip for this component" />
<composite:attribute
name="label"
displayName="label"
type="java.lang.String"
default=""
shortDescription="Label for this component. May be used in FacesMessages." />
<composite:attribute
name="required"
displayName="required"
type="java.lang.Boolean"
default="false" />
</composite:interface>
<composite:implementation>
<p:calendar
id="pCalendarInsideCC"
value="#{cc.attrs.dateValue}"
pattern="#{cc.attrs.pattern}"
readOnlyInputText="true"
showButtonPanel="false"
popupIconOnly="false"
showOn="focus"
mode="popup"
navigator="true"
pages="1"
showOtherMonths="true"
selectOtherMonths="false"
alt="#{cc.attrs.tooltip}"
title="#{cc.attrs.tooltip}"
required="#{cc.attrs.required}"
label="#{cc.attrs.label}">
<p:ajax
event="valueChange"
update="#{cc.attrs.ajaxRenderTargets}" />
<p:ajax
event="change"
update="#{cc.attrs.ajaxRenderTargets}" />
</p:calendar>
</composite:implementation>
</html>
The page containing the composite component references:
<ui:composition template="/templates/primefaces/masterLayout.xhtml">
<ui:param name="title" value="#{bundle.primeFacesCalendarCC_description}" />
<ui:define name="content">
<h:form id="contentForm">
<h:panelGrid columns="3">
<h:outputText
value="Initially empty Date reference on managed bean" />
<sandbox:primeFacesCalendar
id="calendarCC1"
dateValue="#{primeFacesTestBean.userSubmittedDateTime}"
ajaxRenderTargets="messagesCalendar1 :ajaxRenderTargetsInTemplate"
required="true" />
<p:messages
id="messagesCalendar1"
showSummary="false"
showDetail="true" />
<h:outputText
value="A 'new Date()' reference on managed bean" />
<sandbox:primeFacesCalendar
id="calendarCC2"
dateValue="#{primeFacesTestBean.newDateInstance}"
ajaxRenderTargets="messagesCalendar2 :ajaxRenderTargetsInTemplate"
required="true" />
<p:messages
id="messagesCalendar2"
showSummary="false"
showDetail="true" />
<h:outputText
value="Initially empty Date using ddHHmm'Z'MMMyy pattern" />
<sandbox:primeFacesCalendar
id="calendarCC3"
dateValue="#{primeFacesTestBean.userSubmittedDateTime}"
ajaxRenderTargets="messagesCalendar2 :ajaxRenderTargetsInTemplate"
pattern="ddHHmm'Z'MMMyy"
required="true" />
<p:messages
id="messagesCalendar3"
showSummary="false"
showDetail="true" />
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
<ui:composition template="/templates/primefaces/masterLayout.xhtml">
<ui:param name="title" value="#{bundle.primeFacesCalendarCC_description}" />
<ui:define name="content">
<h:form id="contentForm">
<h:panelGrid columns="3">
<h:outputText
value="Initially empty Date reference on managed bean" />
<sandbox:primeFacesCalendar
id="calendarCC1"
dateValue="#{primeFacesTestBean.userSubmittedDateTime}"
ajaxRenderTargets="messagesCalendar1 :ajaxRenderTargetsInTemplate"
required="true" />
<p:messages
id="messagesCalendar1"
showSummary="false"
showDetail="true" />
<h:outputText
value="A 'new Date()' reference on managed bean" />
<sandbox:primeFacesCalendar
id="calendarCC2"
dateValue="#{primeFacesTestBean.newDateInstance}"
ajaxRenderTargets="messagesCalendar2 :ajaxRenderTargetsInTemplate"
required="true" />
<p:messages
id="messagesCalendar2"
showSummary="false"
showDetail="true" />
<h:outputText
value="Initially empty Date using ddHHmm'Z'MMMyy pattern" />
<sandbox:primeFacesCalendar
id="calendarCC3"
dateValue="#{primeFacesTestBean.userSubmittedDateTime}"
ajaxRenderTargets="messagesCalendar2 :ajaxRenderTargetsInTemplate"
pattern="ddHHmm'Z'MMMyy"
required="true" />
<p:messages
id="messagesCalendar3"
showSummary="false"
showDetail="true" />
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
The managed bean:
#ManagedBean(name="primeFacesTestBean")
#SessionScoped
public class PrimeFacesTestBean implements Serializable {
private static final long serialVersionUID = 1L;
private Date userSubmittedDateTime = null;
private Date newDateInstance = new Date();
public void setUserSubmittedDateTime(Date userSubmittedDateTime) {
this.userSubmittedDateTime = userSubmittedDateTime;
}
public Date getUserSubmittedDateTime() {
return userSubmittedDateTime;
}
public void setNewDateInstance(Date newDateInstance) {
this.newDateInstance = newDateInstance;
}
public Date getNewDateInstance() {
return newDateInstance;
}
public void calendarValueChangeHandler(AjaxBehaviorEvent event) {
//System.out.println("calendar value has been changed (Ajaxified)");
}
}
Fixed as of August 18th in 3.0-M3-SNAPSHOT:
http://code.google.com/p/primefaces/issues/detail?id=2215
Confirmed that it works correctly in my webapp using the 3.0-M3-SNAPSHOT of August 23rd.
NOTE: The custom format issue was not covered in this defect. I'm not sure if that is fixed or still a problem.

Categories

Resources