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 196 197 198 199 200
|
package open.ged.jsf;
import com.open.survey.oracle.EticLogs;
import com.open.survey.oracle.EticQuestions;
import com.open.survey.oracle.EticThemes;
import com.open.survey.oracle.service.EticLogsFacadeLocal;
import com.open.survey.oracle.service.EticQuestionsFacadeLocal;
import com.open.survey.oracle.service.EticThemesFacadeLocal;
import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import open.session.entities.ConfigurationSession;
/**
*
* @author olivier
*/
@ManagedBean(name = "QuestionnaireControler")
@RequestScoped
public class QuestionnaireControler implements Serializable {
private String theme;
public String question;
private Map<String,String> questions;
private List<SelectItem> questionsitems;
private List<EticQuestions> listeQuestionsLocal;
private EticQuestions questionLocal;
private boolean themeactif=true;
@ManagedProperty("#{configurationSession}") <-- injection qui semble fonctionnée mais retourne rien qaund je fais getDegre
ConfigurationSession configsession;
@EJB
EticLogsFacadeLocal eticlog;
/*@EJB
FaitEtabBeanLocal eticfait;*/
@EJB
EticQuestionsFacadeLocal eticquestions;
@EJB
EticThemesFacadeLocal eticthemes;
private String intitule ="Ajouter un thème";
/**
* Creates a new instance of QuestionnaireControler
*/
public QuestionnaireControler() {
questionLocal = new EticQuestions();
questionLocal.setLibelleQuestion("Saisir votre intitulé");
}
@PostConstruct
public void init(){
System.out.println(" Initialisation "+ configsession.getDegre()); --> me renvoie null ???
}
/**
* Inject ManagedBean dans la session
* @return
*/
public ConfigurationSession getConfigsession() {
return configsession;
}
public void setConfigsession(ConfigurationSession configsession) {
this.configsession = configsession;
}
/**
* Method setTheme
* @param theme
*/
public void setTheme(String theme) {
this.theme = theme;
}
public String getTheme() {
return theme;
}
public String getQuestion() {
return question;
}
public boolean isThemeactif() {
return themeactif;
}
public void setThemeactif(boolean themeactif) {
this.themeactif = themeactif;
}
public String getButtonTheme(){
if(this.getTheme()!= null){
intitule = "Modifier le thème";
}
return intitule;
}
/**
*
* @param buttontheme
*/
public void setButtonTheme(String buttontheme){
this.intitule = buttontheme;
}
/**
* Mise à jour d'une question
* @param question
*/
public void setQuestion(String question) {
this.question = question;
}
public List<EticQuestions> getListeQuestionsLocal() {
return listeQuestionsLocal;
}
public void setListeQuestionsLocal(List<EticQuestions> listeQuestionsLocal) {
this.listeQuestionsLocal = listeQuestionsLocal;
}
/**
Génération et stockage pour une question
*/
public EticQuestions getQuestionLocal() {
return questionLocal;
}
public void setQuestionLocal(EticQuestions questionLocal) {
this.questionLocal = questionLocal;
}
public String getCreateTheme(){
//check if null?
if("".equals(theme) || theme ==null){
return "";
}else{
return "Création du thème " + theme;
}
}
public void QuestionsMap(){
questions = new LinkedHashMap<String, String>();
questions.put("Radio bouton, choix unique", "essai 1");
questions.put("Questions à choix multiples", "essai 2");
questions.put("Questions avec champ texte", "essai 3");
List<EticLogs> logslocal = eticlog.findAll();
for (EticLogs eticLogs : logslocal) {
System.out.println(eticLogs.getEmail());
}
/*eticfait.getCube();*/
}
public void setQuestionsitems(List<SelectItem> questionsitems) {
this.questionsitems = questionsitems;
}
/**
* Methode pour l'affichage des options
* @return List<SelectItem>
*/
public Map<String,String> getQuestionsitems() {
this.QuestionsMap();
return questions;
}
public void changeQuestion(){
System.out.println("la question "+this.question);
}
public String getSayWelcome(){
//check if null?
if("".equals(theme) || theme ==null){
return "";
}else{
return "Thème : " + theme;
}
}
/**
* Récupération de toute la liste des questions
* On utilise un datable de primefaces pour l'affichage des données.
* @return List<EticQuestions>
*/
public List<EticQuestions> getQuestionsList(){
return eticquestions.findAll();
}
/**
* Retourne la liste des themes, pour un tableau
* @return List<EticThemes>
*/
public List<EticThemes> getThemesList(){
System.out.println(" config session " + configsession.getDegre());
return eticthemes.findAllByDegre("deg1");
}
} |