0

i am trying to pass a parameter between two pages

in the bean i have this string with getters and setters outcome is the function to run with the button

@Named("MeubleBean")
@ManagedBean 
@SessionScoped 
@RequestScoped
public class MeubleBean implements Serializable {
 private String param1;

 public String outcome() {

FacesContext fc = FacesContext.getCurrentInstance();
Map<String, String> params = fc.getExternalContext().getRequestParameterMap();
param1 = params.get("param1Name");


return "meubles3.jsf?faces-redirect=true&includeViewParams=true";
}
}

the code of the command button in the page meubles.xhtml :

         <f:param id="param1" name="param1Name" value="param1Value"/>
            </h:commandButton>

and finally the output in meubles3.xhtml :

<h:form><h:outputText value="#{meubleBean.param1}"></h:outputText>
</h:form>

i am trying the "param1value" as test value . the output is always empty, i tried several ways none of em worked. any solution please ???

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • i have getters and setter and other code so i did not copy it, and i generated it automatically – Abdelhak Bouguila May 10 '20 at 22:48
  • 1
    You are mixing annotations. If you use the CDI annotation `@Named` you should not use `ManagedBean`. Use only one scope, request or session. – Holger May 11 '20 at 06:47
  • You are using `value="#{meubleBean.param1}"`, do you have a getter `getParam1()`? – Holger May 11 '20 at 06:52
  • Please always use good indentation in the code you post – Kukeltje May 11 '20 at 09:43
  • @Holger yes i do have getters and setters and i generated it automatically, i actually almost copied and pasted this code from a tutorial. and i used the named because without it it wasn't detecting the bean . by the way, i can read variables the get is working but i can't set em. – Abdelhak Bouguila May 11 '20 at 20:12

0 Answers0