You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Ali Ok <al...@aliok.com.tr> on 2010/06/21 01:36:05 UTC

Trouble getting the value of a value expression in a datatable

Hi,

I am having problems with getting the value of an expression within a
datatable with my custom component.

Let me write the code:
<h:dataTable value="#{dndBean.teams}" var="team">
<h:column>
<hx:div>
<fx:dragSource action="move" param="#{team.id}" /> <!-- evaluates to empty
string -->
<h:outputText value="#{team.id}" />   <!-- renders the correct id -->
</hx:div>
</h:column>
</h:dataTable>

dndBean: managed bean
dndBean.teams: List<SportsTeam>, where SportsTeam has a public String
getId() method
team: var of datatable

I am getting a value of empty string for #{team.id} in the facelet handler
of fx:dragSource, if I put the fx:dragSource in a h:dataTable.
In the apply method of handler, I am trying to get the value as
_param.getValue(faceletContext)  //use this method since deferredValueType
of _param is String

where _param is
@JSFFaceletAttribute(name = "param", className = "javax.el.ValueExpression",
deferredValueType = "java.lang.String")
private final TagAttribute _param;

If I put the fx:dragSource somewhere else, I am getting the correct value at
the handler:
<h:form>
<hx:div>
 <fx:dragSource action="move" param="#{lakers.id}" />
</hx:div>
</h:form>

Why can this be happening?

One more hint, for the first case if I try to get the value at the handler,
I get empty string.
If I pass the value expression to behavior, and try to get the value at
renderer using the value expression, I am getting the correct value.

In theory, if the second case works, so does first one; right? Or am I
missing something?

Thanks,
Ali

-- 
My Blog: http://blog.aliok.com.tr
Twitter: http://twitter.com/aliok_tr

Re: Trouble getting the value of a value expression in a datatable

Posted by Ali Ok <al...@aliok.com.tr>.
Hi Leonardo,

Thanks for the explanation. I think I'll ignore this problem until the end
of the GSoC period, since it requires much time and may be its beyond me.

I'll request your help later.

Thanks,
Ali

On Mon, Jun 21, 2010 at 3:02 AM, Leonardo Uribe <lu...@gmail.com> wrote:

> Hi
>
> That is because the fields that are saved per row (but not between request)
> are the ones related to EditableValueHolder interface. Take a look at the
> implementation of UIData. In this case "value" property goes per row but
> "param" is shared by all rows.
>
> This is a problem described on:
>
> https://issues.apache.org/jira/browse/MYFACES-2616
> Fix UIData state saving model (spec issue 153)
>
> Really, there is not an easy solution for this issue. After thinking a lot
> in this issue I think we can create a custom datatable component that has
> this problem fixed, instead try to fix UIData implementation, because that
> could cause compatibility problems (I'm not investigated too much that
> suposition).
>
> regards,
>
> Leonardo Uribe
>
> 2010/6/20 Ali Ok <al...@aliok.com.tr>
>
> Hi,
>>
>> I am having problems with getting the value of an expression within a
>> datatable with my custom component.
>>
>> Let me write the code:
>> <h:dataTable value="#{dndBean.teams}" var="team">
>>  <h:column>
>> <hx:div>
>> <fx:dragSource action="move" param="#{team.id}" /> <!-- evaluates to
>> empty string -->
>>  <h:outputText value="#{team.id}" />   <!-- renders the correct id -->
>> </hx:div>
>>  </h:column>
>> </h:dataTable>
>>
>> dndBean: managed bean
>> dndBean.teams: List<SportsTeam>, where SportsTeam has a public String
>> getId() method
>> team: var of datatable
>>
>> I am getting a value of empty string for #{team.id} in the facelet
>> handler of fx:dragSource, if I put the fx:dragSource in a h:dataTable.
>> In the apply method of handler, I am trying to get the value as
>> _param.getValue(faceletContext)  //use this method since deferredValueType
>> of _param is String
>>
>> where _param is
>>  @JSFFaceletAttribute(name = "param", className =
>> "javax.el.ValueExpression", deferredValueType = "java.lang.String")
>> private final TagAttribute _param;
>>
>> If I put the fx:dragSource somewhere else, I am getting the correct value
>> at the handler:
>> <h:form>
>> <hx:div>
>>  <fx:dragSource action="move" param="#{lakers.id}" />
>>  </hx:div>
>> </h:form>
>>
>> Why can this be happening?
>>
>> One more hint, for the first case if I try to get the value at the
>> handler, I get empty string.
>> If I pass the value expression to behavior, and try to get the value at
>> renderer using the value expression, I am getting the correct value.
>>
>> In theory, if the second case works, so does first one; right? Or am I
>> missing something?
>>
>> Thanks,
>> Ali
>>
>> --
>> My Blog: http://blog.aliok.com.tr
>> Twitter: http://twitter.com/aliok_tr
>>
>>
>


-- 
My Blog: http://blog.aliok.com.tr
Twitter: http://twitter.com/aliok_tr

Re: Trouble getting the value of a value expression in a datatable

Posted by Leonardo Uribe <lu...@gmail.com>.
Hi

That is because the fields that are saved per row (but not between request)
are the ones related to EditableValueHolder interface. Take a look at the
implementation of UIData. In this case "value" property goes per row but
"param" is shared by all rows.

This is a problem described on:

https://issues.apache.org/jira/browse/MYFACES-2616
Fix UIData state saving model (spec issue 153)

Really, there is not an easy solution for this issue. After thinking a lot
in this issue I think we can create a custom datatable component that has
this problem fixed, instead try to fix UIData implementation, because that
could cause compatibility problems (I'm not investigated too much that
suposition).

regards,

Leonardo Uribe

2010/6/20 Ali Ok <al...@aliok.com.tr>

> Hi,
>
> I am having problems with getting the value of an expression within a
> datatable with my custom component.
>
> Let me write the code:
> <h:dataTable value="#{dndBean.teams}" var="team">
>  <h:column>
> <hx:div>
> <fx:dragSource action="move" param="#{team.id}" /> <!-- evaluates to empty
> string -->
>  <h:outputText value="#{team.id}" />   <!-- renders the correct id -->
> </hx:div>
>  </h:column>
> </h:dataTable>
>
> dndBean: managed bean
> dndBean.teams: List<SportsTeam>, where SportsTeam has a public String
> getId() method
> team: var of datatable
>
> I am getting a value of empty string for #{team.id} in the facelet handler
> of fx:dragSource, if I put the fx:dragSource in a h:dataTable.
> In the apply method of handler, I am trying to get the value as
> _param.getValue(faceletContext)  //use this method since deferredValueType
> of _param is String
>
> where _param is
> @JSFFaceletAttribute(name = "param", className =
> "javax.el.ValueExpression", deferredValueType = "java.lang.String")
> private final TagAttribute _param;
>
> If I put the fx:dragSource somewhere else, I am getting the correct value
> at the handler:
> <h:form>
> <hx:div>
>  <fx:dragSource action="move" param="#{lakers.id}" />
>  </hx:div>
> </h:form>
>
> Why can this be happening?
>
> One more hint, for the first case if I try to get the value at the handler,
> I get empty string.
> If I pass the value expression to behavior, and try to get the value at
> renderer using the value expression, I am getting the correct value.
>
> In theory, if the second case works, so does first one; right? Or am I
> missing something?
>
> Thanks,
> Ali
>
> --
> My Blog: http://blog.aliok.com.tr
> Twitter: http://twitter.com/aliok_tr
>
>