dataTable selection

UI Components for JSF
Post Reply
wagner.montalvao
Posts: 15
Joined: 25 Oct 2009, 19:11

26 Oct 2009, 05:03

Hello again,

I am now trying the dataTable features and I have a few questions.

Let me show what I am doing:


<h:form id="userListForm" prependId="false">

<p:dataTable id="userList" value="#{userBean.users}" var="u" paginator="true" rows="10" width="100%"
selection="#{userBean.selectedUsers}" selectionMode="single" update="userForm" rendered="#{not empty userBean.users}">

<p:column resizable="true" sortable="true">
<f:facet name="header">
<h:outputText value="#{msg['user.name']}" />
</f:facet>
<h:outputText value="#{u.name}" />
</p:column>

</p:dataTable>

</h:form>
The UserBean

Code: Select all


@Name("userBean")
public class UserBean implements Serializable {
	
	private static final long serialVersionUID = 1L;

	@Out
	private List<User> users;
	
	private Object[] selectedUsers;

	//getters and setters...


1. I dont understand why the selectionMode="single" makes me set the selection attribute value to a primitive array of objects. Please excuse me to suggest another way to handle this. When using selectionMode="single", I think it would be better to allow the selection attribute value to be set to a single instance of any other type like a pojo class User.java, or even when using selectionMode="multiple", to a collection of users instead of a primitive array of users.

2. There are two attributes being ignored in here: dataTable width and column sortable.

3. Is already there a way to align an specific column header and/or body to the right?


Feedbacks about any of the issues above will be helpful

Thanks

WM
Last edited by wagner.montalvao on 28 Oct 2009, 18:03, edited 2 times in total.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

26 Oct 2009, 15:25

Thanks for your feedback Wagner,

1) That was our first intention but I remember hitting a limitation with this, I need to try again. But your suggestion totally makes sense.

2) Which version of primefaces are you using? sortable is replaced with sortedBy="EL" in 1.0.0.RC snapshot. About width, we need to replicate. Currently it can be done with css.

3) With css yes, there was a post related to it in forum. Skinning guide can help to find out where to apply text-align css rule.

http://developer.yahoo.com/yui/examples ... nning.html

wagner.montalvao
Posts: 15
Joined: 25 Oct 2009, 19:11

26 Oct 2009, 16:21

Hi civici, lets go:

1) I have added the primefaces svn repository to my svn client. Can you tell me where in the project is that limitation? I never worked in anything like this, but I would like to try to help.

2) I am using the 1.0.0 RC snapshot. I will replace sortable with sortedBy. About css, do we have available in all tags the basic properties: style for inline css and styleClass for css class names?

3) Thanks for the reference. I took a look at it but, will you add the same attributes of h:column to the p:column? - styleClass and headerStyle - They provide a quick way to customize an specific column only.

Have a nice week

WM

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

27 Oct 2009, 12:54

Hey Wagner,

1) Selection is set on decode phase of DataTableRenderer, at that phase the solution would be to get the type of the valueexpression of selection and do a cast to that type. I couldn't make it work back then though didn't spent a lot of time. For 1.0.0.RC datatable selection will be revised, these selection features are introduced in 0.9.3 so very new and there's room for improvement.

2 - 3) PrimeFaces seperates markup and javascript css so we usually avoid bloating components with *Class attributes since you can achieve the same thing with well defined css selectors.

wagner.montalvao
Posts: 15
Joined: 25 Oct 2009, 19:11

28 Oct 2009, 18:02

1) I took a look at the code and I guess the point is where you call getRequestParameterMap from ExternalContext. Well, I have no idea how to get the type of the valueexpression at that time, as it comes as String, but I will start looking for a way to do that. Please let me know if you achieve it before.

2 - 3) Ok, I will try using only the css selectors.

wagner.montalvao
Posts: 15
Joined: 25 Oct 2009, 19:11

04 Nov 2009, 14:08

Civici,

Please open this: http://code.google.com/p/primefaces/sou ... derer.java

Let's use this as a reference. Please go to line 102:

Code: Select all

return kid.getValueExpression("sortedBy");
Where the method getValueExpression comes from? I didn't find it. If it returns a ValueExpression (http://java.sun.com/javaee/5/docs/api/j ... ssion.html), couldn't we use its getType method to get the type we want? And then do the cast we talked before? Remember this topic is about the decode phase of the DataTableRenderer, when we were trying to enhance the selectionMode feature.

Regards

WM

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

06 Nov 2009, 02:25

Wagner, sortedBy has nothing to do with selection and yes there's a room for improvement in casting part, I'll look into this in detail before 1.0.0.RC gets released.

wagner.montalvao
Posts: 15
Joined: 25 Oct 2009, 19:11

06 Nov 2009, 14:48

Sorry, maybe I didn't explain well. I wasnt talking about the sortedBy exactly, I used it as an example, because in that case you get the valueexpression from a column that is also a UIComponent.

I came to think if it would be possible to get the valueexpression from the UIComponent you receive as a parameter in the decode phase of dataTable, then you could use the getType and do the dynamic cast. Is it clearer now?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

07 Nov 2009, 12:08

Yes as we've discussed before, that's my initial purpose do a dynamic cast but faced some problems with initial implementation. I'll look into this again before the release.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 30 guests