jars required to be added to use rich notify messages in jsf? - jsf

i am using rich notify messages and added all related jars namely
richfaces-components-ui-4.1.0.Final ,
richfaces-core-impl-4.0.0.Final,
standard-1.1.2 ,
jstl-1.2 ,
validation-api-1.0.0.GA ,
richfaces-core-api-4.0.0.Final ,
richfaces-components-api-4.0.0.Final
jsf-impl-2.0.2,
cssparser-0.9.5,
guava-r08,
jhighlight-1.0.
but i am getting class not found exception:org.richfaces.component.NotifyAttributes.
sample.xhtml:
<!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:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<rich:panel>
<f:facet name="header">
<h:outputText value="Validation Form" />
</f:facet>
<h:form>
<h:panelGrid columns="3">
<rich:validator event="change">
<h:outputText value="Name:" />
<h:inputText label="Name" id="name" value="#{userBean.name}"
required="true">
<f:validateLength minimum="3" />
</h:inputText>
<rich:message for="name" ajaxRendered="true" />
<h:outputText value="Job:" />
<h:inputText label="Job" id="job" value="#{userBean.job}"
requiredMessage="Job is required">
<f:validateLength minimum="3" maximum="50" />
</h:inputText>
<rich:message for="job" ajaxRendered="true" />
<h:outputText value="Address:" />
<h:inputText label="Address" id="address"
value="#{userBean.address}" requiredMessage="Address is required">
<f:validateLength minimum="10" />
</h:inputText>
<rich:message for="address" ajaxRendered="true" />
<h:outputText value="Zip:" />
<h:inputText label="Zip" id="zip" value="#{userBean.zip}"
requiredMessage="Zip is required">
<f:validateLength minimum="4" maximum="9" />
</h:inputText>
<rich:message for="zip" ajaxRendered="true" />
</rich:validator>
<rich:notifyMessages stayTime="2000" nonblocking="true" escape="false"/>
<f:facet name="footer">
<a4j:commandButton value="Ajax Validate" />
</f:facet>
</h:panelGrid>
</h:form>
</rich:panel>
</ui:composition>
bean class used to set and get bean vlaues.let me know whats wrong with existing code ,along with jars to be added
userBean.java:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
#ManagedBean
#SessionScoped
public class userBean {
private String name;
private String job;
private String address;
private String zip;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getJob() {
return job;
}
public void setJob(String job) {
this.job = job;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
}
error:
Caused by: java.lang.ClassNotFoundException: org.richfaces.component.NotifyAttributes
i am not getting why this is getting although i added all required jars of richfaces4.0 and above.

notify component is not part of RichFaces 4.0. See Richfaces 4.0 VDL documentation. You have to use version 4.1 or up (for example current version RichFaces 4.3).Note: all richfaces-???.jar(s) should be for the same version of RichFaces.

Related

p:commandbutton on primefaces cannot be clicked twice

hello i was testing out the example given on the official primefaces website an i noticed that my <p:commandButton> does not work well in that once i click it to update a value, it stays highlighted and cannot be clicked again to update the value again. Here is the xhtml file:
<?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:p="http://primefaces.org/ui">
<script src="http://maps.google.com/maps/api/js?sensor=false"
type="text/javascript"></script>
<h:head>
</h:head>
<h:form>
<h:panelGrid columns="2" cellpadding="5" styleClass="ui-grid">
<h:outputLabel for="basic" value="Basic Spinner: " />
<p:spinner id="basic" value="#{spinnerView.number1}" />
<h:outputLabel for="step" value="Step Factor: " />
<p:spinner id="step" value="#{spinnerView.number2}" stepFactor="0.25" />
<h:outputLabel for="minMax" value="Min/Max: " />
<p:spinner id="minMax" value="#{spinnerView.number3}" min="0" max="100" />
<h:outputLabel for="prefix" value="Prefix: " />
<p:spinner id="prefix" value="#{spinnerView.number4}" prefix="$" min="0" />
<h:outputLabel for="ajaxSpinner" value="Ajax Spinner: " />
<p:outputPanel>
<p:spinner id="ajaxSpinner" value="#{spinnerView.number5}">
<p:ajax update="ajaxSpinnerValue" process="#this" />
</p:spinner>
<h:outputText id="ajaxSpinnerValue" value="#{spinnerView.number5}" style="padding-left: 10px" />
</p:outputPanel>
</h:panelGrid>
<p:commandButton value="Submit" update="display" oncomplete="PF('dlg').show()" />
<p:dialog header="Values" widgetVar="dlg" showEffect="fold" hideEffect="fold">
<h:panelGrid id="display" columns="2" cellpadding="5">
<h:outputText value="Value 1: " />
<h:outputText value="#{spinnerView.number1}" />
<h:outputText value="Value 2: " />
<h:outputText value="#{spinnerView.number2}" />
<h:outputText value="Value 3: " />
<h:outputText value="#{spinnerView.number3}" />
<h:outputText value="Value 4: " />
<h:outputText value="#{spinnerView.number4}" />
<h:outputText value="Value 5: " />
<h:outputText value="#{spinnerView.number5}" />
</h:panelGrid>
</p:dialog>
</h:form>
</html>
And this is the managed bean:
package uk.soton.lostatnight;
import javax.faces.bean.ManagedBean;
#ManagedBean
public class SpinnerView {
private int number1;
private double number2;
private int number3;
private int number4;
private int number5;
public int getNumber1() {
return number1;
}
public void setNumber1(int number1) {
this.number1 = number1;
}
public double getNumber2() {
return number2;
}
public void setNumber2(double number2) {
this.number2 = number2;
}
public int getNumber3() {
return number3;
}
public void setNumber3(int number3) {
this.number3 = number3;
}
public int getNumber4() {
return number4;
}
public void setNumber4(int number4) {
this.number4 = number4;
}
public int getNumber5() {
return number5;
}
public void setNumber5(int number5) {
this.number5 = number5;
}
}
I find this weird so does anyone have any solutions to this problem or is it the cause of something else like the web or pom.xml files and if so how can i fix this?

Binding values to UIInput in composite component results in null

I am trying to create a composite component for a user search. Here is the component xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:h="http://java.sun.com/jsf/html">
<cc:interface componentType="searchUser">
<!-- Define component attributes here -->
<cc:attribute name="value" type="java.lang.Object"
shortDescription="Selected User"/>
</cc:interface>
<cc:implementation>
<p:commandButton onclick="PF('sdgl').show();" type="button" value="search for user"/>
<p:dialog header="Search for User"
widgetVar="sdgl"
modal="true"
width="80%"
appendTo="#(body)"
>
<h:form id="searchDLGForm" >
<p:fragment autoUpdate="true">
<p:panelGrid columns="2" id="searchPanel">
<p:outputLabel value="Username: "
for="username"
/>
<p:inputText id="username" binding="#{cc.login}"/>
<p:outputLabel value="First Name: "
for="firstname"
/>
<p:inputText id="firstname" binding="#{cc.firstname}"/>
<p:outputLabel value="Last Name: "
for="lastname"
/>
<p:inputText id="lastname" binding="#{cc.lastname}"/>
<p:commandButton value="search" actionListener="#{cc.search}"/>
</p:panelGrid>
<p:dataTable value="#{cc.foundUser}" var="user" id="sdgl_res" selection="#{cc.selectedUser}"
rowKey="#{user.id}">
<p:column selectionMode="single"
style="width:16px;text-align:center"/>
<p:column headerText="First Name">
#{user.firstName}
</p:column>
<p:column headerText="Last Name">
#{user.lastName}
</p:column>
<p:column headerText="E-Mail">
#{user.email}
</p:column>
</p:dataTable>
</p:fragment>
</h:form>
</p:dialog>
</cc:implementation>
The compnent is nesten in:
<h:form id="ouMembers">
<div>
<p:panelGrid>
......
<my:searchUser id="searchDLG" value="#{ouBean.userToAdd}"/>
</p:panelGrid>
</div>
</h:form>
And the corresponding Java:
private UIInput firstname;
private UIInput lastname;
private UIInput login;
private UserModel selectedUser;
private List<UserModel> foundUser;
/**
* Returns the component family of {#link UINamingContainer}.
* (that's just required by composite component)
*/
#Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
/**
* return selected user
*
* #return selected user
*/
#Override
public Object getSubmittedValue() {
return selectedUser;
}
public void search(ActionEvent event) {
System.out.println("searchUser called with: " + this.login.getSubmittedValue()+ ", " +
""+this.firstname.getSubmittedValue()+"," +
""+this.lastname.getSubmittedValue());
this.foundUser = UserModel.searchUser((String)this.login.getSubmittedValue(),
(String)this.firstname.getSubmittedValue(),
(String)this.lastname.getSubmittedValue());
}
#Override
public void encodeBegin(FacesContext context) throws IOException {
UserModel value = (UserModel) getValue();
if(value!=null){
firstname.setValue(value.getFirstName());
lastname.setValue(value.getLastName());
login.setValue(value.getLogin());
}else{
firstname.setValue("");
lastname.setValue("");
login.setValue("");
}
}
+ getters setters
The problem I currently have, is that this.login.getSubmittedValue(), this.firstname.getSubmittedValue() and this.lastname.getSubmittedValue() are null in the search method. I have tried using getValue() but that also resulted in null value.
I am following http://balusc.omnifaces.org/2013/01/composite-component-with-multiple-input.html tutorial for this. Any help is greatly appreciated. thanks.
I am using:
com.sun.faces 2.2.12
primefaces 5.2
on Glassfish 4.1.0
EDIT
After removing the <h:form id="searchDLGForm" > and the appendTo="#(body)" from the dialog, it works. however I have to remove the modal="true" parameter, or the dialog is also inactive.

How can I navigate to another page in JSF?

I am developing small web app using JSF/PrimeFaces. I am able to call bean from web, however, I am unable to return web. This is what I have:
requestLeave.xhtml
<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:head>
<title>Request leave</title>
</h:head>
<h:body>
<script language="javascript">
var today = new Date();
document.write(today);
</script>
<h:form id="form" >
<h:panelGrid id= "grid" columns="2" cellpadding="5">
<f:facet name="header">
<p:messages id="msgs" />
</f:facet>
<h:outputLabel for="title" value="Leave Title:" style="font-weight:bold" />
<p:inputText value="#{requestLeave.titleLeave}" required="true" requiredMessage="title is required." />
<h:outputLabel for="type" value="Type:" style="font-weight:bold" />
<p:inputText value="#{requestLeave.typeLeave}" required="true" requiredMessage="type is required." />
<p:commandButton value="Submit" actionListener="#{requestLeave.buttonAction}" />
</h:panelGrid>
</h:form>
</h:body>
</html>
RequestLeave.java
import javax.faces.bean.ManagedBean;
#ManagedBean
public class RequestLeave {
private String titleLeave;
private String typeLeave;
public String getTitleLeave() {
return titleLeave;
}
public void setTitleLeave(String titleLeave) {
this.titleLeave = titleLeave;
}
public String getTypeLeave() {
return typeLeave;
}
public void setTypeLeave(String typeLeave) {
this.typeLeave = typeLeave;
}
public String buttonAction() {
System.out.println("leave title " + titleLeave);
System.out.println("leave type " + typeLeave);
return ("index.jsp");
}
}
With this, I cannot return to index.jsp. Can anyone help me? Thanks in advance.
Change the actionListener attribute to action:
<p:commandButton value="Submit" action="#{requestLeave.buttonAction}" />
More info:
Differences between action and actionListener?

update primefaces dataTable with new rows adding dynamically

When I click on the button New <p:commandButton actionListener="#{ecritureCtrl.newLine}" value="New" update="dataTableSaisiePiece" oncomplete="addRowOnComplete()" ajax="true"/>, a new row is added to my dataTable on only the first click and the page is refreshed. Several cliques except the first were not refreshes the dataTable. So to see my newly added rows, I use the F5 key to refresh my page. Certainly my update="dataTableSaisiePiece" not work or only works rather the first click.
Here is my page 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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<script type="text/javascript">
function addRowOnComplete() {
jQuery('#supercoolnewrow').trigger('click');
}
</script>
<ui:composition template="/resources/template/all.xhtml">
<ui:define name="titre">Saisie</ui:define>
<ui:define name="content">
<p:tabView id="ViewPlan">
<p:tab id="tab2" title="Saisie 1">
<h:outputScript library="js" name="frenchLocale.js" />
<h:form id="formPiece">
<p:panel id="panelSaisie" header="Saisir" style="color: brown;font-size: 15px">
<h:panelGrid columns="3" >
<p:outputLabel for="description" value="Description:" ></p:outputLabel>
<p:inputText id="description" value="#{ecritureCtrl.description}" required="true" label="Description" maxlength="100" size="75">
<f:validateLength maximum="100" />
</p:inputText>
<p:message for="description" />
<p:outputLabel for="date" value="Date:" ></p:outputLabel>
<p:calendar locale="fr" id="date" required="true" label="Date" value="#{ecritureCtrl.date}" />
<p:message for="date" />
<p:outputLabel for="code" value="Code Avant" ></p:outputLabel>
<p:inputText id="code" value="#{ecritureCtrl.code}" required="true" >
</p:inputText>
<p:message for="code" />
</h:panelGrid>
<br/>
<p:dataTable var="line" value="#{ecritureCtrl.lignes}" id="dataTableSaisiePiece" >
<p:column headerText="First Name" style="width:150px">
<p:inputText value="#{line.intituleCompte}" style="width:100%"/>
</p:column>
<p:column headerText="Last Name" style="width:150px">
<p:inputText value="#{line.code}" style="width:100%"/>
</p:column>
</p:dataTable>
</p:panel>
<p:commandButton actionListener="#{ecritureCtrl.newLine}" value="New" update="dataTableSaisiePiece" oncomplete="addRowOnComplete()" ajax="true"/>
</h:form>
</p:tab>
<p:tab id="tab3" title="Saisie 2">
</p:tab>
</p:tabView>
</ui:define>
</ui:composition>
</html>
My ManagedBean:
#ManagedBean (name = "ecritureCtrl")
#SessionScoped
public class EcritureCtrl {
private List<Avant> lignes = new ArrayList<Avant>();
Avant unUser;
private String description;
private Date date;
private String code;
public EcritureCtrl() {
lignes.add(new Avant());
}
public void newLine(ActionEvent actionEvent){
lignes.add(new Avant());
}
}
Could you please help me ?
Thanks in advance.
this seems to work for me
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
#ManagedBean
#SessionScoped
public class EcritureCtrl implements Serializable {
private static final long serialVersionUID = 1L;
private String code;
private Date date;
private String description;
private List<Avant> lignes = new ArrayList<Avant>();
private Avant unUser;
public String getCode() {
return this.code;
}
public Date getDate() {
return this.date;
}
public String getDescription() {
return this.description;
}
public List<Avant> getLignes() {
return this.lignes;
}
public Avant getUnUser() {
return this.unUser;
}
#PostConstruct
private void init(){
this.lignes.add(new Avant());
}
public void newLine(ActionEvent actionEvent) {
this.lignes.add(new Avant());
}
public void setCode(String code) {
this.code = code;
}
public void setDate(Date date) {
this.date = date;
}
public void setDescription(String description) {
this.description = description;
}
public void setLignes(List<Avant> lignes) {
this.lignes = lignes;
}
public void setUnUser(Avant unUser) {
this.unUser = unUser;
}
}
and
<!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:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Sorry</title>
</h:head>
<h:body>
<script type="text/javascript">
function addRowOnComplete() {
alert();
}
</script>
<h:form id="formPiece">
<p:messages id="messages" showDetail="true" autoUpdate="true"
closable="true" />
<p:tabView id="ViewPlan">
<p:tab id="tab2" title="Saisie 1">
<p:panel id="panelSaisie" header="Saisir"
style="color: brown;font-size: 15px">
<h:panelGrid columns="3">
<p:outputLabel for="description" value="Description:"></p:outputLabel>
<p:inputText id="description" value="#{ecritureCtrl.description}"
required="true" label="Description" maxlength="100" size="75">
<f:validateLength maximum="100" />
</p:inputText>
<p:message for="description" />
<p:outputLabel for="date" value="Date:"></p:outputLabel>
<p:calendar locale="fr" id="date" required="true" label="Date"
value="#{ecritureCtrl.date}" />
<p:message for="date" />
<p:outputLabel for="code" value="Code Avant"></p:outputLabel>
<p:inputText id="code" value="#{ecritureCtrl.code}"
required="true">
</p:inputText>
<p:message for="code" />
</h:panelGrid>
<br />
<p:dataTable var="line" value="#{ecritureCtrl.lignes}"
id="dataTableSaisiePiece">
<p:column headerText="First Name" style="width:150px">
<p:inputText value="#{line.intituleCompte}" style="width:100%" />
</p:column>
<p:column headerText="Last Name" style="width:150px">
<p:inputText value="#{line.code}" style="width:100%" />
</p:column>
</p:dataTable>
</p:panel>
<p:commandButton actionListener="#{ecritureCtrl.newLine}"
value="New" update="dataTableSaisiePiece" oncomplete="addRowOnComplete()"
ajax="true" />
</p:tab>
<p:tab id="tab3" title="Saisie 2">
</p:tab>
</p:tabView>
</h:form>
</h:body>
</html>

Jsf PrimeFaces. Error during the render response. p:commandButton

I'm starting to use JSF with primefaces library over an Hibernate project. I've tried to use wizard component to manage a form but, when I click any of the buttons in the wizard, I get the following warning and the action listener is not invoked.
I think the problem is that, in the wizard there are some p:commandButton because when I use h:commandButton, everything works. Could someine explain in what way primefaces commandButton ih different from the standard one, and how could I face this problem? What's different in the rendering process?
Thanks for your help!
Here's the warning:
9-ott-2012 9.50.43 org.apache.myfaces.trinidadinternal.context.PartialViewContextImpl getPartialResponseWriter
AVVERTENZA: getPartialResponseWriter() called during render_reponse. The returned writer is not integrated with PPRResponseWriter
Here's the code of the page:
<?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>
<h:outputScript name="jsf.js" library="javax.faces" target="head" />
</h:head>
<h:body>
<p:growl id="growl" showDetail="true" sticky="true" />
<h:form>
<p:wizard widgetVar="wiz"
flowListener="#{traduttoreBean.onFlowProcess}">
<p:tab id="personali" title="Info Personali">
<p:panel header="Informazioni Personali">
<h:messages errorClass="error"/>
<h:panelGrid columns="2" columnClasses="label, value" styleClass="grid">
<h:outputText value="Nome: *" />
<p:inputText required="true" label="Nome"
value="#{traduttoreBean.info.nome}" />
<h:outputText value="Cognome: *" />
<p:inputText required="true" label="cognome"
value="#{traduttoreBean.info.cognome}" />
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab id="confirm" title="Confirmation">
<p:panel header="Confirmation">
<h:panelGrid id="confirmation" columns="6">
<h:outputText value="Nome: " />
<h:outputText styleClass="outputLabel"
value="#{traduttoreBean.info.nome}" />
<h:outputText value="Cognome: " />
<h:outputText styleClass="outputLabel"
value="#{traduttoreBean.info.cognome}" />
<h:outputText />
</h:panelGrid>
<p:commandButton value="Submit" update="growl" action="#{traduttoreBean.save}" ></p:commandButton>
</p:panel>
</p:tab>
</p:wizard>
</h:form>
</h:body>
</html>
The associated bean:
public class TraduttoreBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private Traduttore traduttore;
private InfoTraduttore info;
public TraduttoreBean(){
this.traduttore=new Traduttore();
this.info= new InfoTraduttore();
this.info.setTraduttore(traduttore);
}
public void save(ActionEvent actionEvent) {
PersistenzaUtenti pu= PersistenzaUtenti.getInstance();
PersistenzaInfoTraduttori pi= PersistenzaInfoTraduttori.getInstance();
try {
pu.insert(traduttore);
pi.insert(info);
} catch (Exception e) {
}
FacesMessage msg = new FacesMessage("Successful", "Welcome :" + info.getNome());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public String onFlowProcess(FlowEvent event) {
return event.getNewStep();
}
public Traduttore getTraduttore() {
return traduttore;
}
public void setTraduttore(Traduttore traduttore) {
this.traduttore = traduttore;
}
public InfoTraduttore getInfo() {
return info;
}
public void setInfo(InfoTraduttore info) {
this.info = info;
}
}
For the declaration of the bean I've tried both with the annotation #Managed bean and the faces-config file.
Here's my definition:
<managed-bean>
<managed-bean-name>traduttoreBean</managed-bean-name>
<managed-bean-class>guiBeans.TraduttoreBean</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
</managed-bean>
Answer provided by comment:
The problem was that Trinidad libraries were in conflict with
Primefaces. Solved removing Trinidad libraries.

Resources