I need help with passing a query parameter into my next JSF page. I have tried everything and I am stuck. I'm able to retrieve the param in the second page if i type the url myself. Example: localhost:8080/devices?propId=24&faces-redirect=true from a primefaces commandButton action. But if i try to do it dynamically, i get an error like: Not a Valid Method Expression: property/devices?propId=#{recentPropertyFEnd.selected.idpropertytable}&faces-redirect=true.
I have tried everything. f:param, f:viewParam, etc. but nothings works.
I guess the question is, what is the right way to send query params from a commandButton in JSF?
command button from first page:
<p:commandButton value="Show Devices" action="property/devices?propId=#{recentPropertyFEnd.selected.idpropertytable}&faces-redirect=true"> </p:commandButton>
second page f:viewParam:
<f:metadata>
<f:viewParam name="propId" value="#{deviceFEnd.propId}"/>
<f:viewAction action="#{deviceFEnd.actioncheck()}" />
</f:metadata>
manage bean second page:
@Named(value = "deviceFEnd")
@RequestScoped
public class DeviceFEnd implements Serializable {
private int propId;
public DeviceFEnd() {
}
public int getPropId() {
return propId;
}
public void setPropId(int propId) {
this.propId = propId;
}
public void actioncheck() {
int x = 0;
x++;
}
@PostConstruct
public void init() {
}
}
Like i said, if i type it myself in the action commandButton works, but if i tried to use a value from a bean fails. Please help...