my p : dialog doesn´t work - primefaces

I´m using JSF2.0 and primefaces 3.4 in my web project
simply.... when I copy the code for p:dialog from show-case of
primefaces to my project, it doesn't work, the dialog window doesn't appear
(the first dialog I put is the real one I want in my page... but actually the problem is...)
It seems like something in my project is not working in the right way... I´m just copying the code from prime-faces show-case to my page, but in my page the commandButtons to show the p:dialogs don´t work, the p:dialog is not showed. This is the web page I tested and not work for me:
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="../template/template.xhtml">
<ui:define name="main">
<h:form id="form">
<h:panelGrid columns="1" cellpadding="5">
<p:commandButton id="basic" value="Basic" onclick="dlg1.show();" type="button" />
<p:commandButton id="modalDialogButton" value="Modal" onclick="dlg2.show();" type="button"/>
<p:commandButton id="effectsDialogButton" value="Effects" onclick="dlg3.show();" type="button" />
</h:panelGrid>
<p:dialog id="basicDialog" header="Basic Dialog" widgetVar="dlg1">
<h:outputText value="Resistance to PrimeFaces is futile!" />
</p:dialog>
<p:dialog id="modalDialog" header="Modal Dialog" widgetVar="dlg2" modal="true" height="100">
<h:outputText value="This is a Modal Dialog." />
</p:dialog>
<p:dialog header="Effects" widgetVar="dlg3" showEffect="explode" hideEffect="bounce" height="100">
<h:outputText value="This dialog has nice effects." />
</p:dialog>
</h:form>
</ui:define>
</ui:composition>
</html>

Where's your code showing the dialog? Something similar to
<p:commandButton id="button" value="Open Dialog" oncomplete="PF('dialog').show();"/>

Related

PF10 Primefaces p:breadcrumb doesn't show separators among items

Environment:
Jboss 7.2
Java 22
JSF 2.3
Primefaces 10
PF Themes Avalon, ui-lightness
I've migrated from PF8 to PF10 and p:breadcrumb doesn't show separators among menu items. Is there some incompatibility with PF10 and some themes?
Basic breadcrumb
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form>
<div class="card">
<p:breadCrumb>
<p:menuitem value="Electronics"/>
<p:menuitem value="Computer"/>
<p:menuitem value="Notebook"/>
<p:menuitem value="Accessories"/>
<p:menuitem value="Backpacks"/>
<p:menuitem value="Item"/>
</p:breadCrumb>
</div>
</h:form>
</h:body>
</html>
You need a new Avalon theme from your PrimeStore account that is updated for PF10.0.0.
According to this page Avalon is complete and should be in your PrimeStore account for download: https://github.com/primefaces/primefaces/wiki/Updates-Of-Premium-Templates-For-PrimeFaces-X

primefaces: selectonemenu does not open on all pages

I am new to primefaces and already facing problems with the "selectOneMenu" component. I have implemented a mainMenu.xhtml file, which is visible on all my pages. This mainmenu has a "selectOneMenu" component for language Change. The "selectOneMenu" does not open on the start page and several other pages, but there are also pages where it opens and works as it should. I've searched the net for a couple of days now, and couldn't find any hint or suggestion, that solved my Problem.
Would be very nice to find some help here.
See code below: Identity_Session is a #SessionScoped-bean; The "languageSet" is a HashMap of (String, Integer) pairs.
<?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:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
</h:head>
<h:body>
<h:form>
<p:panel>
<h:panelGrid columns="2" cellpadding="5" style="right: 700px; position: absolute; margin-top: -7px;" rendered="#{identity_Session.showMenuLogout()}">
<p:outputLabel for="languageComboBox" value=" #{identity_Session.translate('outputlabel_language')}:" style="font-weight:bold"/>
<p:selectOneMenu id="languageComboBox" value="#{identity_Session.languageID}" style="width:150px">
<p:ajax listener="#{identity_Session.translationAction()}" update="#all" delay="1000"/>
<f:selectItems value="#{identity_Session.getLanguageSet()}" />
</p:selectOneMenu>
</h:panelGrid>
</p:panel>
</h:form>
<br/>
<br/>
</h:body>
</html>
UPDATE!!!
I am using the same selectOneMenu with the same values (as described above) on the same webPage. When I place the selectOneMenu in the "west"-layoutUnit it does not open, but when I place it in the "east"-layoutUnit it opens. Is this actually a "PrimeFaces"-Bug, or am I missing something?
Try to change
</f:panel>
to
</p:panel>

Eclipse: format JSF/XHTML/HTML/... files with each attribute on same line, but column-wise

