Cannot 'hide' rich:fileUpload - jsf

Im trying to create a page that uses the rich:fileUpload, to (surprisingly) upload an image, once the upload is completed I want to 'hide' the rich:fileUpload component and display the jQuery plugin jCrop so that the image can be cropped before saving. once the image is saved from the crop selected, the two components should toggle their viewability again.
However, I dont appear to be able to get the rich:fileUpload to 'hide'. the jCrop component displays fine, as does the jCrop functionality. but no matter what I try rich:fileUpload is still displayed on the screen. Actually if I add rendered="#{!uploadAndCrop.newImage}" to the rich:panel that the rich:fileUpload is in, nothing seems to update. I have to remove this for the jCrop component to appear.
My code is below, it is a little messy as ive tried so many different things. Would be extremely grateful if someone could point me in the right direction with this, or advise a better way of doing it.
Thanks
<ui:define name="head">
<link href="stylesheet/jquery.Jcrop.css" rel="stylesheet"
type="text/css" />
<script type="text/javascript" src="scripts/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="scripts/jquery.Jcrop.js"></script>
<script language="Javascript">// <![CDATA[ //
{
var $J = jQuery.noConflict();
}
//]]> //</script>
</ui:define>
<ui:define name="body">
<h:form>
<h:panelGrid columns="2" columnClasses="top,top">
<h:panelGroup id="uploadgroup">
<a4j:outputPanel id="uploadpanel">
<rich:panel rendered="#{!uploadAndCrop.newImage}">
<rich:fileUpload fileUploadListener="#{uploadAndCrop.listener}"
maxFilesQuantity="#{uploadAndCrop.uploadsAvailable}" id="upload"
immediateUpload="#{uploadAndCrop.autoUpload}"
acceptedTypes="jpg, gif, png, bmp"
allowFlash="#{uploadAndCrop.useFlash}" listHeight="80px">
<ui:remove>
onfileuploadcomplete="Richfaces.showModalPanel('croppanel');">
</ui:remove>
<a4j:support event="onuploadcomplete"
reRender="info, uploadgroup, cropgroup" />
</rich:fileUpload>
<h:outputText value="#{uploadAndCrop.newImage}" id="newimage" />
<a onclick="Richfaces.showModalPanel('croppanel');" href="#">Show
ModalPanel</a>
</rich:panel>
</a4j:outputPanel>
</h:panelGroup>
<h:panelGroup id="info">
<rich:panel bodyClass="info" rendered="#{!uploadAndCrop.newImage}">
<f:facet name="header">
<h:outputText value="Uploaded Image Preview" />
</f:facet>
<rich:dataGrid columns="1" value="#{uploadAndCrop.files}"
var="file" rowKeyVar="row">
<rich:panel bodyClass="rich-laguna-panel-no-header">
<h:panelGrid columns="2">
<a4j:mediaOutput element="img" mimeType="#{file.mime}"
createContent="#{uploadAndCrop.paint}" value="#{row}"
style="width:156x; height:71px;" cacheable="false">
<f:param value="#{uploadAndCrop.timeStamp}" name="time" />
<s:conversationId />
</a4j:mediaOutput>
</h:panelGrid>
</rich:panel>
</rich:dataGrid>
</rich:panel>
<rich:spacer height="3" />
<br />
<a4j:commandButton action="#{uploadAndCrop.clearUploadData}"
reRender="info, upload" value="Clear Uploaded Image" />
</h:panelGroup>
<h:panelGroup id="cropgroup">
<rich:panel rendered="#{uploadAndCrop.newImage}">
<f:facet name="header">
<h:outputText value="Crop Image" />
</f:facet>
<a4j:outputPanel id="crop" layout="inline">
<rich:jQuery selector="#cropbox" timing="immediate"
query="Jcrop()" />
<a4j:mediaOutput element="img"
mimeType="#{uploadAndCrop.tempImageStore.mime}" id="cropbox"
createContent="#{uploadAndCrop.paintCrop}" value="null"
style="width:312; height:142px;" cacheable="false">
<f:param value="#{uploadAndCrop.timeStamp}" name="time" />
<s:conversationId />
</a4j:mediaOutput>
<rich:spacer height="3" />
<br />
<a4j:commandButton action="#{uploadAndCrop.clearUploadData}"
reRender="info, upload" value="Crop" />
</a4j:outputPanel>
</rich:panel>
</h:panelGroup>
</h:panelGrid>
<h:commandButton id="save" value="Save"
action="#{uploadAndCrop.save}">
<f:param name="cmsCompanyIdCom" value="" />
</h:commandButton>
<s:button id="cancelEdit" value="Cancel" propagation="end"
view="/CmsCompany.xhtml">
<f:param name="cmsCompanyIdCom" value="" />
</s:button>
</h:form>
<ui:remove>
<rich:modalPanel id="croppanel" width="350" height="240">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Crop Image"></h:outputText>
</h:panelGroup>
</f:facet>
<f:facet name="image">
<ui:remove>
<h:panelGroup>
<h:outputText value="close" />
<rich:componentControl for="croppanel" attachTo="close"
operation="hide" event="onclick" />
</h:panelGroup>
</ui:remove>
</f:facet>
<rich:panel rendered="#{uploadAndCrop.newImage}">
<ui:remove>
<f:facet name="header">
<h:outputText value="Crop Image" />
</f:facet>
</ui:remove>
<a4j:outputPanel id="crop" layout="inline">
<a4j:mediaOutput element="img"
mimeType="#{uploadAndCrop.tempImageStore.mime}" id="cropbox"
createContent="#{uploadAndCrop.paintCrop}" value="null"
style="width:312; height:142px;" cacheable="false">
<f:param value="#{uploadAndCrop.timeStamp}" name="time" />
<s:conversationId />
</a4j:mediaOutput>
<ui:remove>
<rich:spacer height="3" />
<br />
<a4j:commandButton action="#{uploadAndCrop.clearUploadData}"
reRender="info, upload" value="Crop" />
</ui:remove>
</a4j:outputPanel>
</rich:panel>
<a onclick="Richfaces.hideModalPanel('croppanel');" href="#">Hide
ModalPanel</a>
</rich:modalPanel>
</ui:remove>
</ui:define>

