Bean imbriqués ne fonctionnant pas
Bonjour,
J'essai d'utiliser plusieurs Beans à la fois, mais je plante lods de la création dans le formulaire :
manageApplication.xhtml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
<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:p="http://primefaces.org/ui">
<h:form>
<p:menubar id="menu" autoSubmenuDisplay="true">
<p:menuitem value="Acceuil"
actionListener="#{applicationWizard.showHomePanel}"
icon="ui-icon-home" update="@form" />
<p:submenu label="Séléction" icon="ui-icon-gear">
<p:menuitem value="Séléctionner"
actionListener="#{applicationWizard.showSelectionPanel}"
update="@form" />
<p:menuitem value="Créer"
actionListener="#{applicationWizard.showCreationPanel}"
update="@form" />
</p:submenu>
</p:menubar>
<p></p>
<p:panel>
<p:outputPanel widgetVar="homePanel"
rendered="#{applicationWizard.viewHomePanel}" autoUpdate="true">
l33t
</p:outputPanel>
<p:outputPanel widgetVar="creationPanel"
rendered="#{applicationWizard.viewCreationPanel}" autoUpdate="true">
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Référence :" />
<p:inputText value="#{createApplicationBean.reference}"
style="width:300px;" />
<h:outputText value="Client :" />
<p:selectOneMenu value="#{createApplicationBean.customer}"
converter="customerConverter" style="width:300px;">
<f:selectItem itemValue="" itemLabel="Selectionner" />
<f:selectItems value="#{createApplicationBean.customers}"
var="customer" itemLabel="#{customer.displayed}"
itemValue="#{customer}" />
</p:selectOneMenu>
<h:outputText value="Type d'application :" />
<p:selectOneMenu value="#{createApplicationBean.applicationType}"
converter="applicationTypeConverter" style="width:300px;">
<f:selectItem itemValue="" itemLabel="Selectionner" />
<f:selectItems value="#{createApplicationBean.applicationTypes}"
var="applicationType" itemLabel="#{applicationType.displayed}"
itemValue="#{applicationType}" />
</p:selectOneMenu>
<h:outputText value="Famille d'application :" />
<p:selectOneMenu
value="#{createApplicationBean.applicationFamily}"
converter="applicationFamilyConverter" style="width:300px;">
<f:selectItem itemValue="" itemLabel="Selectionner" />
<f:selectItems
value="#{createApplicationBean.applicationFamilies}"
var="applicationFamily"
itemLabel="#{applicationFamily.displayed}"
itemValue="#{applicationFamily}" />
</p:selectOneMenu>
<h:outputText value="Pression :" />
<p:selectOneMenu value="#{createApplicationBean.pressure}"
converter="pressureConverter" style="width:300px;">
<f:selectItem itemValue="" itemLabel="Selectionner" />
<f:selectItems value="#{createApplicationBean.pressures}"
var="pressure" itemLabel="#{pressure.displayed}"
itemValue="#{pressure}" />
</p:selectOneMenu>
<h:outputText value="Fluide :" />
<p:selectOneMenu value="#{createApplicationBean.fluid}"
converter="fluidConverter" style="width:300px;">
<f:selectItem itemValue="" itemLabel="Selectionner" />
<f:selectItems value="#{createApplicationBean.fluids}"
var="fluid" itemLabel="#{fluid.displayed}" itemValue="#{fluid}" />
</p:selectOneMenu>
<h:outputText value="Cylindrée :" />
<p:selectOneMenu value="#{createApplicationBean.cylinder}"
converter="cylinderConverter" style="width:300px;">
<f:selectItem itemValue="" itemLabel="Selectionner" />
<f:selectItems value="#{createApplicationBean.cylinders}"
var="cylinder" itemLabel="#{cylinder.displayed}"
itemValue="#{cylinder}" />
</p:selectOneMenu>
<h:outputText value="Fonctionnement :" />
<p:selectOneMenu value="#{createApplicationBean.working}"
converter="workingConverter" style="width:300px;">
<f:selectItem itemValue="" itemLabel="Selectionner" />
<f:selectItems value="#{createApplicationBean.workings}"
var="working" itemLabel="#{working.displayed}"
itemValue="#{working}" />
</p:selectOneMenu>
<h:outputText value="Condensateur permanent :" />
<p:inputText value="#{createApplicationBean.permanentCapacitor}"
style="width:300px;" />
<h:outputText value="Condensateur de démarrage mini :" />
<p:inputText value="#{createApplicationBean.miniCapacitorStart}"
style="width:300px;" />
<h:outputText value="Condensateur de démarrage maxi :" />
<p:inputText id="createApplicationMaxiCapacitorStart"
value="#{createApplicationBean.maxiCapacitorStart}"
style="width:300px;" />
<p:commandButton value="Créer" icon="ui-icon-check"
actionListener="#{createApplicationBean.create}" />
</h:panelGrid>
</h:form>
</p:outputPanel>
<p:outputPanel widgetVar="selectionPanel"
rendered="#{applicationWizard.viewSelectionPanel}" autoUpdate="true">
w00t w00t
</p:outputPanel>
</p:panel>
</h:form>
</ui:composition> |
manageApplication.xhtml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
package org.bean;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
import org.config.Tracer;
import org.objects.ApplicationFamily;
import org.objects.ApplicationType;
import org.objects.Customer;
import org.objects.Cylinder;
import org.objects.Fluid;
import org.objects.Pressure;
import org.objects.Ventilation;
import org.objects.Working;
@ManagedBean ( name = "createApplicationBean" )
public class CreateApplicationBean implements ActionListener {
private String reference;
private Customer customer;
private ApplicationType applicationType;
private ApplicationFamily applicationFamily;
private Pressure pressure;
private Fluid fluid;
private Cylinder cylinder;
private Ventilation ventilation;
private Working working;
private float permanentCapacitor;
private float miniCapacitorStart;
private float maxiCapacitorStart;
public Working getWorking () {
return working;
}
public void setWorking ( Working working ) {
System.out.println("CreateApplicationBean.setWorking");
this.working = working;
}
public Cylinder getCylinder () {
return cylinder;
}
public void setCylinder ( Cylinder cylinder ) {
System.out.println("CreateApplicationBean.setCylinder");
this.cylinder = cylinder;
}
public List<Cylinder> getCylinders () {
return Cylinder.getAll();
}
public Fluid getFluid () {
return fluid;
}
public void setFluid ( Fluid fluid ) {
System.out.println("CreateApplicationBean.setFluid");
this.fluid = fluid;
}
public List<Fluid> getFluids () {
return Fluid.getAll();
}
public Pressure getPressure () {
return pressure;
}
public void setPressure ( Pressure pressure ) {
System.out.println("CreateApplicationBean.setPressure");
this.pressure = pressure;
}
public List<Pressure> getPressures () {
return Pressure.getAll();
}
public ApplicationFamily getApplicationFamily () {
return applicationFamily;
}
public void setApplicationFamily ( ApplicationFamily applicationFamily ) {
System.out.println("CreateApplicationBean.setApplicationFamily");
this.applicationFamily = applicationFamily;
}
public List<Ventilation> getVentilations () {
return Ventilation.getAll();
}
public List<ApplicationFamily> getApplicationFamilies () {
return ApplicationFamily.getAll();
}
public List<ApplicationType> getApplicationTypes () {
return ApplicationType.getAll();
}
public List<Customer> getCustomers () {
return Customer.getAll();
}
public List<Working> getWorkings () {
return Working.getAll();
}
public String getReference () {
return reference;
}
public void setReference ( String reference ) {
System.out.println("CreateApplicationBean.setReference");
this.reference = reference;
}
public Customer getCustomer () {
return customer;
}
public void setCustomer ( Customer customer ) {
System.out.println("CreateApplicationBean.setCurstomer");
this.customer = customer;
}
public ApplicationType getApplicationType () {
return applicationType;
}
public void setApplicationType ( ApplicationType applicationType ) {
System.out.println("CreateApplicationBean.setApplicationType");
this.applicationType = applicationType;
}
public Ventilation getVentilation () {
return ventilation;
}
public void setVentilation ( Ventilation ventilation ) {
System.out.println("CreateApplicationBean.setVentilation");
this.ventilation = ventilation;
}
public float getPermanentCapacitor () {
return permanentCapacitor;
}
public void setPermanentCapacitor ( float permanentCapacitor ) {
System.out.println("CreateApplicationBean.setPermanentCapacitor");
Tracer.println("CreateApplicationBean.create");
this.permanentCapacitor = permanentCapacitor;
}
public float getMiniCapacitorStart () {
return miniCapacitorStart;
}
public void setMiniCapacitorStart ( float miniCapacitorStart ) {
Tracer.println("CreateApplicationBean.create");
this.miniCapacitorStart = miniCapacitorStart;
}
public float getMaxiCapacitorStart () {
return maxiCapacitorStart;
}
public void setMaxiCapacitorStart ( float maxiCapacitorStart ) {
Tracer.println("CreateApplicationBean.create");
this.maxiCapacitorStart = maxiCapacitorStart;
}
public void create ( ActionEvent actionEvent ) {
Tracer.println("CreateApplicationBean.create");
System.out.println("CreateApplicationBean.create");
FacesMessage msg = null;
msg = new FacesMessage(FacesMessage.SEVERITY_FATAL,
"Erreur lors de la création.", "");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
@Override
public void processAction ( ActionEvent event )
throws AbortProcessingException {
Tracer.println("CreateApplicationBean.processAction");
}
} |
ApplicationWizard.java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
package org.wizard;
import java.awt.event.ActionEvent;
import javax.faces.bean.ManagedBean;
import org.objects.Application;
@ManagedBean
public class ApplicationWizard {
private Application selectionnedApplication ;
private boolean viewHomePanel = true;
private boolean viewCreationPanel = false;
private boolean viewSelectionPanel = false;
public Application getSelectionnedApplication() {
return selectionnedApplication;
}
public void setSelectionnedApplication(Application selectionnedApplication) {
this.selectionnedApplication = selectionnedApplication;
}
public void showHomePanel ( ActionEvent evt ) {
showHomePanel ();
}
public void showHomePanel () {
this.viewHomePanel = true ;
this.viewCreationPanel = false ;
this.viewSelectionPanel = false ;
}
public boolean isViewHomePanel() {
return viewHomePanel;
}
public void setViewHomePanel(boolean viewHomePanel) {
this.viewHomePanel = viewHomePanel;
}
public void showCreationPanel ( ActionEvent evt ) {
showCreationPanel ();
}
public void showCreationPanel () {
this.viewHomePanel = false ;
this.viewCreationPanel = true ;
this.viewSelectionPanel = false ;
}
public boolean isViewCreationPanel() {
return viewCreationPanel;
}
public void setViewCreationPanel(boolean viewCreationPanel) {
this.viewCreationPanel = viewCreationPanel;
}
public void showSelectionPanel ( ActionEvent evt ) {
showSelectionPanel ();
}
public void showSelectionPanel () {
this.viewHomePanel = false ;
this.viewCreationPanel = false ;
this.viewSelectionPanel = true ;
}
public boolean isViewSelectionPanel() {
return viewSelectionPanel;
}
public void setViewSelectionPanel(boolean viewSelectionPanel) {
this.viewSelectionPanel = viewSelectionPanel;
}
} |
Le truc est que quand je n'utilise que l'un des deux, celui que j'utilise fonctionne...
N'avez vous pas une solution pour moi ? :calim2: