Composition is not rendered in Richfaces tabPanel - java

I am a user of JSF and Richfaces. I will simplify the code about my question to make things easier.
I have a composition named 'mytab.xhtml' defined like following:
<cc:interface>
<cc:attribute name="header" required="true"/>
</cc:interface>
<cc:implementation>
<rich:tab id="my-tab" header="#{cc.attrs.header}" >
<cc:insertChildren />
</rich:tab>
</cc:implementation>
This composition is used in another xhtml file like following:
<rich:tabPanel id="tp" switchType="ajax" headerPosition="top" >
<ic:mytab id="tab1" header="header1">
<h:outputText>content1</h:outputText>
</ic:mytab>
<ic:mytab id="tab2" header="header2">
<h:outputText>content1</h:outputText>
</ic:mytab>
</rich:tabPanel>
But it is very strange that the tab is not rendered at all.
To find the reason, if I add an outputText in the composition definition file like this:
<cc:interface>
<cc:attribute name="header" required="true"/>
</cc:interface>
<cc:implementation>
<h:outputText>#{cc.attrs.header}</h:outputText>
<rich:tab id="my-tab" header="#{cc.attrs.header}" >
<cc:insertChildren />
</rich:tab>
</cc:implementation>
The outputText will be rendered, but tab is not rendered.
Or, if I change one of the tab to richfaces tab directly:
<rich:tabPanel id="tp" switchType="ajax" headerPosition="top" >
<ic:mytab id="tab1" header="header1">
<h:outputText>content1</h:outputText>
</ic:mytab>
<rich:tab id="tab2" header="header2">
<h:outputText>content1</h:outputText>
</rich:tab>
</rich:tabPanel>
The first tab will not be rendered, but the second tab will be rendered.
Thank you if you could give me any help.

Composite components are rendered as own UINamingContainer. So between the UITabPanel and the UITab-component now is a UINamingContainer, UITab might not know what to do with it (same problem with datatable, by the way). What you can do is to use a classic facelet tag instead.

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;

JSP markup inside <tiles:put> or a or an alternative

I've inherited an old application that is using Struts 1.2 Tiles 1. For various annoying reasons I can't upgrade.
I'm not very familiar with Struts, or specifically Tiles in general and I'm trying to do something that makes sense in my head but I can't seem to make work in practice. Here's an example of what I'm trying to accomplish:
<tiles-definition>
<definition name="content-with-sidebar" path="/content_with_sidebar.jsp">
<put name="top" value="" type="string" />
<put name="sidebar" value="/tiles/sidebar.jsp" />
<put name="main" value="" type="string" />
<put name="bottom" value="" type="string" />
</definition
</tiles-definition>
content_with_sidebar.jsp
...
<tiles:insert attribute="top" flush="false" />
<div id="content">
<aside>
<tiles:insert attribute="sidebar" flush="false" />
</aside>
<div id="main">
<tiles:insert attribute="main" flush="false" />
</diV>
</div>
<tiles:insert attribute="top" flush="false" />
...
actual_page.jsp
<tiles:insert definition="content-with-sidebar" flush="false">
<tiles:put name="top" type="string">
<div>Maybe this page has something on the top that isn't the page header</div>
</tiles:put>
<!-- use the default sidebar -->
<tiles:put name="main">
<strong>Current Location:</strong>
<address><h:outputText value="#{locationDesc} #{zipCode}" /></address>
<!-- Some more dynamic jsp markup -->
</tiles:put>
<!-- This one doesn't have anything extra on the bottom -->
</tiles:insert>
This almost works but the dynamic bits get rendered above and outside the <tiles:insert> and the plain strings go where they should. I understand now, after much searching, that <tiles:put> in this, er, context, is expecting a plain ole string.
Is there a pattern to accomplish what I want with dynamic context?
As it stands I'm having to create another jsp file to be referenced by the <tiles:put> tag. i.e.
<tiles:put name="main" value="/actual_page_body.jsp" />
I'd rather not have to create an additional file when one would do. Any advice would be helpful.
With tiles, when the definition is rendered (content-with-sidebar in your code), the jsp corresponding to the 'path' attribute (/content_with_sidebar.jsp) will be invoked. All other jsps have to be manually invoked using a <tiles:insert>. What tiles provides you is a way to configurationally invoke them as definition attributes.

Javabean validation error inside JSF/PrimeFaces dialog

Recently I have update my application to JSF 2.1.7 and PrimeFaces 3.4.2. When the below dialog is used for adding a new group, I get an "Name size must be between 1 and 40" validation error, prior to saving the new group. It happens when I click the picker's add button. I understand that this message is shown because the validation failed. The validation error doesn't appear when I add immediate=true to p:commandButton. I don't know what triggered the validation.
<h:form id="formg" prependId="false">
<!-- messages -->
<p:growl id="msgsg" showDetail="true" />
<!-- data table -->
<ui:include src="/WEB-INF/flows/groupsTable.xhtml" />
<p:separator />
<!-- bottom tool bar -->
<ui:include src="/WEB-INF/flows/groupsToolBar.xhtml" />
<!-- preview, edit dialog -->
<ui:include src="/WEB-INF/flows/groupsDialog.xhtml" />
</h:form>
<p:dialog id="dialogg" header="#{groupsBean.dialogTitle}"
widgetVar="groupsDialog" dynamic="true" resizable="false" width="800"
height="600" showEffect="fade" hideEffect="fade" modal="true">
<p:ajax event="close" listener="#{groupsBean.refresh}"
immediate="true" update=":formg" global="false" process="#this" />
<p:tabView id="tabPicker">
<p:tab title="General">
<h:panelGrid id="displayg" columns="2">
<h:outputText value="#Group name*:" />
<p:inputText value="#{groupsBean.selectedGroup.name}" size="40"
readonly="#{!groupsBean.updatable}" maxlength="40" />
</h:panelGrid>
</p:tab>
<p:tab title="Members">
<ui:include src="/WEB-INF/custom/picker.xhtml">
... some params passed to picker
</ui:include>
</p:tab>
</p:tabView>
</p:dialog>
The picker is similar to <p:password> and it is made up from two p:dataTable components and 4 buttons between them. The buttons are grouped together with a h:panelGrid. The button attributes are similar. Here is button sample code:
<p:outputPanel autoUpdate="true">
<p:commandButton actionListener="#{eval.evaluateAsMethod(pickerAdd)}"
update="source, target, #{messages}" immediate="true"
disabled="#{pickerSourceDisabled}"
icon="ui-icon ui-icon-arrowthick-1-s" />
</p:outputPanel>
source, target are the ids of the two datatables. pickerAdd is passed as param with a value of groupsBean.picker.add. The tables contain FooDomain objects.
public class FooDomain implements Serializable {
...
#NotNull
#Size(min = 1, max = 40)
#Column(name = "NAME")
private String name;
...
}
The PrimeFaces <p:commandButton> processes by default the entire form (as in, process="#form"), so it would by default trigger all validations. Your validation error is coming from the #Size restriction on the property. If you would like to process only the button's own action, then you should add process="#this".
<p:commandButton ... process="#this" />
The immediate="true" can also be used to solve it, but it behaves under the covers somewhat different: the entire form is still processed, but the action is invoked in APPLY_REQUEST_VALUES phase instead of INVOKE_ACTION phase. And only the input components which also have immediate="true" set will also be processed and others will be skipped.

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.

Primefaces 3.0 : TreeNode and ContextMenu

In my application, I have a tree with various object types (sources, tables, etc).
I'd like to enable a context menu for the different types of object (add, delete, edit etc).
How can I use context menu on tree nodes in Primefaces ?
Never did it in practice (I am still on Primefaces 2.x), but from theory the facelet code should look something like this:
<h:form>
<p:tree value="#{myBean.tree}" var="node" id="tree"
selectionMode="single" selection="#{myBean.selectedNode}">
<p:treeNode>
<h:outputText value="#{node}" />
</p:treeNode>
</p:tree>
<p:contextMenu for="tree" id="menu">
<p:menuitem value="Add" actionListener="#{myBean.add}" />
...
</p:contextMenu>
</h:form>
Usage of p:contextMenu and p:tree is shown in Primefaces showcase.

Categories

Resources