Dialog framework doesn't work - jsf-2

i am trying to apply the basic sample for rendering a page inside a dialog as in the showcase
http://www.primefaces.org/showcase/ui/dialogFrameworkBasic.jsf
my web pages are under webapp/pages/general
i am running PrimeFaces-4.0-SNAPSHOT on Mojarra-2.1.20
i have two pages:
1- home.xhtml
2- viewreport.xhtml
1- home.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"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:p="http://primefaces.org/ui"
xmlns:pretty="http://ocpsoft.com/prettyfaces"
xmlns:sec="http://www.springframework.org/security/tags"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<title>Welcome</title>
<h:outputStylesheet library="css" name="style.css" />
</h:head>
<h:body dir="rtl">
<h:form>
<p:commandButton value="View" icon="ui-icon-extlink"
action="dialog:viewreport" />
</h:form>
</h:body>
</html>
2- viewreport.xhtml:
<!DOCTYPE html>
<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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:panelGroup id="report_details_new" layout="block" style="width:500px;height:500px;">
HELLO WORLD
</h:panelGroup>
</h:body>
</html>
when clicking on the button, nothing happens, i don't get any errors in eclipse console or in browser console.
please advise why the dialog framework is not working.

Solved by adding the following configuration to the faces-config.xml:
<action-listener>org.primefaces.application.DialogActionListener</action-listener>
<navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
<view-handler>org.primefaces.application.DialogViewHandler</view-handler>
tested on IE9,Chrome,Firefox for primefaces 4.0-SNAPSHOT

Related

Templates in primefaces mobile

How to create templates in primefaces mobile, since the root tag is f:view, and not the html.
The XML root element doesn't matter. It merely holds the XML name space declarations. The key is that you should have a <f:view renderKitId="PRIMEFACES_MOBILE"> in the master template. So the following kickoff example of the master template should work as good:
<f:view
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:pm="http://primefaces.org/mobile"
renderKitId="PRIMEFACES_MOBILE"
>
<ui:insert name="some" />
</f:view>
Template client looks just the same as usual:
<ui:composition template="/WEB-INF/template.xhtml"
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:pm="http://primefaces.org/mobile"
>
<ui:define name="some">
...
</ui:define>
</ui:composition>

InputText doesnt work in dialog with modal=true (Primefaces)

I have this issue, i think is a bug, i have a composite component with a simple inputtext, then i try to use my composite component in a modal dialog, at first look all it's ok, you can type inside the inputtext, but when the inputtext lost the focus and try to type again you cant, even you can't erase what you typed before.
In the issue tracker, there are a similiar problem reported:
LINK!!!!!
But this is with autocomplete not with input (maybe can be the same), but is marked as fixed, and i tried with PrimeFaces 3.3.1 and 3.4-SNAPSHOT but the problem persist.
Im using 3.4-SNAPSHOT
Here is a "reproducible test cases", i add an other input to my composite component for lost the focus more easily from first input.
Composite component:
<!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:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.org/ui">
<body>
<cc:implementation>
<p:commandButton value="Open dialog composite component" onclick="dialog.show()"/>
<p:dialog widgetVar="dialog">
<p:inputText/>
<p:inputText value="Click here for lost focus of the first input"/>
</p:dialog>
</cc:implementation>
</body>
</ui:composition>
test.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.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:mycomp="http://java.sun.com/jsf/composite/components"
xmlns:p="http://primefaces.org/ui"
xml:lang="es">
<f:view contentType="text/html">
<h:head>
</h:head>
<h:body>
<h:form id="myform">
<p:commandButton value="Open first dialog" onclick="firstDialog.show()"/>
</h:form>
<h:form id="myform2">
<p:dialog widgetVar="firstDialog" modal="true">
<mycomp:test />
</p:dialog>
</h:form>
</h:body>
</f:view>
</html>
I tried to replace p:inputText with h:inputText and the problem persist.
Im using:
MyFaces 2.1.8, Primefaces 3.4-SNAPSHOT

why does a4j:poll just work one time when I use it in my jsf page which is ui:defined with a template .xhtml

I create a template xhtml file which is like richfaces-showcase main.xhtml:
<!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:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j">
<f:view contentType="text/html">
<h:head>
<!-- Mimic Internet Explorer 8 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>My title</title>
</h:head>
<h:body>
<div id="page">
<ui:insert name="body">
Body content missed
</ui:insert>
</div>
</h:body>
</f:view>
</html>
And in sub page, I defined the "template body", and add an a4j:poll in my sub page, which I want to use to refresh the data every 5 seconds:
<!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:ui="http://java.sun.com/jsf/facelets" xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<ui:composition template="/templates/main.xhtml">
<ui:define name="body">
<h:form>
<a4j:poll id="poll" interval="5000" enabled="true" action="..." render="poll,grid" />
</h:form>
<h:form>
<h:panelGrid columns="2" width="80%" id="grid">
sorry, details forgot ...
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</html>
But the question is, when I open my sub page with IE8 in the localhost computer, the a4j:poll can refresh data once, and then it never get data again. when I open the sub page with IE6 or IE8 in other computer, it works fine! Can anybody find the reason out? Thanks in advance!!
I change the
<h:head>
<!-- Mimic Internet Explorer 8 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<title>My title</title>
</h:head>
to
<h:head>
<!-- Mimic Internet Explorer 7 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>My title</title>
</h:head>
and, it works now... but why?
I got it working with EmulateIE8. But probably when using it in an intranet way IE can be doing things differently.
Check your Browser mode and Document mode (press F12).
I got: IE9 / IE8 standards.

JSF .xcss styles not getting rendered

I'm using JSF2 and Richfaces 4.
I've added the following to my web.xml:
<mime-mapping>
<extension>xcss</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
I have an test.xcss file:
<?xml version="1.0" encoding="UTF-8"?>
<f:template xmlns:f="http:/jsf.exadel.com/template"
xmlns:u="http:/jsf.exadel.com/template/util"
xmlns="http://www.w3.org/1999/xhtml" >
<f:verbatim><![CDATA[
#content a:link[disabled]{ cursor: default;}
]]>
</f:verbatim>
<u:selector name="body">
<u:style name="background-color" skin="generalBackgroundColor" />
<u:style name="font-size" skin="generalSizeFont" />
<u:style name="font-family" skin="generalFamilyFont" />
</u:selector>
</f:template>
I load this test.xcss via my template.xhtml:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8" />
<f:view contentType="text/html">
<h:head>
<title>TEST</title>
<h:outputStylesheet library="css" name="test.xcss" />
</h:head>
<h:body>
</h:body>
</f:view>
</html>
Using firebug to view the content, the test.xcss is empty. Any ideas why it is not rendering the file correctly?
I suspect .xcss files are not supported in Richfaces 4, that ecss files are now used.
http://docs.jboss.org/richfaces/latest_4_0_X/Developer_Guide/en-US/html_single/#sect-Developer_Guide-Skinning_and_theming-What_are_skins
Found my answer:
http://community.jboss.org/wiki/RichFacesMigrationGuide33x-4xMigration-Skinning
.xcss not supported anymore, quite a bit of code migration to do now :(

JSF 2.0, "preRenderView" event handler called twice

I have the following snippet:
<?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">
<f:metadata>
<f:event type="preRenderView" listener="#{workflowController.test}"/>
</f:metadata>
<h:head>
<title>Simple JSF Facelets page</title>
</h:head>
<h:body>
Hello, Place your content here
</h:body>
</html>
When I open the page, the WorkflowController.test() method is called twice (it's just a simple method which makes a log entry). Do you know why it's being called twice?
Thanks.
Try to put the <f:event/> tag outside of the <f:metadata>, it worked for me (mojarra 2.1.0).

Resources