You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ma...@sanofi-aventis.com on 2008/04/10 15:23:29 UTC

Using t:dataList with Ajax4JSF

Hi,

 

I have a small problem with t:dataList and Ajax4JSF. I'm going to step
through this in the debugger soon but maybe someone's already
encountered this.

 

I have a t:dataList like so:

 

<t:dataList id="dataList" var="element" value="#{mbDataList.folderList}"
layout="unorderedList" styleClass="DataList" itemStyleClass="DataList">

 

Elsewhere I'm doing some Ajax4JSF action and I pass "dataList" to be
rerendered.

 

For the most part it rerenders correctly except it seems to omit the
'itemStyleClass="DataList"' attribute. The data gets updated, but the
formatting gets broken since the <li>s don't have their class attribute
anymore.

 

Thanks,

Matt


RE: Using t:dataList with Ajax4JSF

Posted by Ma...@sanofi-aventis.com.
Hi Martin,

I see your point, I will make the changes. I've been on holiday all week hence the delay in my response, but thanks for your input on this.

Matt

-----Message d'origine-----
De : Martin Marinschek [mailto:martin.marinschek@gmail.com] 
Envoyé : vendredi 11 avril 2008 10:28
À : MyFaces Discussion
Objet : Re: Using t:dataList with Ajax4JSF

Hi Matt,

attention - your fix will not always work as expected. What you
effectively do is you evaluate the value-binding once, and then set
the retrieved value locally. So the value-binding will only be
evaluated on the _first_ request. You should also override the getters
and setters, and do the normal JSF stuff in them.

regards,

Martin

On 4/10/08, Matt.Rossner-prest@sanofi-aventis.com
<Ma...@sanofi-aventis.com> wrote:
> Fix if anyone's interested :
>
>
>
> public class HtmlDataList extends
> org.apache.myfaces.custom.datalist.HtmlDataList {
>
>     public Object saveState(FacesContext context) {
>
>         Object [] values = new Object[2];
>
>         values[0] = super.saveState(context);
>
>         values[1] = getItemStyleClass();
>
>         return values;
>
>     }
>
>
>
>     public void restoreState(FacesContext context, Object state) {
>
>         Object [] values = (Object[])state;
>
>         super.restoreState(context, values[0]);
>
>         setItemStyleClass((String)values[1]);
>
>     }
>
> }
>
>
>
> Then just override it in your config file :
>
>
>
> <component>
>
>   <component-type>org.apache.myfaces.HtmlDataList</component-type>
>
>
> <component-class>com.sag.ibee.web.gui.component.datalist.HtmlDataList</component-class>
>
>
> </component>
>
>
>
> Just tested and it works fine for me.
>
> ________________________________
>
> De : Matt.Rossner-prest@sanofi-aventis.com
> [mailto:Matt.Rossner-prest@sanofi-aventis.com]
> Envoyé : jeudi 10 avril 2008 15:35
> À : users@myfaces.apache.org
> Objet : RE: Using t:dataList with Ajax4JSF
>
>
>
> Ok I found the problem already, this would appear to be a bug with Tomahawk
> (as I have the source attached here). Looks like "itemStyleClass"  was
> omitted from the saveState method. When I was debugging this I noticed the
> value for it was null.
>
>
>
> Listing from HtmlDataList.java
>
>
>
> public Object saveState(FacesContext context)
>
> {
>
>     Object values[] = new Object[17];
>
>     values[0] = super.saveState(context);
>
>     values[1] = _layout;
>
>     values[2] = _rowIndexVar;
>
>     values[3] = _rowCountVar;
>
>     values[4] = _onclick;
>
>     values[5] = _ondblclick;
>
>     values[6] = _onkeydown;
>
>     values[7] = _onkeypress;
>
>     values[8] = _onkeyup;
>
>     values[9] = _onmousedown;
>
>     values[10] = _onmousemove;
>
>     values[11] = _onmouseout;
>
>     values[12] = _onmouseover;
>
>     values[13] = _onmouseup;
>
>     values[14] = _style;
>
>     values[15] = _styleClass;
>
>     values[16] = _title;
>
>     return values;
>
> }
>
>
>
> As you can see itemStyleClass is not there. I'm using MyFaces 1.1.5, not
> sure if this problem exists in 1.2 but we're not upgrading at this point. I
> guess for now I'll just override this component to make it work. I'll see
> about opening a proper bug maybe? I haven't done so before so I'm not sure
> what the process is for that.
>
>
>
> ________________________________
>
> De : Matt.Rossner-prest@sanofi-aventis.com
> [mailto:Matt.Rossner-prest@sanofi-aventis.com]
> Envoyé : jeudi 10 avril 2008 15:23
> À : users@myfaces.apache.org
> Objet : Using t:dataList with Ajax4JSF
>
>
>
> Hi,
>
>
>
> I have a small problem with t:dataList and Ajax4JSF. I'm going to step
> through this in the debugger soon but maybe someone's already encountered
> this.
>
>
>
> I have a t:dataList like so:
>
>
>
> <t:dataList id="dataList" var="element" value="#{mbDataList.folderList}"
> layout="unorderedList" styleClass="DataList" itemStyleClass="DataList">
>
>
>
> Elsewhere I'm doing some Ajax4JSF action and I pass "dataList" to be
> rerendered.
>
>
>
> For the most part it rerenders correctly except it seems to omit the
> 'itemStyleClass="DataList"' attribute. The data gets updated, but the
> formatting gets broken since the <li>s don't have their class attribute
> anymore.
>
>
>
> Thanks,
>
> Matt
>
>


-- 

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: Using t:dataList with Ajax4JSF

Posted by Martin Marinschek <ma...@gmail.com>.
Hi Matt,

attention - your fix will not always work as expected. What you
effectively do is you evaluate the value-binding once, and then set
the retrieved value locally. So the value-binding will only be
evaluated on the _first_ request. You should also override the getters
and setters, and do the normal JSF stuff in them.

regards,

Martin

On 4/10/08, Matt.Rossner-prest@sanofi-aventis.com
<Ma...@sanofi-aventis.com> wrote:
> Fix if anyone's interested :
>
>
>
> public class HtmlDataList extends
> org.apache.myfaces.custom.datalist.HtmlDataList {
>
>     public Object saveState(FacesContext context) {
>
>         Object [] values = new Object[2];
>
>         values[0] = super.saveState(context);
>
>         values[1] = getItemStyleClass();
>
>         return values;
>
>     }
>
>
>
>     public void restoreState(FacesContext context, Object state) {
>
>         Object [] values = (Object[])state;
>
>         super.restoreState(context, values[0]);
>
>         setItemStyleClass((String)values[1]);
>
>     }
>
> }
>
>
>
> Then just override it in your config file :
>
>
>
> <component>
>
>   <component-type>org.apache.myfaces.HtmlDataList</component-type>
>
>
> <component-class>com.sag.ibee.web.gui.component.datalist.HtmlDataList</component-class>
>
>
> </component>
>
>
>
> Just tested and it works fine for me.
>
> ________________________________
>
> De : Matt.Rossner-prest@sanofi-aventis.com
> [mailto:Matt.Rossner-prest@sanofi-aventis.com]
> Envoyé : jeudi 10 avril 2008 15:35
> À : users@myfaces.apache.org
> Objet : RE: Using t:dataList with Ajax4JSF
>
>
>
> Ok I found the problem already, this would appear to be a bug with Tomahawk
> (as I have the source attached here). Looks like "itemStyleClass"  was
> omitted from the saveState method. When I was debugging this I noticed the
> value for it was null.
>
>
>
> Listing from HtmlDataList.java
>
>
>
> public Object saveState(FacesContext context)
>
> {
>
>     Object values[] = new Object[17];
>
>     values[0] = super.saveState(context);
>
>     values[1] = _layout;
>
>     values[2] = _rowIndexVar;
>
>     values[3] = _rowCountVar;
>
>     values[4] = _onclick;
>
>     values[5] = _ondblclick;
>
>     values[6] = _onkeydown;
>
>     values[7] = _onkeypress;
>
>     values[8] = _onkeyup;
>
>     values[9] = _onmousedown;
>
>     values[10] = _onmousemove;
>
>     values[11] = _onmouseout;
>
>     values[12] = _onmouseover;
>
>     values[13] = _onmouseup;
>
>     values[14] = _style;
>
>     values[15] = _styleClass;
>
>     values[16] = _title;
>
>     return values;
>
> }
>
>
>
> As you can see itemStyleClass is not there. I'm using MyFaces 1.1.5, not
> sure if this problem exists in 1.2 but we're not upgrading at this point. I
> guess for now I'll just override this component to make it work. I'll see
> about opening a proper bug maybe? I haven't done so before so I'm not sure
> what the process is for that.
>
>
>
> ________________________________
>
> De : Matt.Rossner-prest@sanofi-aventis.com
> [mailto:Matt.Rossner-prest@sanofi-aventis.com]
> Envoyé : jeudi 10 avril 2008 15:23
> À : users@myfaces.apache.org
> Objet : Using t:dataList with Ajax4JSF
>
>
>
> Hi,
>
>
>
> I have a small problem with t:dataList and Ajax4JSF. I'm going to step
> through this in the debugger soon but maybe someone's already encountered
> this.
>
>
>
> I have a t:dataList like so:
>
>
>
> <t:dataList id="dataList" var="element" value="#{mbDataList.folderList}"
> layout="unorderedList" styleClass="DataList" itemStyleClass="DataList">
>
>
>
> Elsewhere I'm doing some Ajax4JSF action and I pass "dataList" to be
> rerendered.
>
>
>
> For the most part it rerenders correctly except it seems to omit the
> 'itemStyleClass="DataList"' attribute. The data gets updated, but the
> formatting gets broken since the <li>s don't have their class attribute
> anymore.
>
>
>
> Thanks,
>
> Matt
>
>


-- 

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: Using t:dataList with Ajax4JSF

Posted by Grant Smith <wo...@gmail.com>.
Please note that this issue has already been addressed in the current
Tomahawk snapshot.

On Thu, Apr 10, 2008 at 6:46 AM, <Ma...@sanofi-aventis.com>
wrote:

>  Fix if anyone's interested :
>
>
>
> *public* *class* HtmlDataList *extends*org.apache.myfaces.custom.datalist.HtmlDataList {
>
>     *public* Object saveState(FacesContext context) {
>
>         Object [] values = *new* Object[2];
>
>         values[0] = *super*.saveState(context);
>
>         values[1] = getItemStyleClass();
>
>         *return* values;
>
>     }
>
>
>
>     *public* *void* restoreState(FacesContext context, Object state) {
>
>         Object [] values = (Object[])state;
>
>         *super*.restoreState(context, values[0]);
>
>         setItemStyleClass((String)values[1]);
>
>     }
>
> }
>
>
>
> Then just override it in your config file :
>
>
>
> <component>
>
>   <component-type>org.apache.myfaces.HtmlDataList</component-type>
>
>
> <component-class>com.sag.ibee.web.gui.component.datalist.HtmlDataList</component-class>
>
>
> </component>
>
>
>
> Just tested and it works fine for me.
>  ------------------------------
>
> *De :* Matt.Rossner-prest@sanofi-aventis.com [mailto:
> Matt.Rossner-prest@sanofi-aventis.com]
> *Envoyé :* jeudi 10 avril 2008 15:35
> *À :* users@myfaces.apache.org
> *Objet :* RE: Using t:dataList with Ajax4JSF
>
>
>
> Ok I found the problem already, this would appear to be a bug with
> Tomahawk (as I have the source attached here). Looks like "itemStyleClass"
> was omitted from the saveState method. When I was debugging this I noticed
> the value for it was null.
>
>
>
> Listing from HtmlDataList.java
>
>
>
> public Object saveState(FacesContext context)
>
> {
>
>     Object values[] = new Object[17];
>
>     values[0] = super.saveState(context);
>
>     values[1] = _layout;
>
>     values[2] = _rowIndexVar;
>
>     values[3] = _rowCountVar;
>
>     values[4] = _onclick;
>
>     values[5] = _ondblclick;
>
>     values[6] = _onkeydown;
>
>     values[7] = _onkeypress;
>
>     values[8] = _onkeyup;
>
>     values[9] = _onmousedown;
>
>     values[10] = _onmousemove;
>
>     values[11] = _onmouseout;
>
>     values[12] = _onmouseover;
>
>     values[13] = _onmouseup;
>
>     values[14] = _style;
>
>     values[15] = _styleClass;
>
>     values[16] = _title;
>
>     return values;
>
> }
>
>
>
> As you can see itemStyleClass is not there. I'm using MyFaces 1.1.5, not
> sure if this problem exists in 1.2 but we're not upgrading at this point. I
> guess for now I'll just override this component to make it work. I'll see
> about opening a proper bug maybe? I haven't done so before so I'm not sure
> what the process is for that.
>
>
>  ------------------------------
>
> *De :* Matt.Rossner-prest@sanofi-aventis.com [mailto:
> Matt.Rossner-prest@sanofi-aventis.com]
> *Envoyé :* jeudi 10 avril 2008 15:23
> *À :* users@myfaces.apache.org
> *Objet :* Using t:dataList with Ajax4JSF
>
>
>
> Hi,
>
>
>
> I have a small problem with t:dataList and Ajax4JSF. I'm going to step
> through this in the debugger soon but maybe someone's already encountered
> this.
>
>
>
> I have a t:dataList like so:
>
>
>
> <t:dataList id="dataList" var="element" value="#{mbDataList.folderList}"
> layout="unorderedList" styleClass="DataList" itemStyleClass="DataList">
>
>
>
> Elsewhere I'm doing some Ajax4JSF action and I pass "dataList" to be
> rerendered.
>
>
>
> For the most part it rerenders correctly except it seems to omit the
> 'itemStyleClass="DataList"' attribute. The data gets updated, but the
> formatting gets broken since the <li>s don't have their class attribute
> anymore.
>
>
>
> Thanks,
>
> Matt
>



