This question already has answers here:
commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
(12 answers)
Validation Error: Value is not valid
(3 answers)
How to use enum values in f:selectItem(s)
(4 answers)
Closed 3 years ago.
I'm facing some problems with this widget:
<h:panelGroup>
<p:selectOneRadio required="true"
requiredMessage="Seleziona un elemento"
value="#{createCustomerView.customer.humanSex}">
<f:selectItems value="#{createCustomerView.values}"
var="humanSex" itemValue="humanSex"
itemLabel="#{humanSex.label}" />
</p:selectOneRadio>
</h:panelGroup>
The problem is that the value is not set into my instance of customer. Where am I wrong? This is the enum used in the selection for the user
public enum HumanSex {
MAN(1, "Maschio"), WOMAN(2, "Femmina");
public int id;
public String label;
private HumanSex(int id, String label) {
this.id = id;
this.label = label;
}
private HumanSex() {
}
//SET and GETTERS
}
Related
This question already has answers here:
Does f:viewParam only pass query string in url when first page uses the same managed bean as the second page?
(2 answers)
Bookmarkability via View Parameters feature
(1 answer)
Closed 2 years ago.
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 ???
This question already has answers here:
javax.el.PropertyNotFoundException: Property 'foo' not found on type com.example.Bean
(6 answers)
Naming convention for getters/setters in Java
(7 answers)
Closed 2 years ago.
Hello i keep getting this warning for 4 attributes.
the one in the .xhtml is
First Name : <h:inputText value="#{projectBean.fname}" id="fname" required="true" requiredMessage=" Firstname is required"></h:inputText>
<h:message for="fname" styleClass="error"></h:message>
and the one in the bean is
private String fname;
public String getfName() {
return fname;
}
public void setfName(String fname) {
this.fname = fname;
}
the warning im getting
fname cannot be resolved as a member of projectBean
What seems to be the problem?
This question already has answers here:
commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
(12 answers)
Validation Error: Value is not valid
(3 answers)
How to populate options of h:selectOneMenu from database?
(5 answers)
Closed 5 years ago.
I am trying to perform ajax on selecting any element in selectCheckBoxMenu primefaces.
But ajax event fires only if itemValue is equal to String. If i am passing object then not event is fired. Please have a look.
package com.gsep.utility.bean;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
#ManagedBean
#Entity
#ViewScoped
public class Tool {
#Id #GeneratedValue
#Column(name="tool_id")
private int toolId;
#Column(name="tool_name")
private String toolName;
public int getToolId() {
return toolId;
}
public void setToolId(int toolId) {
this.toolId = toolId;
}
public String getToolName() {
return toolName;
}
public void setToolName(String toolName) {
this.toolName = toolName;
}
}
Above is my bean class which i am iterating to display values in selectCheckboxMenu.
Below is jsf code
<p:selectCheckboxMenu id="multiple" value="#{projectBean.selectedToolList}" label="Tools" multiple="true"
filter="true" filterMatchMode="startsWith" panelStyle="width:250px" >
<f:selectItems value="#{projectBean.toolList}" var="toolObject" itemLabel="#{toolObject.toolName}" itemValue="#{toolObject}" />
<p:ajax update="projectRequestForm:testTabView" listener="#{projectBean.addTab(requestBean,projectBean)}" />
</p:selectCheckboxMenu>
Here if i am changing itemValue attribute to toolObject.toolName then ajax call is happening but i want the selectedToolList as a Tool collection of objects instead of toolName collection of Strings.
#ManagedBean(name = "projectBean")
#ViewScoped
public class ProjectBeanCompUI {
#ManagedProperty(value="#{jiraDao}")
private JiraProjectDAO jiraDao;
private List<Tool> toolList;
private List<String> selectedToolList;
public List<Tool> getToolList() {
toolList = getTools();
return toolList;
}
public void setToolList(List<Tool> toolList) {
this.toolList = toolList;
}
public List<String> getSelectedToolList() {
return selectedToolList;
}
public void setSelectedToolList(List<String> selectedToolList) {
this.selectedToolList = selectedToolList;
public List<Tool> getTools()
{
List<Tool> toolList = new ArrayList<>();
Tool tool = new Tool();
tool.setToolId(1);
tool.setToolName("Eclipse");
Tool tool1 = new Tool();
tool1.setToolId(2);
tool1.setToolName("Jira");
toolList.add(tool);
toolList.add(tool1);
return toolList;
}
}
This question already has answers here:
commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
(12 answers)
Closed 5 years ago.
I'm using netbeans with glassfish
In my .xhtml file, a have a link which I expect to call action shopBean.instructorScheduleById()
<p:commandLink styleClass="tooltip tour-sched"
rendered="#{shopBean.instructorSchedule!=null}"
update=":dialogFormTS" action="#
{shopBean.instructorScheduleById()}"
oncomplete="dlgTS.show()" process="#this"
ajax="true">TS<h:outputText styleClass="tooltiptext"
value="#{shopBean.instructorSchedule.name}"/>
</p:commandLink>
Bean file
#ManagedBean(name = "shopBean")
#SessionScoped
public class ShopBean {
public ShopBean() {}
public void getInstructorScheduleById(){
System.out.println("hello");
}
}
I looked to my Developer tools under network i see there is an ajax request but when i looked on glassfish output, there's no word hello
Base on what i have learned here at stackoverflow, the get prefix is used for getter methods which means it must have a return value.
public void sum(){
int num1 = 1;
int num2 = 2;
System.out.println(num1 + num2);
}
// xhtml
<p:commandButton action="#{bean.sum()}" />
if you want get the value from a getter method:
pivate int sum;
public int getSum(){
return this.sum;
}
public void setSum(sum){
this.sum = sum;
}
// xhtml
<p:outputText value="#{bean.sum}" />
The quick solution for your problem is to remove the get prefix in your
bean.
This question already has answers here:
javax.el.PropertyNotFoundException: The class 'xxx' does not have a readable property 'yyy'
(2 answers)
Closed 7 years ago.
(intro: I have generated Entity Clases from DB with one tabe lets say Beans, so it generated me Beans.java, BeansFacade.java, BeansController.java and AbstracFacade.java than I added JSF pages from entity classes, and just want to add something to list.xhtml)
In my BeansFacade.java I have
public String simple(){
return "output";
}
In BeansController.java I hava
public String printSimple(){
return ejbFacade.simple();
}
And than whem I try to print that
<h:outputText value="#{beansController.printSimple}"> </h:outputText>
I get an error
javax.el.PropertyNotFoundException:
The class 'fct.entity.EventsController' does not have the property 'printSimple'.
You are not able to call the method in h:outputText.
h:outputText tries to search the given variable related getter/setter
private String printSimple;
public String getPrintSimple()
{
return ejbFacade.simple();;
}
/**
* #return the simple
*/
public String getSimple()
{
return simple;
}
And than whem you can use the simple variable to get the value.
<h:outputText value="#{beansController.printSimple}"> </h:outputText>
before that call the printSimple method.