I´m trying to upload some files with the richfaces fileupload.
This is my .xhtml:
<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:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head></h:head>
<h:body>
<ui:composition
template="/WEB-INF/templates/application/main-template.xhtml">
<ui:define name="contentheader">
<h:outputText value="#{messages.incoming_malfunction_header}" />
</ui:define>
<h:form id="controls_form">
<ui:define name="contentbody">
<rich:fileUpload maxFilesQuantity="2" immediateUpload="true"
fileUploadListener="#{isiDataTransferPM.uploadListener}"
listWidth="280px">
<a4j:ajax event="uploadcomplete" render="controls_form" />
</rich:fileUpload>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
This is my uploadeListener:
public void uploadListener(FileUploadEvent event) throws Exception {
final UploadedFile item = event.getUploadedFile();
if (selectedEntity.equals(ENTITY_WORK)) {
//addToList
}
This is my web.xml config:
<context-param>
<param-name>org.richfaces.fileUpload.maxRequestSize</param-name>
<param-value>10000000</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.fileUpload.createTempFiles</param-name>
<param-value>true</param-value>
</context-param>
I use the following libraries:
jboss-jsf-api_2.1_spec-2.0.7.Final-redhat-1.jar
richfaces-components-ui-4.2.3.Final.jar
richfaces-components-api-4.2.3.Final.jar
richfaces-core-api-4.2.3.Final.jar
richfaces-core-impl-4.2.3.Final.jar
Debbuging the code shows, that the listener is called. But after calling this listener,the progress bar of the fileupload shows still 0 %. Nothing happens anymore.
Any Ideas.
Thanks
Related
I'm having this really weird issue where my commandLinkonly work if I have BOTH links in the same view.
Works fine, both links:
<ui:composition template="../../template.xhtml" 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"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:define name="content">
<h:form>
<p:dataTable var="v" value="#{myBean.myList}">
<p:column headerText="Name">
<h:commandLink value="Go to next page" action="#{myBean.doThing(v)}" />
<p:commandLink value="Go to next page" action="#{myBean.doThing(v)}" />
</p:column>
</p:dataTable>
<p:commandButton value="Submit" ajax="false" actionListener="#{myBean.submit}" />
</h:form>
</ui:define>
</ui:composition>
But if I remove either link, it doesn't even reach the method doThing() and reloads an empty page.
My bean:
#ManagedBean(name="myBean")
#RequestScoped
public class MyBean {
private List<Object> myList = new ArrayList<>();
public MyBean() {
}
public String doThing(Object obj) {
// This never prints if I remove one of the links
System.out.println("You're doing the thing!");
return "nextView?faces-redirect=true"
}
// Getters, setters etc.
}
I'm using JSF 2.0 and GlassFish 4.0.
How can I fix this and why is it happening?
I have a commandLink in a p:dataTable in another view and it's working fine.
EDIT:
Added the complete XML for the composition part of the view. The partial is inside a template:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<h:head>
<!-- css imports, titles etc -->
</h:head>
<h:body>
<ui:insert name="menu">
<ui:include src="./default/content.xhtml" />
</ui:insert>
</h:body>
</html>
I have problem with the Push Technology, the project is to:
Primefaces 3.5
WebLogic 12c
Atmosphere Runtime 2.2
The configuration is:
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
</servlet>
The View:
#Named
#SessionScoped
public class FrmNotificacion implements Serializable
...
public void send() {
...
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Usuario: "+getUser(), getMensajeDetalle());
PushContext pushContext = PushContextFactory.getDefault().getPushContext();
pushContext.push("/notificacion", msg);
System.out.println("......");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
The XHTML:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui" >
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Enivar Notificación</title>
</h:head>
<h:body>
<h:form id="frmPrincipal" >
<p:growl id="message" showDetail="true" />
<p:panel header="Notificación" >
<p:panelGrid columns="2" columnClasses="ui-widget-header,,ui-widget-header,,ui-widget-header,," >
<p:outputLabel id="lblNombre" value="Ingrese Usuario a Notificar:" />
<p:inputText id="txtNombre" value="#{frmNotificacion.user}" />
<p:outputLabel id="lblMensaje" value="Ingresar Mensaje Notificación" />
<p:inputTextarea id="txtMensaje" autoResize="true" value="#{frmNotificacion.mensajeDetalle}"/>
</p:panelGrid>
<p:commandButton id="btnNotifica"
value="Notifica"
update="message"
actionListener="#{frmNotificacion.send()}"
icon="ui-icon-arrowthickstop-1-e" />
</p:panel>
</h:form>
<p:socket onMessage="handleMessage" channel="/notificacion" />
<script type="text/javascript">
function handleMessage(msg) {
msg.severity = 'info';
grow.show([msg]);
}
</script>
</h:body>
</html>
But the action notify push Faces Message not working
Maybe the configuration is wrong
It also shows me this console:
INFO: Installed AtmosphereInterceptor Atmosphere LifeCycle with priority AFTER_DEFAULT
03-feb-2015 9:09:50 org.atmosphere.cpr.AsynchronousProcessor action
ADVERTENCIA: Websocket protocol not supported
03-feb-2015 9:09:50 org.atmosphere.cpr.AsynchronousProcessor action
GRAVE: Invalid request state. AsyncContext#startAsync not supported. Make sure async-supported is set to true in web.xml
03-feb-2015 9:09:52 org.atmosphere.cpr.AtmosphereFramework$4 run
INFO: Latest version of Atmosphere's JavaScript Client 2.2.6
Change JavaScript:
Last:
<script type="text/javascript">
function handleMessage(msg) {
msg.severity = 'info';
grow.show([msg]);
}
</script>
For This:
<script type="text/javascript">
function handleMessage(data) {
alert("Hola");
}
</script>
as I do that I work at the FacesMessage ¿?
this is the page where i call dialog on openDialog metod
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
</h:head>
<h:body>
<h:form>
<p:commandButton value="OpenDialog" action="#{cnt.openDialog()}"/>
</h:form>
</h:body>
</html>
and my dialog page is
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
</h:head>
<h:body>
<h:form id="insModForm">
<p:panel id="searchCitizenPanel" header="Just Panel" >
<h:panelGrid columns="2">
<h:outputText value="name"/>
<p:inputText value="#{iamasCnt.citizen.name}"/>
<h:outputText value="surname"/>
<p:inputText value="#{iamasCnt.citizen.surname}"/>
<h:outputText value="bdate"/>
<p:calendar value="#{iamasCnt.citizen.bdate}"/>
<h:outputText value=""/>
<p:commandButton value="check" action="#{cnt.searchThis()}" />
</h:panelGrid>
</p:panel>
</h:form>
</h:body>
and CDI where i call prime faces framework dialog
#Named("cnt")
#SessionScoped
public class IAMASController implements Serializable {
public void openDialog() {
logger.info("// opendialog");
Map<String, Object> options = new HashMap<String, Object>();
options.put("modal", true);
options.put("draggable", false);
options.put("resizable", false);
options.put("contentHeight", 720);
options.put("contentWidth", 720);
RequestContext.getCurrentInstance().openDialog("/dialogTest/dialog", options, null);
}
}
i'm newly using primefaces dialog framework got some problems
problem is p:commandButton action searchThis() invokes each time when i open prime faces dialog
I find it! There was such a weird situation
i put comment next to
<p:commandButton value="check" action="#{cnt.searchThis()}"/><!-- action="#{iamasCnt.hiddenSearch()}"-->
due to jsf problem hiddenSearch() action in comment invoked each time when dialog loads so i took off this comment everything works fine
I've been trying to put a queue onto a text area, and it is not cooperating. I'll list the relevant section of code below.
<h:form>
<a4j:queue requestDelay="1000" ignoreDupResponses="true"/>
<table>
<tr>
<td>
<h:outputText value="Notes:"/>
</td>
</tr>
<tr>
<td>
<h:inputTextarea value="#{MyActionBean.notes}">
<a4j:ajax event="keyup" listener="#{MyActionBean.updateNotes}"/>
</h:inputTextarea>
The notes get updated as expected, but there is no delay between requests. Is there some bug in my code, do textAreas not work for this? Any help would be appreciated.
EDIT: Just for good measure, tried the following code as well, but it didn't work either.
<h:panelGrid columns="1" width="100%">
<h:outputText value="Notes:"/>
<h:inputTextarea value="#{MyActionBean.notes}">
<a4j:ajax event="keyup" listener="#{MyActionBean.updateNotes}">
<a4j:attachQueue id="notesQueue" requestDelay="1000"/>
</a4j:ajax>
</h:inputTextArea>
</h:panelGrid>
For reference, the technology versions:
JBoss AS 7, Seam 2.3.0, Richfaces 4.2.2, JSF 2.1
For your case you need to nest a4j:attachQueue inside a4j. Try to run the code below and you'll notice that you'll get an output on the console after 15 seconds.
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<a4j:queue name='Y' requestDelay="3000" ignoreDupResponses="true"/>
<h:panelGrid columns="1" width="100%">
<h:outputText value="Notes:"/>
<h:inputTextarea value="#{MyActionBean.notes}">
<a4j:ajax event="keyup" listener="#{MyActionBean.updateNotes}">
<a4j:attachQueue requestDelay="3000"/>
</a4j:ajax>
</h:inputTextarea>
<a4j:status>
<f:facet name="start">
Please wait
</f:facet>
</a4j:status>
</h:panelGrid>
</h:form>
</h:body>
You can use this link if you need more information
UPDATE
I stripped down the code you sent to the bare minimum and I'm sorry to say that it is still working on my end with JBoss. Your issue could be somewhere else (e,g. your ajax might be failing for some reason since you told me "Please Wait" was not appearing). However, I should mention that I'm not familiar with JBoss' conversation scope so I changed it to javax.enterprise.context.SessionScoped (but I don't think that should matter because it was still working when it was requestscoped). I'm including all the code so you can test it yourself as a separate project. Also, since we are using a queue I changed the logging location from updateNotes to setReport so that I could be absolutely certain that the characters were actually being queued. When I typed "This is a test", the only output I saw was the entire String and not each character.
AssessmentCheckListAction.java
import java.io.Serializable;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
#Named(value="AssessmentChecklistAction")
#SessionScoped
public class AssessmentCheckListAction implements Serializable {
private static final long serialVersionUID = -4970638494437413924L;
private String report;
public AssessmentCheckListAction() {
}
public void updateNotes() {
//FacesContext.getCurrentInstance().getExternalContext().log(report);
//Logging the setter to make sure everything was queued
}
public String getReport() {
return report;
}
public void setReport(String report) {
FacesContext.getCurrentInstance().getExternalContext().log(report);
this.report = report;
//left blank
}
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">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
template="template.xhtml">
<ui:define name="content">
<h:form>
<a4j:queue requestDelay="3000" ignoreDupResponses="true"/>
<h:panelGrid columns="1" width="100%">
<h:outputText value="Notes:"/>
<h:inputTextarea value="#{AssessmentChecklistAction.report}">
<a4j:ajax event="keyup" listener="#{AssessmentChecklistAction.updateNotes}">
<a4j:attachQueue requestDelay="3000"/>
</a4j:ajax>
</h:inputTextarea>
<a4j:status>
<f:facet name="start">
Please wait
</f:facet>
</a4j:status>
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
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:ui="http://java.sun.com/jsf/facelets">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Cache-Control" content="no-store"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
</h:head>
<h:body>
<ui:insert name="content"/>
</h:body>
</html>
I'm new to JSF and I'm facing this weird issue. I'm sure it's a silly mistake but I just can't seem to figure it out. Basically, when I insert rich:calendar within ui:composition it does not display. My (simplified) template is defined 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">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title></title>
</h:head>
<h:body>
<ui:insert name="content"/>
<ui:debug/>
</h:body>
</html>
My index page
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich">
<head>
<title></title>
</head>
<body>
<ui:composition template="/indexLayout.xhtml">
<h:outputScript library="javascript" name="common.js" target="head"/>
<ui:define name="content">
<h:form>
<h:panelGrid columns="2">
From
<rich:calendar id="pickup" onchange="#{rich:component('return')}.setValue(#{rich:component('pickup')}.getValue())"
dayDisableFunction="disablementFunction" datePattern="MMM d, yyyy" value="#{reservation.pickUp}" />
To
<rich:calendar id="return" dayDisableFunction="disablementFunction" datePattern="MMM d, yyyy" />
</h:panelGrid>
<h:commandButton value="Redisplay" />
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
If I define the index page without ui:composition it displays just fine. Please help. Thank you.
You should place your <h:outputScript /> inside the <ui:define></ui:define> since when you are using <ui:composition />, every <ui:insert /> inside the template are replaced by respective <ui:define />. Everything outside <ui:define /> is not rendered.
In your case the JavaScript function disablementFunction is not loaded so your rich:calendar doesn't work properly.
Here is how your index page should look like :
<ui:composition template="/indexLayout.xhtml">
<ui:define name="content">
<h:outputScript library="javascript" name="common.js" target="head"/>
<h:form>
<h:panelGrid columns="2">
From
<rich:calendar id="pickup" onchange="#{rich:component('return')}.setValue(#{rich:component('pickup')}.getValue())" dayDisableFunction="disablementFunction" datePattern="MMM d, yyyy" value="#{reservation.pickUp}" />
To
<rich:calendar id="return" dayDisableFunction="disablementFunction" datePattern="MMM d, yyyy" />
</h:panelGrid>
<h:commandButton value="Redisplay" />
</h:form>
</ui:define>
</ui:composition>
More info :
JSF 2 templating with Facelets example