• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jsf error in <h:commandlink>

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ,i am implementing code of edit/update row of datatable in jsf .i am posting code .please help me as early as possible due to dead lines

package org.demo;

import java.util.ArrayList;
import java.util.Arrays;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean(name="order")
@SessionScoped

public class OrderBean
{
private int pid;
private String name;
private int price;
boolean editable;

public OrderBean() { }
public OrderBean(int pid,String name,int price)
{
this.pid=pid;
this.name=name;
this.price=price;


}


public boolean isEditable() {
return editable;
}
public void setEditable(boolean editable) {
this.editable = editable;
}

public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}







private static final ArrayList<OrderBean> orderList =new ArrayList<OrderBean>(Arrays.asList(

new OrderBean(101,"Rice",1100),
new OrderBean(102,"oil",1400),
new OrderBean(103,"a",1000),
new OrderBean(104,"b",600),
new OrderBean(105,"c",700)
));

public ArrayList<OrderBean> getOrderList() {

return orderList;

}

public String addAction()
{

OrderBean order = new OrderBean(this.pid, this.name,
this.price);

orderList.add(order);

return null;


}

public String saveAction() {

//get all existing value but set "editable" to false
for (OrderBean order : orderList){
order.setEditable(false);
}
//return to current page
return null;

}
public String deleteAction(OrderBean order) {

orderList.remove(order);
return null;
}

public String editAction(OrderBean order)
{

//order.setEditable(true);
order.setEditable(true);

return null;
}


}


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="/WEB-INF/templates/template.xhtml">
<ui:param name="title" value="Applicant System" />

<ui:define name="header">
<h:graphicImage library="images" name="icefaces.png"/>
</ui:define>

<ui:define name="menu">
<h:button outcome="applicants" value="Listing Page" />
</ui:define>

<ui:define name="content">
<h:head>
<h:outputStylesheet library="css" name="template.css" />


<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">



$(document).ready(function()
{
$('#output').click(function(event) {

alert("inside jquery");
$.ajax({
url: "data.jsf",
type: "POST",
data:{pid:$('#pid'),name:$('#name'),price:$('#price')},
dataType: "json",
success : function(data)
{
alert("inside success");
}
});
};

});
});

</script>


</h:head>
<h:form id="f1" prependId="false">
<h:messages globalOnly="true" />
<h:panelGroup id="table" layout="block" >
<table>


<tr>
<td>
<h:outputLabel value="Product id :"></h:outputLabel>
</td>

<td>
<h:inputText id="pid"
value="#{order.pid}"
required="true" >

</h:inputText>
</td>

</tr>

<tr>
<td>
<h:outputLabel value="Product Name:"></h:outputLabel>
</td>
<td>
<h:inputText id="name"
value="#{order.name}"
required="true" >

</h:inputText>
</td>

</tr>

<tr>
<td>
<h:outputLabel value="Product Price:"></h:outputLabel>
</td>

<td>
<h:inputText id="price"
value="#{order.price}"
required="true" >

</h:inputText>
</td>

</tr>
<tr>
<td>

<h:commandButton id="output" value="Add" action="#{order.addAction}"/>

</td>


</tr>
</table>



</h:panelGroup>

<h:dataTable value="#{order.orderList}" var="o"
styleClass="order-table"
headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row" border="2">

<h:column>

<f:facet name="header">Order No</f:facet>

<h:inputText value="#{o.pid}" size="10" rendered="#{o.editable}" />

<h:outputText value="#{o.pid}" rendered="#{not o.editable}" />

</h:column>

<h:column>

<f:facet name="header">Product Name</f:facet>

<h:inputText value="#{o.name}" size="20" rendered="#{o.editable}" />

<h:outputText value="#{o.name}" rendered="#{not o.editable}" />

</h:column>

<h:column>

<f:facet name="header">Price</f:facet>

<h:inputText value="#{o.price}" size="10" rendered="#{o.editable}" />

<h:outputText value="#{o.price}" rendered="#{not o.editable}" />

</h:column>


<h:column>
<f:facet name="header">Action</f:facet>

<h:commandLink value="Edit" action="#{order.editAction(o)}"
rendered="#{not o.editable}" />


</h:column>

<h:column>

<f:facet name="header">Action</f:facet>

<h:commandLink value="Delete"
action="#{order.deleteAction(o)}" /> //Error on this line
Method must have signature "String method(), String method(), String method(String), String method(String,
String), String method(String, String, String), String method(String, String, String, String), String method(String,
String, String, String, String), String method(String, String, String, String, String, String), String method(String,
String, String, String, String, String, String), String method(String, String, String, String, String, String, String,
String), String method(String, String, String, String, String, String, String, String, String), String method(String,
String, String, String, String, String, String, String, String, String), String method(String, String, String, String,
String, String, String, String, String, String, String), String method(String, String, String, String, String, String,
String, String, String, String, String, String), String method(String, String, String, String, String, String, String,
String, String, String, String, String, String), String method(String, String, String, String, String, String, String,
String, String, String, String, String, String, String), String method(String, String, String, String, String, String,
String, String, String, String, String, String, String, String, String), String method(String, String, String, String,
String, String, String, String, String, String, String, String, String, String, String, String), String method(String,
String, String, String, String, String, String, String, String, String, String, String, String, String, String, String,
String), String method(String, String, String, String, String, String, String, String, String, String, String, String,
String, String, String, String, String, String), String method(String, String, String, String, String, String, String,
String, String, String, String, String, String, String, String, String, String, String, String)" but has signature "String
method(OrderBean)"

</h:column>


</h:dataTable>

<h:commandButton value="Save Changes" action="#{order.saveAction}" />

</h:form>
</ui:define>

</ui:composition>
</html>

 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use code tags when posting code.

What EL version are you using?
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Code tags (use the "Code" button on our message editor UI) will make your sample code and XML easier for us to read. Also, remove any irrelevant code/data from your sample. When a sample won't fit on my screen, I tend not to give it as much attention.

Use of the "$" JQuery shorthand can lead to problems on JSF pages, since "$" is also an EL marker. Use the alternative "jQuery." form, instead.

Finally, EL is not intended to be used as a programming language. The form

is bad practice even when you are using valid parameters. Which you are not. The action attribute is supposed to be a reference to a backing bean method, and not a direct call to the method. Action methods are expected to get their parameters directly from the Model (backing bean), not from the View.
 
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic