Hello,
I wonder why the sample in the showcase regards to ajax sorting doesn't have sortBy or sortFunction in attribute in columns?
http://www.primefaces.org:8080/prime-sh ... leAjax.jsf
DataTable Sorting
PrimeFaces 2.1
JSF 2.0
GlassFish 3 Server
Mojarra 2.0.2
JSF 2.0
GlassFish 3 Server
Mojarra 2.0.2
this is the correct XHTML code for the DataTable - Ajax Pagination/Sorting showcase
Code: Select all
<h:form>
<p:dataTable var="car" value="#{tableBean.cars}" dynamic="true"
paginator="true" rows="10">
<p:column sortBy="#{car.model}">
<f:facet name="header">
<h:outputText value="Model" />
</f:facet>
<h:outputText value="#{car.model}" />
</p:column>
<p:column sortBy="#{car.year}">
<f:facet name="header">
<h:outputText value="Year" />
</f:facet>
<h:outputText value="#{car.year}" />
</p:column>
<p:column sortBy="#{car.manufacturer}">
<f:facet name="header">
<h:outputText value="Manufacturer" />
</f:facet>
<h:outputText value="#{car.manufacturer}" />
</p:column>
<p:column sortBy="#{car.color}">
<f:facet name="header">
<h:outputText value="Color" />
</f:facet>
<h:outputText value="#{car.color}" />
</p:column>
</p:dataTable>
</h:form>
JSF-2.0, mojarra-2.0.2-FCS and PrimeFaces-2.1 on GlassFish v3.0.1 (build 22)
Thank you michiel,
I tried that code and I'm getting this weird behavior on sorting:
1. When I press the table header to sort, the data sorts accordingly.
2. When I press it again, the data will be gone and to other columns with sortBy attribute.
My dataTable is set to dynamic = true. I just want to ask if I'm missing something here why the data is gone for the second hit in sorting.
Thank you.
I tried that code and I'm getting this weird behavior on sorting:
1. When I press the table header to sort, the data sorts accordingly.
2. When I press it again, the data will be gone and to other columns with sortBy attribute.
My dataTable is set to dynamic = true. I just want to ask if I'm missing something here why the data is gone for the second hit in sorting.
Thank you.
PrimeFaces 2.1
JSF 2.0
GlassFish 3 Server
Mojarra 2.0.2
JSF 2.0
GlassFish 3 Server
Mojarra 2.0.2
you need to provide some more info.
are you getting any error?
is the showcase working for you?
any code (xhtml and managedBean), also the java code for the Object your trying to show/sort (like 'car' in the showcase)?
are you getting any error?
is the showcase working for you?
any code (xhtml and managedBean), also the java code for the Object your trying to show/sort (like 'car' in the showcase)?
JSF-2.0, mojarra-2.0.2-FCS and PrimeFaces-2.1 on GlassFish v3.0.1 (build 22)
Here's my xhtml:
The bean:
Thank you.
Code: Select all
<h:form>
<p:dataTable var="car" value="#{carBean.cars}"
rows="10"
paginator="true"
dynamic="true">
<p:column sortBy="#{car.model}">
<f:facet name="header">
<h:outputText value="Model"/>
</f:facet>
<h:outputText value="#{car.model}"/>
</p:column>
</p:dataTable>
</h:form>
Code: Select all
@ManagedBean(name = "carBean")
@SessionScoped
public class CarBean implements Serializable {
private List<Car> cars;
public List<Car> getCars() { return cars; }
public void setCars(List<Car> cars) { this.cars = cars; }
private Car car;
public Car getCar() { return car; }
public void setCar(Car car) { this.car = car; }
public CarBean() {
cars = new ArrayList<Car>();
populateCars(cars, 35);
}
private void populateCars(List<Car> cars, int size) {
for (int i = 0; i < size; i++) {
cars.add(new Car(createModel(i), 2010, createManufacturer(i), createColor(i)));
}
}
private String createModel(int i) {
return "model " + i * (Math.random() * 10);
}
private String createManufacturer(int i) {
return "manufacturer " + i * (Math.random() * 10);
}
private String createColor(int i) {
return "color #" + i + (Math.random() * 10);
}
}
PrimeFaces 2.1
JSF 2.0
GlassFish 3 Server
Mojarra 2.0.2
JSF 2.0
GlassFish 3 Server
Mojarra 2.0.2
Don't forgot to implement Serializable on your business model objects. (Car in this case)
view also http://primefaces.prime.com.tr/forum/vi ... f=3&t=2497
view also http://primefaces.prime.com.tr/forum/vi ... f=3&t=2497
JSF-2.0, mojarra-2.0.2-FCS and PrimeFaces-2.1 on GlassFish v3.0.1 (build 22)
Thank you michiel. My problem solved. Now I have another problem. Remote sorting doesn't work with LazyModel implemented bean.
PrimeFaces 2.1
JSF 2.0
GlassFish 3 Server
Mojarra 2.0.2
JSF 2.0
GlassFish 3 Server
Mojarra 2.0.2
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Lazy sorting is not supported yet but it will be in 2.1.1 release which is due August.
My project deadline is on August. Unlucky me.
PrimeFaces 2.1
JSF 2.0
GlassFish 3 Server
Mojarra 2.0.2
JSF 2.0
GlassFish 3 Server
Mojarra 2.0.2
-
- Information
-
Who is online
Users browsing this forum: Google [Bot] and 44 guests