I dont know how is your uploadAndCrop.newImage method, but you can just use a boolean and sets it to false on the fileUploadListener.
But reRender the <a4j:outputPanel id="uploadpanel">, not the <rich:fileUpload> or the group.
<a4j:outputPanel id="uploadpanel" rendered="#{bean.fileUpRendered}">
(...)
<rich:fileUpload...
<a4j:support event="onuploadcomplete"
reRender="info, uploadpanel, cropgroup" />
</rich:fileUpload>
(...)
</a4j:outputPanel>
Bean:
Boolean fileUpRendered;
(...)
public void listener(UploadEvent event) throws Exception {
try {
(...)
fileUpRendered = false;
catch (...) { (...) }
}
//Get set
public get/set fileUpRendered() { }...

Related

Apply animation effect on button click - JSF

I found these animations for jsf components : http://www.animatejsf.org/
I tried applying this to a <h:form> from a commandlink click as shown
<h:form id="leftMenu">
Slide
</h:form>
<p:commandLink>
<p:outputLabel> click here
<aj:animate target="leftMenu" type="slideInLeft"/>
</p:outputLabel>
</p:commandLink>
But the animation is not visible on click of the command link. Instead it is animating on web page loading initially only. I wanted to apply this animation on click of either a <p:commandButton> or <p:commandLink>.
Does anyone know how can I achieve this? Any help is appreciated.
Have you already tried:
<p:effect type="clip" event="click" />
Here an example:
<h3 style="margin-top:0">Catalog</h3>
<h:panelGrid columns="4" cellpadding="5">
<p:panel id="blind" header="Blind">
<h:outputText value="click" />
<p:effect type="blind" event="click">
<f:param name="direction" value="'horizontal'" />
</p:effect>
</p:panel>
<p:panel id="clip" header="Clip">
<h:outputText value="click" />
<p:effect type="clip" event="click" />
</p:panel>
<p:panel id="drop" header="Drop">
<h:outputText value="click" />
<p:effect type="drop" event="click" />
</p:panel>
<p:panel id="explode" header="Explode">
<h:outputText value="click" />
<p:effect type="explode" event="click" />
</p:panel>
<p:panel id="fold" header="Fold">
<h:outputText value="doubleclick" />
<p:effect type="fold" event="dblclick" />
</p:panel>
<p:panel id="puff" header="Puff">
<h:outputText value="doubleclick" />
<p:effect type="puff" event="dblclick" />
</p:panel>
<p:panel id="slide" header="Slide">
<h:outputText value="doubleclick" />
<p:effect type="slide" event="dblclick" />
</p:panel>
<p:panel id="scale" header="Scale">
<h:outputText value="doubleclick" />
<p:effect type="scale" event="dblclick">
<f:param name="percent" value="90" />
</p:effect>
</p:panel>
<p:panel id="bounce" header="Bounce">
<h:outputText value="click" />
<p:effect type="bounce" event="click" />
</p:panel>
<p:panel id="pulsate" header="Pulsate">
<h:outputText value="click" />
<p:effect type="pulsate" event="click" />
</p:panel>
<p:panel id="shake" header="Shake">
<h:outputText value="click" />
<p:effect type="shake" event="click" />
</p:panel>
<p:panel id="size" header="Size">
<h:outputText value="click" />
<p:effect type="size" event="click">
<f:param name="to" value="{width: 200,height: 60}" />
</p:effect>
</p:panel>
</h:panelGrid>
<h3>Target</h3>
<p:commandButton type="button" value="Show" style="display:block" icon="ui-icon-image">
<p:effect type="puff" event="click" for="img">
<f:param name="mode" value="'show'" />
</p:effect>
</p:commandButton>
<p:graphicImage id="img" name="demo/images/nature/nature1.jpg" style="display:none"/>
<h:form>
<h3>On Load</h3>
<p:messages id="messages" closable="true">
<p:effect type="pulsate" event="load" delay="500" />
</p:messages>
<p:panel id="panel" header="Message Effects" toggleable="true">
<h:panelGrid columns="2" cellpadding="5">
<p:outputLabel for="text" value="Type:" />
<p:inputText id="text" value="#{effectView.text}" required="true" />
<h:outputText />
<p:commandButton id="submit" value="Echo" actionListener="#{effectView.echo}" update="messages"/>
</h:panelGrid>
</p:panel>
</h:form
>
package org.primefaces.showcase.view.misc;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
#ManagedBean
public class EffectView {
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public void echo() {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("You said:'" + text + "'"));
}
}
http://www.primefaces.org/showcase/ui/misc/effect.xhtml
That's worked fine for me with a commandLink.