In Eclipse, I find no way to format code the way I need to for JSF, XHTML, HTML or XML files like can be configured for Java.
I have found the following part-solutions:
JSF Code formatter or Eclipse XML Editor, each tag for new line?
However, just placing attributes on the next line, indenting them by one is not enough:
<p:spinner
id="multi-trade-adjust-count"
value="#{bulkTradeManager.count}"
title="Number of trades to create"
maxlength="2"
size="1"
min="1"
max="50"
styleClass="bx-spinner mb-5px"
style="width: 60px;">
<p:ajax
listener="#{bulkTradeManager.onCountChange}"
process="#this"
update=":content-form:data-panel" />
</p:spinner>
I am so unhappy with it, that I end up using no JSF formatters at all. What I'm desparately looking for is a result like this:
<?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">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:of="http://omnifaces.org/functions"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">
<p:dataTable id="multi-data-add"
value="#{bulkTradeManager.dataModel}"
var="trd"
rowIndexVar="rowIndex"
rowKey="#{trd.id}"
editable="true"
editMode="cell"
rowStyleClass="#{bulkTradeManager.lastNonRemovableIndex le rowIndex ? 'ui-state-highlight' : ''}"
styleClass="mb-10px mr-10px">
<p:ajax event="cellEdit"
listener="#{bulkTradeManager.onCellEdit}"
update=":content-form:msgs" />
<p:ajax event="sort" />
<p:column headerText="#{msg['common.active.header']}"
rendered="#{bulkTradeManager.showingConstantColumns}"
styleClass="text-center">
<h:outputText value="#{trd.active ? msg['common.yes.label'] : msg['common.no.label']}" />
</p:column>
<p:column headerText="#{msg['entity.trade.transactionNbr.shortHeader']}"
rendered="#{bulkTradeManager.showingConstantColumns}">
<h:outputText value="#{trd.transactionNbr}" />
</p:column>
<p:column headerText="#{msg['entity.trade.referenceNbr.shortHeader']}"
sortBy="#{trd.referenceNbr}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{trd.referenceNbr}" />
</f:facet>
<f:facet name="input">
<p:inputText id="reference-number-input"
value="#{trd.referenceNbr}"
styleClass="width-190px" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{msg['entity.trade.quantity.header']}/#{msg['common.nominal.header']}*"
sortBy="#{trd.quantity}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{trd.quantity}">
<f:convertNumber maxIntegerDigits="126" pattern="#,###,##0.########" />
</h:outputText>
</f:facet>
<f:facet name="input">
<p:inputText id="quantity-input"
value="#{trd.quantity}"
required="false"
requiredMessage="#{msg['entity.trade.quantity.requiredMessage']}"
maxlength="50"
styleClass="width-190px">
<pe:keyFilter regEx="/[0-9,.]/i" />
<f:convertNumber maxIntegerDigits="126" pattern="#,###,##0.########" />
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
...
This means, on top of the option "Split multiple attributes each on a new line", at least two sub options need to be present to produce this:
[✓] Split multiple attributes each on a new line
[✓] Leave first attribute on the same line as the opening tag
[✓] Align attributes column-wise
Q:
Does anything like this exist?
Maybe a JSF formatter plugin? Maybe there are some hacks via the config files?
Addendum:
As it stands now, JSF, XHTML, XML, HTML etc. formatting is a somewhat incomplete feature, at least the long-term solution would be to offer a configuration that is more like the Java code formatters where almost anything can be configured.
I'd even be tempted to contribute to the Eclipse community, if it's not overly hard to implement the two check boxes described. At least, leaving the first attribute on the same line and using the second character's column index after the opening tag and taking it for all subsequent attributes as indent seems doable to me...

JSF not showing data from database

I'm trying to show data from mysql database in JSF, but nothing show up. Getting page with table without data. I'm using http://www.devmanuals.com/tutorials/java/jsf/database/viewdata.html tutorial
index.xhtml :
<?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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
>
<h:head>
<title>index.xhtml</title>
</h:head>
<h:body>
<h1>JSF 2.0 View Data From The Database Table Example</h1>
<h:dataTable value="#{UserBean.getUserList()}" var="u" border="1">
<h:column>
<f:facet name="header">
User ID
</f:facet>
#{u.userID}
</h:column>
<h:column>
<f:facet name="header">
Name
</f:facet>
#{u.name}
</h:column>
<h:column>
<f:facet name="header">
Address
</f:facet>
#{u.address}
</h:column>
<h:column>
<f:facet name="header">
Created Date
</f:facet>
#{u.created_date}
</h:column>
</h:dataTable>
</h:body>
</html>
It seems you've just mistyped the managed-bean's name in your view when using within the <h:dataTable>'s tag. You should render its first letter lowercase to enable the proper use, i.e from value="#{UserBean.getUserList()}" to value="#{userBean.getUserList()}".

p:editor visible in chrome but not rendered properly in IE

The editor doesn't appears in my IE window while it works correctly in chrome
I have implemented p:layout and in the center layoutunit I am including the template.xhtml using ui:include which is enclosed in a
<h:form id="centercontentpanel">
Kindly guide me with what corrections needs to be done to make it visible in IE 8
Template.xhtml
<?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:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:body>
<f:view>
<p:editor id="editor" value="#{editorBean.value}"/>
<h:panelGrid columns="2" style="margin-top:10px">
<p:commandButton id="submitButton" value="Submit" update="display" oncomplete="editordlg.show()"
icon="ui-icon-disk" />
<p:commandButton id="clearButton" type="button" value="Clear" onclick="editor.clear()"
icon="ui-icon-close"/>
</h:panelGrid>
<p:dialog header="Content" widgetVar="editordlg" showEffect="fade" hideEffect="fade" modal="true">
<h:outputText id="display" value="#{editorBean.value}" escape="false" />
</p:dialog>
</f:view>
</h:body>
</html>
For all i know, the IE 8 doesn't support Primefaces Editor, still in IE 11.
Actually i can render it, but nothing works, not even the bold/italic/underline.
I think it's because the way IE process javascript... but i don't know much about technical issues.
(My tests were done on IE 11 and Primefaces 4.0, plain programming, didn't twitch anything)
Only for the RichText i'm using the HTML5 library wysihtml5 (GIT)
EDIT:
I'm sorry, i just stumbled on the answear to my problem (Editing on IE), hope it fixes yours
Just add contentType="text/html" to the <f:view> like this <f:view contentType="text/html">
Here is the post from Optimus (Even though it's a rendering problem for chrome)