Client Side State Saving Bug

2006-06-14 Thread JSFSter Smith
Hello,I am using myfaces-1.1.1, and get the following exception when running my application:javax.faces.FacesException: java.io.IOException: Not in GZIP format	org.apache.myfaces.renderkit.html.HtmlResponseStateManager.decode64
(HtmlResponseStateManager.java:238)	org.apache.myfaces.renderkit.html.HtmlResponseStateManager.getTreeStructureToRestore(HtmlResponseStateManager.java:197)	org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreTreeStructure
(JspStateManagerImpl.java:142)	org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:181)	org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java
:255)	org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:124)	org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)	javax.faces.webapp.FacesServlet.service(FacesServlet.java
:106)	org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:92)	org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)In my web.xml
 I have the following setting:context-param 
param-namejavax.faces.STATE_SAVING_METHOD/param-name 
param-valueclient/param-value/context-paramI set breakpoints in the JSF code to trap this exception to try to see what was going on. The String that is being passed in to the decode64() method is bogus. This String comes from 
reqParamMap.get( BASE64_TREE_PARAM) in the getTreeStructureToRestore() method. Any ideas about what could be causing this?Thanks,Satish


Re: commandlink inside datatable still broken?

2006-05-22 Thread JSFSter Smith
Hi ,

I am facing this problem too. I have a command link inside a
t:dataTable and the action string for the commandLink is never hit
(debugged using MyEclipse environment). The part that has me stumped is
that I have a very similar tag setup in a different jsp page in the
same application seems to work fine. I have tried different things and
think the issue can be narrowed down to the t:commandLink not working
inside a t:dataTable at this point.

Is this a bug? I have not yet upgraded to the new MyFaces release.
Would be great if anyone can shed some light on this. I have now spent
a few days trying to get to the bottom of this but am stuck.

Thanks!

-Rajiv
On 19/05/06, Andrew Robinson [EMAIL PROTECTED] wrote:
I use t:commandLink all the time in dataTables and dataList controls,never with an issue. Perhaps it is better with facelets, but I havenever seen an issue.-AndrewOn 5/18/06, Le Van 
[EMAIL PROTECTED] wrote: Matthias Wessendorf wrote:  Marti   perhaps [1] is interesting for you   [1] 
http://tinyurl.com/p59la   On 5/16/06, Mike Kienenberger [EMAIL PROTECTED] wrote:   None of these issues appear to be related to what you described.
  They either deal with a different component (dataList) or were  solved/invalidated for other reasons.   Without a reproducable test case, there's not much we can do about it
  -- after all, it could be something unique to your particular  situation.   It is true that you need to persist your data model across requests.  But you don't have to use a session-scoped bean. You can use a
  request-scoped bean with t:saveState instead. This is what I do.On 5/16/06, Marti, Adrian (Adrian) [EMAIL PROTECTED]
 wrote:   Mike,   I did some research on this before and it seemed to be a very   random problem. Someone had said that it could be do to a race
  condition   during id generation. One fix was to set the bean to session but that   seems like a hack. Anyways here are some jira #'s that have to do with   the problem. A lot of these are closed but the same problem seems to
   keep popping up. I too use commandlinks inside datatables that work   fine, but then on other pages with different object types the   commandlinks do not fire the action methods. Commandlinks outside
  of the   datatable on the same page fire fine. MYFACES-247 MYFACES-803 and 802 I guess  
   MYFACES-604the solution given here does not apply as my  collection is   not null at that point in the lifecycle. There are a few others for dataList but I'm not sure if that's the
  same   thing so I left them out. Thanks,   Adrian -Original Message-
   From: Mike Kienenberger [mailto:[EMAIL PROTECTED]]   Sent: Tuesday, May 16, 2006 4:07 PM   To: MyFaces Discussion
   Subject: Re: commandlink inside datatable still broken? On 5/16/06, Marti, Adrian (Adrian) [EMAIL PROTECTED] wrote:

 

Just upgraded to the latest release   (core,tomahawk,sandbox) andwas a little disappointed to see that the commandlink inside  datatable   issue
was not resolved. I am using a custom java object as the current   variable inthe datatable which I guess is what causes this problem. Is this bug
   still abug? Is it being worked on? I'm using a command-link inside a t:dataTable without problems. Is   there a JIRA issue open on it? Did you submit a patch?Or provide
   an example demonstrating the problem?I got this problem but it came with h:dataTable. Then I play with
 MyFaces and everything is OK. But I don't like t:commandLink at all. I think your problem came from t:commandLink because till now I use h:commandLink with t:dataTable



Re: [newbie] - simple custom tag problems

2006-05-11 Thread JSFSter Smith
Hi Volker,

Thanks for your response!

I attempted the forcing of the ValueBinding in the setProperties()
since setting value of the tag attribute was not passed on to the
Component Class.

In a case like this: my:testTag value=My message (or) my:testTag value=#{datapanel.description}
where description is a String, the contents of the 'value' attribute in
the setProperty method of the Tag class are picked up ok. 

But in the case when the the Bean member is not a string (like in
the dataTable case), the contents of the value attribute in
setProperty() are : #{datapanel.description}. In this case, the
getValue() in my Custom Component class is null and the EL does not
seem to be processed.

My setProperties() method :
 protected void setProperties(UIComponent component) 
 {
  FacesContext context = FacesContext.getCurrentInstance();
  super.setProperties(component);
  
  if(value != null)
  {
   if (isValueReference(value))
   {
 
 ValueBinding vb =
context.getApplication().createValueBinding(value);
   component.setValueBinding(value, vb);
   }
   else 
  
 
((UICustomHTMLOutput)component).setValue(value);
  }
 }


And my state and encode methods from the UICustomHTMLOutput:
 @Override
 public Object saveState(FacesContext context) 
 {
 Object values[] = new Object[2];
 values[0] = super.saveState(context);
 values[1] = value;
 return ((Object) (values));
 }

 @Override
 public void restoreState(FacesContext context, Object state) 
 {
 Object values[] = (Object[])state;
 super.restoreState(context, values[0]);
 value = (String)values[1];
 }
 
 // component render
 public void encodeBegin(FacesContext context) throws IOException 
 {

  ResponseWriter writer = context.getResponseWriter();
  
  writer.startElement(p, this);
   writer.write(value);
   writer.endElement(p);
   writer.flush();
 } 

Any help is greatly appreciated. Thanks!

-Rajiv

On 11/05/06, Volker Weber [EMAIL PROTECTED] wrote:
Hi Rajiv,JSFSter Smith wrote: Firstly, kudos to the MyFaces team for the recent releases of myfaces 1.1.3 and tomahawk 1.1.2! I am just a few weeks old with JSF and am using it for a current
 project. So far its been great but I am still getting to know the deatils. I attempted to create a simple custom JSP tag and was able to get it together surprisingly quickly. But I do have a problem now. My
 tag essentially renders the string in an attribute value. Here is a sample usage: my:testTag value=My message (or) my:testTag value=#{datapanel.description
} But the ValueBinding does not seem to work when I try to access a member of the DataPanel bean that is a collection or another class that has members. Examples of these cases are below:
 t:dataTable value=#{datapanel.sentenceDisplayData} var=each t:column my:testTag value=#{each.part0} / my:testTag value=#{
each.part1} / my:testTag value=#{each.part2} / my:testTag value=#{each.part3} / /t:column /t:dataTable
 (OR) my:testTag value=#{datapanel.summary.length I am including my setProperties method of the TagLib class. Would be great if someone can point out what I am missing here.
 protected void setProperties(UIComponent component) { /* you have to call the super class */ FacesContext context = FacesContext.getCurrentInstance();
 super.setProperties(component); if(value != null) { if (isValueReference(value)){ ValueBinding vb =
 context.getApplication().createValueBinding(value);
component.setValueBinding(value, vb);- remove following --
// forcing the value from the ValueBinding to the component. if(vb != null) {
if(vb.getValue(context) != null) ((UIInfactHTMLOutput)component).setValue(vb.getValue(context).toString()); }- / remove following --Why this? Thats the problem!
Here are the valueBinding evaluated at component creation time, butdatatable needs eavluation at rendering time!just remove this an it should do. } else

((UIInfactHTMLOutput)component).setValue(value); } }or better implement your set properties using UIComponentTagUtils like this:protected void setProperties(UIComponent component)
{super.setProperties(component);UIComponentTagUtils.setValueProperty(getFacesContext(), component,value);}Regards,Volker thanks in advance!
 -Rajiv--Don't answer to From: address!Mail to this account are droped if not recieved via mailinglist.To contact me direct create the mail address byconcatenating my forename to my senders domain.



Re: [newbie] - simple custom tag problems

2006-05-11 Thread JSFSter Smith
Hi Volker,

Thanks! yes that was the problem. 
I am getting a better hang of the JSF rendering framework now and it is pretty powerful!

Thanks again.

-RajivOn 11/05/06, Volker Weber [EMAIL PROTECTED] wrote:
Hi,see inlineJSFSter Smith wrote: Hi Volker, Thanks for your response! I attempted the forcing of the ValueBinding in the setProperties() since setting value of the tag attribute was not passed on to the Component
 Class. In a case like this: my:testTag value=My message (or) my:testTag value=#{datapanel.description} where description is a String, the contents of the 'value' attribute in the
 setProperty method of the Tag class are picked up ok. But in the case when the theBean member is not a string (like in the dataTable case), the contents of the value attribute insetProperty()
 are : #{datapanel.description}. In this case, the getValue() in my Custom Component class is null and the EL does not seem to be processed. My setProperties() method :protected void setProperties(UIComponent component)
{FacesContext context = FacesContext.getCurrentInstance();super.setProperties(component);if(value != null){if (isValueReference(value))
 {ValueBinding
vb = context.getApplication ().createValueBinding(value);component.setValueBinding(value,
vb);}else((UICustomHTMLOutput)component).setValue(value);}} And my state and encode methods from the UICustomHTMLOutput:
@Overridepublic Object saveState(FacesContext context){Object values[] = new Object[2];values[0] = super.saveState(context);values[1] = value;
return ((Object) (values));}@Overridepublic void restoreState(FacesContext context, Object state){Object values[] = (Object[])state;
super.restoreState(context, values[0]);value = (String)values[1];}// component renderpublic void encodeBegin(FacesContext context) throws IOException
{ResponseWriter writer = context.getResponseWriter();writer.startElement(p, this);writer.write(value);This is the wrong part. In case of ValueBinding the value is of cause
null. you need here the same if else as in setProperties():if (value != null) {writer.write(value);} else {ValueBinding vb = getValueBinding(value);if (vb != null) {
writer.write(vb.getValue(context));}}Regards,Volkerwriter.endElement(p);writer.flush();}
 Any help is greatly appreciated. Thanks! -Rajiv On 11/05/06, Volker Weber [EMAIL PROTECTED] wrote:
 Hi Rajiv, JSFSter Smith wrote:   Firstly, kudos to the MyFaces team for the recent releases of myfaces  1.1.3 and tomahawk 
1.1.2!   I am just a few weeks old with JSF and am using it for a current  project. So far its been great but I am still getting to know the  deatils. I attempted to create a simple custom JSP tag and was able to
  get it together surprisingly quickly. But I do have a problem now. My  tag essentially renders the string in an attribute value. Here is a  sample usage: 
  my:testTag value=My message (or) my:testTag  value=#{datapanel.description}   But the ValueBinding does not seem to work when I try to access a
 member  of the DataPanel bean that is a collection or another class that has  members. Examples of these cases are below:   t:dataTable value=#{
datapanel.sentenceDisplayData} var=each  t:column  my:testTag value=#{each.part0} /  my:testTag value=#{
each.part1} /  my:testTag value=#{each.part2} /  my:testTag value=#{each.part3} /  /t:column
  /t:dataTable   (OR)  my:testTag value=#{datapanel.summary.length   I am including my setProperties method of the TagLib class. Would be
  great if someone can point out what I am missing here.   protected void setProperties(UIComponent component)  {  /* you have to call the super class */
   FacesContext context = FacesContext.getCurrentInstance();  super.setProperties(component);   if(value != null)
  {  if (isValueReference(value)) {  ValueBinding vb =  context.getApplication().createValueBinding(value);


component.setValueBinding(value, vb);  - remove following --

// forcing the value from the ValueBinding to the  component.  if(vb != null)  {

if(vb.getValue(context) != null)   ((UIInfactHTMLOutput)component).setValue(vb.getValue (context).toString());  } - / remove following --
 Why this? Thats the problem! Here are the valueBinding evaluated at component creation time, but datatable needs eavluation at rendering time! just remove this an it should do.
  }  else

((UIInfactHTMLOutput)component).setValue(value);  }  }  or better implement your set properties using UIComponentTagUtils like
 this: protected void setProperties(UIComponent component) { super.setProperties(component); UIComponentTagUtils.setValueProperty
(getFacesContext(), component, value); } Regards, Volker  thanks in advance! 
  -Rajiv -- Don't answer to From: address! Mail to this account are droped if not recieved via mailinglist. To contact me direct create the mail address by
 concatenating my forename to my senders domain.--Don't answer to From: address!Mail to this account are droped if not recieved via mailinglist.To contact me direct create the mail

[newbie] - simple custom tag problems

2006-05-10 Thread JSFSter Smith

Firstly, kudos to the MyFaces team for the recent releases of myfaces 1.1.3 and tomahawk 1.1.2! 

I am just a few weeks old with JSF and am using it for a current
project. So far its been great but I am still getting to know the
deatils. I attempted to create a simple custom JSP tag and was able to
get it together surprisingly quickly. But I do have a problem now. My
tag essentially renders the string in an attribute value. Here is a
sample usage:

my:testTag value=My message (or) my:testTag value=#{datapanel.description}

But the ValueBinding does not seem to work when I try to access a
member of the DataPanel bean that is a collection or another class that
has members. Examples of these cases are below:

t:dataTable value=#{datapanel.sentenceDisplayData} var=each
 t:column
  my:testTag value=#{each.part0} /
  my:testTag value=#{each.part1} /
  my:testTag value=#{each.part2} /
  my:testTag value=#{each.part3} /
 /t:column
/t:dataTable 

(OR)
my:testTag value=#{datapanel.summary.length

I am including my setProperties method of the TagLib class. Would be great if someone can point out what I am missing here. 

 protected void setProperties(UIComponent component) 
 {
  /* you have to call the super class */

  FacesContext context = FacesContext.getCurrentInstance();
  super.setProperties(component);
  
  if(value != null)
  {
   if (isValueReference(value))
   {
 
 ValueBinding vb =
context.getApplication().createValueBinding(value);
   component.setValueBinding(value, vb);

 
 // forcing the value from
the ValueBinding to the component. 
   if(vb != null)
   {
 
 
if(vb.getValue(context) != null)
 
 
((UIInfactHTMLOutput)component).setValue(vb.getValue(context).toString());
   }
   }
   else 
  
 
((UIInfactHTMLOutput)component).setValue(value);
  }
 }

thanks in advance!

-Rajiv


Newbie help

2006-04-11 Thread JSFSter Smith
Hi,

I have just started using MyFaces for a new project and had a couple of
questions while I am on the learning curve. Any help/response is
greatly appreciated. Its been a pleasure to actually create
JSP pages with no java code using JSF in them and I hope to keep them
that way!


1. h:commandLink tag does not work inside a t:dataTable tag 
 and ends up refreshing the same page from
where the link was clicked without any updates to the model. The
get/set methods for the corresponding backing bean member are
never called by the framework

 I looked through the mail archives for myFaces as
well as JSF RI. This seems to be an issue faced by many users and the
suggested work around is to make the backing bean that contains the
table data a session bean (currently mine is a request). Is this a bug
with the spec or am I missing something ?

2. h:commandButton with a request scope backing bean cannot be
used to pass request parameters to the next page using f:param
tags. 
 The h:commandLink tag has to be used instead. Again is this a bug or I am missing something?