Unexpected result with h:dataGrid

The underlying code makes the look of two column table while there are four panelGroup's.
<h:panelGrid id="panel" columns="4" border="1" cellpadding="0" cellspacing="2">
<h:panelGroup><h:outputText value="#{ph.currentProduct.brand} #{ph.currentProduct.model}"/>
</h:panelGroup>
<h:panelGroup><h:outputText value="#{ph.currentProduct.price} грн"/>
</h:panelGroup>
<h:panelGroup>
Наличие:
<p:rating id="present" value="#{ph.currentProduct.present}" readonly="true" />
<p:tooltip for="present" value="test" />
</h:panelGroup>
<h:panelGroup>
<h:form id="buy_button" style="">
<h:inputHidden value="#{ph.productId}" />
<h:commandButton image="images/buy.png" action="#{ph.addToCart}" />
</h:form>
</h:panelGroup>
</h:panelGrid>
Why is it?

jsf page action listioner not working

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<h:head>
<title>Community</title>
</h:head>
<h:body>
<rich:panel>
<f:facet name="header">
<h:outputText value="Login form" />
</f:facet>
<h:form id="loginform">
<h:panelGrid columns="2" width="210">
<rich:validator id="loginformvalidate">
<h:outputText value="Username:" />
<h:inputText label="username" id="username" value="#{loginMB.username}" required="true" requiredMessage="user name is requried">
<f:validateLength minimum="5" />
</h:inputText>
<h:outputText value="Password" />
<h:inputSecret label="password" id="password" value="#{loginMB.password}" requiredMessage="password is requried">
<f:validateLength minimum="8" maximum="16" />
</h:inputSecret>
</rich:validator>
<rich:notifyMessages stayTime="2000" nonblocking="true" />
<f:facet name="footer">
<a4j:commandButton value="Login"/>
</f:facet>
</h:panelGrid>
</h:form>
</rich:panel>
<rich:panel>
<h:form id="Questions">
<rich:dataTable value="#{contentBean.questions}" var="list" id="question" >
<rich:column>#{list.QUserid.fname}</rich:column><br/>
<rich:column> <rich:collapsiblePanel expanded="false" header="#{list.questionValue}" switchType="client" onclick="#{contentBean.onclick(list.qid)}" >
<rich:accordion id="answer" switchType="ajax">
<a4j:repeat value="#{contentBean.ansList}" var="skinName" >
<rich:accordionItem name="#{skinName.ansDate}">
#{skinName.ansValue}
</rich:accordionItem>
</a4j:repeat>
</rich:accordion></rich:collapsiblePanel></rich:column>
<br/><rich:column>
  <h:commandButton value="Show popup">
        <rich:componentControl target="popup" operation="show">
            <a4j:param noEscape="true" value="event" />
            <rich:hashParam>
                <f:param name="width" value="500" />
                <f:param name="height" value="300" />
                <f:param name="minWidth" value="300" />
                <f:param name="minHeight" value="150" />
                <a4j:param noEscape="true" name="left" value="(jQuery(window).width()/2)-250" />
                <a4j:param noEscape="true" name="top" value="(jQuery(window).height()/2)-150" />
            </rich:hashParam>
        </rich:componentControl>
    </h:commandButton>
 <rich:popupPanel id="popup" modal="false" autosized="true" resizeable="false">
<f:facet name="header">
<h:outputText value="Add your answer" />
</f:facet>
<p>Enter your answer in less than 4000 char</p>
<p>
<h:inputTextarea id="answertxt" value="#{contentBean.ansvalue}" required="true" requiredMessage="this feild is required"/>
<h:commandButton value="Submit" onclick="#{rich:component('popup')}.hide(); return false;">
<a4j:actionListener for="Submit" listener="#{contentBean.addAnswer(list.QUserid,list.QGroupid, list)}"/>
</h:commandButton>
</p>
</rich:popupPanel>
</rich:column>
</rich:dataTable>
</h:form>
</rich:panel>
</h:body>
</html>
I am new to jsf and richfaces i am tring to create two panels in singles with different forms can i do that? the page worked until i have added new button which uses action listener in a popup window
i am getting following error
INFO: WEB0671: Loading application [My_community] at [/My_community]
INFO: My_community was successfully deployed in 19,911 milliseconds.
SEVERE: /index.xhtml #21,61 id="loginformvalidate" Unhandled by MetaTagHandler for type org.richfaces.component.behavior.ClientValidatorImpl
the page runs but submit button on popup generated action listener is not working
please let me know if i am doing any thing wrong
Are you sure, rich:validator can have children ? I think it should be inside the fields you want to validate:
<h:inputText label="username" id="username" value="#{loginMB.username}" required="true" requiredMessage="user name is requried">
<f:validateLength minimum="5" />
<rich:validator/>
</h:inputText>

How to render a panelGroup with a h:commandLink and f:ajax