-- 
Grant Smith

RE: Using t:dataList with Ajax4JSF

Posted by Ma...@sanofi-aventis.com.
Fix if anyone's interested :

 

public class HtmlDataList extends org.apache.myfaces.custom.datalist.HtmlDataList {

    public Object saveState(FacesContext context) {

        Object [] values = new Object[2]; 

        values[0] = super.saveState(context);

        values[1] = getItemStyleClass();

        return values;

    }

    

    public void restoreState(FacesContext context, Object state) {

        Object [] values = (Object[])state;

        super.restoreState(context, values[0]);

        setItemStyleClass((String)values[1]);         

    }

}

 

Then just override it in your config file :

 

<component>

  <component-type>org.apache.myfaces.HtmlDataList</component-type>

  <component-class>com.sag.ibee.web.gui.component.datalist.HtmlDataList</component-class>    

</component>

 

Just tested and it works fine for me.

________________________________

De : Matt.Rossner-prest@sanofi-aventis.com [mailto:Matt.Rossner-prest@sanofi-aventis.com] 
Envoyé : jeudi 10 avril 2008 15:35
À : users@myfaces.apache.org
Objet : RE: Using t:dataList with Ajax4JSF

 

Ok I found the problem already, this would appear to be a bug with Tomahawk (as I have the source attached here). Looks like "itemStyleClass"  was omitted from the saveState method. When I was debugging this I noticed the value for it was null.

 

Listing from HtmlDataList.java

 

public Object saveState(FacesContext context)

{

    Object values[] = new Object[17];

    values[0] = super.saveState(context);

    values[1] = _layout;

    values[2] = _rowIndexVar;

    values[3] = _rowCountVar;

    values[4] = _onclick;

    values[5] = _ondblclick;

    values[6] = _onkeydown;

    values[7] = _onkeypress;

    values[8] = _onkeyup;

    values[9] = _onmousedown;

    values[10] = _onmousemove;

    values[11] = _onmouseout;

    values[12] = _onmouseover;

    values[13] = _onmouseup;

    values[14] = _style;

    values[15] = _styleClass;

    values[16] = _title;

    return values;

}

 

As you can see itemStyleClass is not there. I'm using MyFaces 1.1.5, not sure if this problem exists in 1.2 but we're not upgrading at this point. I guess for now I'll just override this component to make it work. I'll see about opening a proper bug maybe? I haven't done so before so I'm not sure what the process is for that.

 

________________________________

De : Matt.Rossner-prest@sanofi-aventis.com [mailto:Matt.Rossner-prest@sanofi-aventis.com] 
Envoyé : jeudi 10 avril 2008 15:23
À : users@myfaces.apache.org
Objet : Using t:dataList with Ajax4JSF

 

Hi,

 

I have a small problem with t:dataList and Ajax4JSF. I'm going to step through this in the debugger soon but maybe someone's already encountered this.

 

I have a t:dataList like so:

 

<t:dataList id="dataList" var="element" value="#{mbDataList.folderList}" layout="unorderedList" styleClass="DataList" itemStyleClass="DataList">

 

Elsewhere I'm doing some Ajax4JSF action and I pass "dataList" to be rerendered.

 

For the most part it rerenders correctly except it seems to omit the 'itemStyleClass="DataList"' attribute. The data gets updated, but the formatting gets broken since the <li>s don't have their class attribute anymore.

 

Thanks,

Matt


RE: Using t:dataList with Ajax4JSF

Posted by Ma...@sanofi-aventis.com.
Ok I found the problem already, this would appear to be a bug with Tomahawk (as I have the source attached here). Looks like "itemStyleClass"  was omitted from the saveState method. When I was debugging this I noticed the value for it was null.

 

Listing from HtmlDataList.java

 

public Object saveState(FacesContext context)

{

    Object values[] = new Object[17];

    values[0] = super.saveState(context);

    values[1] = _layout;

    values[2] = _rowIndexVar;

    values[3] = _rowCountVar;

    values[4] = _onclick;

    values[5] = _ondblclick;

    values[6] = _onkeydown;

    values[7] = _onkeypress;

    values[8] = _onkeyup;

    values[9] = _onmousedown;

    values[10] = _onmousemove;

    values[11] = _onmouseout;

    values[12] = _onmouseover;

    values[13] = _onmouseup;

    values[14] = _style;

    values[15] = _styleClass;

    values[16] = _title;

    return values;

}

 

As you can see itemStyleClass is not there. I'm using MyFaces 1.1.5, not sure if this problem exists in 1.2 but we're not upgrading at this point. I guess for now I'll just override this component to make it work. I'll see about opening a proper bug maybe? I haven't done so before so I'm not sure what the process is for that.

 

________________________________

De : Matt.Rossner-prest@sanofi-aventis.com [mailto:Matt.Rossner-prest@sanofi-aventis.com] 
Envoyé : jeudi 10 avril 2008 15:23
À : users@myfaces.apache.org
Objet : Using t:dataList with Ajax4JSF

 

Hi,

 

I have a small problem with t:dataList and Ajax4JSF. I'm going to step through this in the debugger soon but maybe someone's already encountered this.

 

I have a t:dataList like so:

 

<t:dataList id="dataList" var="element" value="#{mbDataList.folderList}" layout="unorderedList" styleClass="DataList" itemStyleClass="DataList">

 

Elsewhere I'm doing some Ajax4JSF action and I pass "dataList" to be rerendered.

 

For the most part it rerenders correctly except it seems to omit the 'itemStyleClass="DataList"' attribute. The data gets updated, but the formatting gets broken since the <li>s don't have their class attribute anymore.

 

Thanks,

Matt