Currently, I am using h:commandLinks for my request param passing
and it works fine. But this leads me to my final question:

3. I am trying to map the enter key to my command link (which is an image) using _javascript_ and have included a snippet below.
 
 if (keycode == 13) {

 document.forms['MyJSFForm'].elements['submitLink'].click()
 return false;
 }

 I have explicitly given id's to my form and commandLink. The _javascript_ object for the link is invalid

Thanks in advance for your response!

- Rajiv


Re: Newbie help - Java script to submit on accessing commandLink

2006-04-11 Thread JSFSter Smith
Hi,

Thanks for your responses! Adding the preserveDataModel=true did
solve the commandLink problem inside the dataTable and I did not have
to go the session bean route. I

I am still having problems with the _javascript_ to trap the enter
key to submit the form using when a h:commandLink is clicked. I tried
setting the forceID attribute (in an earlier version) as well as using
the id explicitly in the _javascript_. 

My _javascript_ :
 function trapEnter(evt) {
var keycode;
 if (evt)
 ;
 else if (window.event)
 evt = window.event;
 else if (event)
   evt = event;
 else
 return true;

 if (evt.charCode)
 keycode = evt.charCode;
 else if (evt.keyCode)
 keycode = evt.keyCode;
 else if (evt.which)
 keycode = evt.which;
 else
 keycode = 0;

 if (keycode == 13) {
 document.forms['myJSFForm'].elements['myJSFForm:searchLink'].click();
 return false;
 }
 else
 return true;
}

and my form is as follows:
 body >
 f:view

f:loadBundle basename=ifmessages var=msgs/
 h:form id=myJSFForm
 h:panelGrid
 h:panelGroup styleClass=bookSearchPanel

h:inputText id=searchText value=#{searchMain.searchTerm} /


t:commandLink forceId=searchLink
action="">

h:graphicImage value=/images/submit.gif/

/t:commandLink

/h:panelGroup
 -


 /h:form

The keypress event is trapped and I tested it using alerts. Is there anything I am missing here?

thanks,

Rajiv
On 11/04/06, Volker Weber [EMAIL PROTECTED] wrote:
Hi Rajiv,1: The model must the same on render and restore phase, afaik you can force this by using preserveDataModel=true on t:datatable. Or you can use the t:saveState tag see: 
http://myfaces.apache.org/tomahawk/uiSaveState.html3: the html ids are created by prefixing component ids with the ids of namingcontainer components you should use sommething like 
document.forms['MyJSFForm'].elements['MyJSFForm:submitLink'].click() or document.getElementById('MyJSFForm:submitLink').click() Take a look into the generated html source if unclear about the
 generated id of the link.Regards,VolkerJSFSter Smith wrote: Hi, I have just started using MyFaces for a new project and had a couple of questions while I am on the learning curve. Any help/response is greatly
 appreciated.Its been a pleasure to actually createJSP pages with no java code using JSF in them and I hope to keep them that way! 1. h:commandLink tag does not work inside a t:dataTable tag
and ends up refreshing the same page from where the link was clicked without any updates to the model. The get/setmethods for the corresponding backing bean member are never called by the framework
 I looked through the mail archives for myFaces as well as JSF RI. This seems to be an issue faced by many users and the suggested work around is to make the backing bean that contains the table data a session bean (currently
 mine is a request). Is this a bug with the spec or am I missing something ? 2. h:commandButton with a request scope backing bean cannot be used to pass request parameters to the next page using f:param tags.
 The h:commandLink tag has to be used instead. Again is this a bug or I am missing something? Currently, I am using h:commandLinks formy request param passing and it works fine. But this leads me to my final question:
 3. I am trying to map the enter key to my command link (which is an image) using _javascript_ and have included a snippet below.if (keycode == 13) {document.forms
['MyJSFForm'].elements['submitLink'].click() return false; } I have explicitly given id's to my form and commandLink. The _javascript_ object for the link is invalid
 Thanks in advance for your response! - Rajiv--Don't answer to From: address!Mail to this account are droped if not recieved via mailinglist.To contact me direct create the mail address by
concatenating my forename to my senders domain.