I want to render a <h:panelGroup> when the user clicks on a <h:commandLink>.
I can make it work without ajax, but the whole page is refreshed. When I try to use <f:ajax>, then the action is not invoked.
How is this caused and how can I solve it?
Here is the code of my link:
<a4j:outputPanel>
<h:commandLink action="#{ObjetEleve.showInfosPersos}" style="text-decoration:none;">
<a4j:ajax event="click" render=":corps:panelInfos"/>
<a4j:outputPanel layout="block" styleClass="menu_item_static_header">
<h:panelGroup layout="block" styleClass="menu_item_static">
<h:outputText value="#{(ObjetEleve.displayModifications) ? 'Retour au mur' : 'Modifier mes informations'}" />
</h:panelGroup>
</a4j:outputPanel>
</h:commandLink>
</a4j:outputPanel>
And here is the code of the panel that I want to be rendered:
<h:panelGroup id="panelInfos">
<h:panelGroup id="infoPerso"
rendered="#{(ObjetEleve.displayModifications) ? true : false}"
layout="block">
<a4j:outputPanel id="infosPersos" layout="block">
<h:panelGrid width="580" columns="2" border="0">
<h:panelGrid id="panelInscription" columns="2" border="0"
cellspacing="0" cellpadding="0">
<a4j:outputPanel>
<h:outputText value="Nom" />
<h:outputText value="*" style="color:#ff0000;" />
</a4j:outputPanel>
<a4j:outputPanel>
<h:inputText id="nomInscription"
value="#{ObjetEleve.nom_eleve}" styleClass="inputbox"
required="true" requiredMessage="Nom obligatoire" />
</a4j:outputPanel>
<h:outputText value="" />
<h:outputText value="" />
<a4j:outputPanel>
<h:outputText value="Prénom" />
<h:outputText value="*" style="color:#ff0000;" />
</a4j:outputPanel>
<a4j:outputPanel>
<h:inputText id="pnomInscription"
value="#{ObjetEleve.prenom_eleve}" styleClass="inputbox"
required="true" requiredMessage="Prénom obligatoire" />
</a4j:outputPanel>
<h:outputText value="" />
<h:outputText value="" />
<a4j:outputPanel id="pwd">
<h:outputText value="Mot de passe" />
<h:outputText value="*" style="color:#ff0000" />
</a4j:outputPanel>
<a4j:outputPanel>
<h:inputSecret id="passwd" value="#{ObjetEleve.pwd_eleve}"
redisplay="true" styleClass="inputbox" required="true"
requiredMessage="Mot de passe obligatoire" />
</a4j:outputPanel>
<h:outputText value="" />
<h:outputText value="" />
<a4j:outputPanel id="classe">
<h:outputText value="Classe" />
<h:outputText value="*" style="color:#ff0000" />
</a4j:outputPanel>
<a4j:outputPanel>
<rich:select value="#{ObjetEleve.id_classe_eleve}">
<f:selectItems value="#{classeBean.classes}" var="classe"
itemValue="#{classe.id_classe}"
itemLabel="#{classe.nom_classe}" />
</rich:select>
</a4j:outputPanel>
<h:outputText value="" />
<h:outputText value="" />
<a4j:outputPanel>
<h:outputText value="E-Mail" />
<h:outputText value="*" style="color:#ff0000" />
</a4j:outputPanel>
<a4j:outputPanel>
<h:inputText id="email" size="30"
value="#{ObjetEleve.email_eleve}" styleClass="inputbox"
required="true" requiredMessage="Email obligatoire" />
</a4j:outputPanel>
<h:outputText value="" />
<h:outputText value="" />
<a4j:outputPanel>
<h:outputText value="Date de naissance" />
<h:outputText value="*" style="color:#ff0000" />
</a4j:outputPanel>
<a4j:outputPanel>
<rich:calendar value="#{ObjetEleve.date_naissance_eleve}"
required="true"
requiredMessage="Date de naissance obligatoire" />
</a4j:outputPanel>
<h:outputText value="" />
<h:outputText value="" />
<a4j:outputPanel>
<h:outputText value="" />
</a4j:outputPanel>
<a4j:outputPanel>
<h:commandButton value="Mettre à jour les informations"
styleClass="submitButton" />
</a4j:outputPanel>
<h:outputText value="" />
<h:outputText value="" />
</h:panelGrid>
</h:panelGrid>
</a4j:outputPanel>
</h:panelGroup>
</h:panelGroup>
You're overridding the default ajax event for action components, which is event="action" by a event="click". This way JSF won't queue the action event to the action method.
So, use event="action"
<a4j:ajax event="action" render=":corps:panelInfos"/>
or just remove it altogether, it's the default event already
<a4j:ajax render=":corps:panelInfos"/>
The same story applies to <f:ajax>.
See also:
What values can I pass to the event attribute of the f:ajax tag?

RequestScope bean and Prime Faces Collector

I got a problem. I have a bean CreateProjectBean which is RequestScope bean. I want to use Prime Faces component called Collector so i can dynamicly change in view createProject table groupRoleAdapters which is a field of CreateProjectBean. Unforuntely every time i click "add" or "remove" in collector, there is a new request being sent to bean, which means, that GroupRoleAdapters is being created once more - of course empty.
My collector code:
<p:panel header="Add group">
<h:panelGrid columns="2">
<h:outputLabel value="Group name: *" for="txt_title"></h:outputLabel>
<h:selectOneMenu id="groupMenu"
value="#{createProjectBean.groupRoleAdapter.groupName}">
<f:selectItems value="#{createProjectBean.groupNames}"
var="group" itemValue="#{group}" itemLabel="#{group}" />
</h:selectOneMenu>
<f:verbatim>
<br />
</f:verbatim>
<h:message styleClass="errorMessage" for="creationForm:groupMenu" />
<h:outputLabel value="Role name: *" for="txt_title"></h:outputLabel>
<h:selectOneMenu id="roleMenu"
value="#{createProjectBean.groupRoleAdapter.roleName}">
<f:selectItems value="#{createProjectBean.roleNames}" var="role"
itemValue="#{role}" itemLabel="#{role}" />
</h:selectOneMenu>
<f:verbatim>
<br />
</f:verbatim>
<h:message styleClass="errorMessage" for="creationForm:roleMenu" />
<f:verbatim>
<br />
</f:verbatim>
<p:commandButton value="Add" update="creationForm:out"
action="#{createProjectBean.reinit}">
<p:collector value="#{createProjectBean.groupRoleAdapter}"
addTo="#{createProjectBean.selectedGroupRoleAdapters}"/>
</p:commandButton>
</h:panelGrid>
</p:panel>
<f:verbatim>
<br />
</f:verbatim>
<p:outputPanel id="out">
<p:dataTable value="#{createProjectBean.selectedGroupRoleAdapters}"
var="groupRoleAdapter">
<p:column>
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<h:outputText value="#{groupRoleAdapter.groupName}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Role" />
</f:facet>
<h:outputText value="#{groupRoleAdapter.roleName}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Operation" />
</f:facet>
<p:commandLink value="Remove" update="creationForm:out">
<p:collector value="#{groupRoleAdapter}" removeFrom="#{createProjectBean.selectedGroupRoleAdapters}" />
</p:commandLink>
</p:column>
</p:dataTable>
</p:outputPanel>
I'd like to use the same instance of bean while adding and removing groupRoleAdapters from list selectedGroupRoleAdapters (represented by collector table), but create new instance of bean every time i try to create new project, so changing scope to sessionScope is not what i can accept.
Thanks in advance for every help.
I attach full code of that view:
<!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:p="http://primefaces.prime.com.tr/ui">
<ui:composition template="/templates/template.xhtml">
<ui:define name="head">
<title>Create Project</title>
<link rel="stylesheet" type="text/css"
href="#{facesContext.externalContext.requestContextPath}/styles/style.css" />
</ui:define>
<ui:define name="content">
<div class="mainTable">
<center><f:view>
<h:outputText id="error" rendered="false" />
<h:message styleClass="errorMessage" for="error" />
<h:form id="creationForm">
<h:panelGrid columns="2" width="420">
<h:panelGroup width="300">
<h:outputLabel styleClass="formLabel" value="Name: "></h:outputLabel>
</h:panelGroup>
<h:panelGroup>
<h:inputText styleClass="formField" id="name"
value="#{createProjectBean.project.name}" required="true">
<f:validateLength minimum="3" />
</h:inputText>
</h:panelGroup>
<f:verbatim>
<br />
</f:verbatim>
<h:message styleClass="errorMessage" for="creationForm:name" />
<h:panelGroup>
<h:outputLabel styleClass="formLabel" value="Short Name: " />
</h:panelGroup>
<h:panelGroup>
<h:inputText styleClass="formField" id="shortname"
value="#{createProjectBean.project.shortname}" required="false">
<f:validateLength maximum="8" />
</h:inputText>
</h:panelGroup>
<f:verbatim>
<br />
</f:verbatim>
<h:message styleClass="errorMessage" for="creationForm:shortname" />
<h:panelGroup>
<h:outputLabel styleClass="formLabel" value="Homepage: " />
</h:panelGroup>
<h:panelGroup>
<h:inputText styleClass="formField" id="homepage"
value="#{createProjectBean.project.homepage}" required="false">
</h:inputText>
</h:panelGroup>
<f:verbatim>
<br />
</f:verbatim>
<h:message styleClass="errorMessage" for="creationForm:hostname" />
<h:panelGroup>
<h:outputLabel styleClass="formLabel" value="Description: " />
</h:panelGroup>
<h:panelGroup>
<h:inputTextarea styleClass="formField" id="description"
value="#{createProjectBean.project.description}" required="false"
cols="50" rows="10" />
</h:panelGroup>
<f:verbatim>
<br />
</f:verbatim>
<h:message styleClass="errorMessage" for="creationForm:description" />
<h:panelGroup>
<h:outputLabel styleClass="formLabel" value="Plugins: " />
</h:panelGroup>
<h:selectManyListbox id="pluginBox"
value="#{createProjectBean.selectedPluginNames}">
<f:selectItems value="#{createProjectBean.pluginNames}"
var="plugin" itemValue="#{plugin}" itemLabel="#{plugin}" />
</h:selectManyListbox>
<f:verbatim>
<br />
</f:verbatim>
<h:message styleClass="errorMessage" for="creationForm:pluginBox" />
<h:panelGroup>
<h:outputLabel styleClass="formLabel" value="Tags: " />
</h:panelGroup>
<h:selectManyListbox id="tagBox"
value="#{createProjectBean.project.tags}">
<f:selectItems value="#{createProjectBean.allTags}" var="tag"
itemValue="#{tag}" itemLabel="#{tag.name}" />
</h:selectManyListbox>
<f:verbatim>
<br />
</f:verbatim>
<h:message styleClass="errorMessage" for="creationForm:tagBox" />
<f:verbatim>
<br />
</f:verbatim>
<p:panel header="Add group">
<h:panelGrid columns="2">
<h:outputLabel value="Group name: *" for="txt_title"></h:outputLabel>
<h:selectOneMenu id="groupMenu"
value="#{createProjectBean.groupRoleAdapter.groupName}">
<f:selectItems value="#{createProjectBean.groupNames}"
var="group" itemValue="#{group}" itemLabel="#{group}" />
</h:selectOneMenu>
<f:verbatim>
<br />
</f:verbatim>
<h:message styleClass="errorMessage" for="creationForm:groupMenu" />
<h:outputLabel value="Role name: *" for="txt_title"></h:outputLabel>
<h:selectOneMenu id="roleMenu"
value="#{createProjectBean.groupRoleAdapter.roleName}">
<f:selectItems value="#{createProjectBean.roleNames}" var="role"
itemValue="#{role}" itemLabel="#{role}" />
</h:selectOneMenu>
<f:verbatim>
<br />
</f:verbatim>
<h:message styleClass="errorMessage" for="creationForm:roleMenu" />
<f:verbatim>
<br />
</f:verbatim>
<p:commandButton value="Add" update="creationForm:out"
action="#{createProjectBean.reinit}">
<p:collector value="#{createProjectBean.groupRoleAdapter}"
addTo="#{createProjectBean.selectedGroupRoleAdapters}"/>
</p:commandButton>
</h:panelGrid>
</p:panel>
<f:verbatim>
<br />
</f:verbatim>
<p:outputPanel id="out">
<p:dataTable value="#{createProjectBean.selectedGroupRoleAdapters}"
var="groupRoleAdapter">
<p:column>
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<h:outputText value="#{groupRoleAdapter.groupName}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Role" />
</f:facet>
<h:outputText value="#{groupRoleAdapter.roleName}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Operation" />
</f:facet>
<p:commandLink value="Remove" update="creationForm:out">
<p:collector value="#{groupRoleAdapter}"
removeFrom="#{createProjectBean.selectedGroupRoleAdapters}" />
</p:commandLink>
</p:column>
</p:dataTable>
</p:outputPanel>
<f:verbatim>
<br />
</f:verbatim>
<h:commandButton value="Create" styleClass="formButton"
action="#{createProjectBean.create}" />
</h:panelGrid>
</h:form>
</f:view></center>
</div>
</ui:define>
</ui:composition>
</html>
If you're already on JSF 2.0, just put the bean in view scope, by either #ViewScoped annotation or by <managed-bean-scope>view</managed-bean-scope> in faces-config.xml.
If you're still on JSF 1.x (which I'm afraid of since you're using those ugly JSF 1.0/1.1-mandatory <f:verbatim> tags), then you have to either put bean in session scope, eventually in combination with an unique request scoped parameter which is retained in subsequent requests by h:inputHidden or f:param, or to grab a 3rd party library with a component which is able to save the state of an entire request scoped bean for the subsequent request, like Tomahawk's t:saveState.

Resources