You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Eurig Jones <eu...@fugro-robertson.com> on 2005/11/28 12:12:08 UTC

Development problems with JSF

Hi,

I've been having a lot of trouble this week developing my JSF 
application. I've found it very time consuming to update/test my code 
due to sessions (i guess its a session related problem anyway).

Everytime I do an update (to a JSF tag for example), I find that I have 
to reload the application, and restart the browser to get it to run 
correctly. Its ok when I edit some backend code, but its extremely 
annoying having to reload and close browser all the time when I update a 
tag value. The session seems to keep the bean values after you reload.

How do you lot get around this problem?

I'm using MyEclipse with the latest MyFaces release.

Regards,
Eurig

Re: Development problems with JSF

Posted by Martin van den Bemt <mv...@ibl-software.nl>.
The system I have integrated myfaces in has a development mode and tried 
to make myfaces comply to that idea... :)
The solution I did was q&d, so you can always make a solution that works 
for you..

Mvgr,
Martin

Eurig Jones wrote:
> I see what you're doing here. The problem is is that you dont want to 
> remove the values after every single call to your myFaces servlet, just 
> the very first one after a code change.
> 
> Also, I didn't realise MyFaces had a development mode. If so, what does 
> it do exactly?
> 
> Thanks,
> Eurig
> 
> Martin van den Bemt wrote:
> 
>> In my case I use my own myfaces servlet, check if the site is in 
>> development mode, and just remove the jsf specific values from the 
>> session.
>> Something like this :
>>
>>                 HttpSession session = ((HttpServletRequest) 
>> request).getSession();
>>                 if (session != null) {
>>                     Enumeration en = session.getAttributeNames();
>>                     while (en.hasMoreElements()) {
>>                         String name = (String) en.nextElement();
>>                         if (name.indexOf(target) != -1) {
>>                             // remove this key...
>>                             System.out.println("NOT REMOVING SESSION 
>> ATTRIBUTE : " + name);
>>                             session.removeAttribute(name);
>>                             // and stop the while loop.
>>                             break;
>>                         }
>>
>>                     }
>>                 }
>>
>> target = the jsf session key (just print out everything in the session 
>> to see how the key is contrsucted)
>>
>> Since this a pretty abnormal use case, maybe this can be done in some 
>> prerendering phase in myfaces, but I really don't have a clue how to 
>> handle that, but you want this to happen before the session is read by 
>> myfaces and in a place where you can get a hold of the HttpSession.
>>
>> Mvgr,
>> Martin
>>
>> Eurig Jones wrote:
>>
>>> How do i clear the session?? Can you do this everytime you reload the 
>>> app or something? I'm not sure how to remove myfaces specific session 
>>> attributes either.
>>>
>>> Martin van den Bemt wrote:
>>>
>>>> Just clear the session or remove myfaces specific session attributes 
>>>> (that's what I do to make sure everything is reparsed).
>>>> I thought the session attribute for the page is named after the jsp 
>>>> filename on the physical filesystem.
>>>>
>>>> Mvgr.
>>>> Martin
>>>>
>>>> Eurig Jones wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I've been having a lot of trouble this week developing my JSF 
>>>>> application. I've found it very time consuming to update/test my 
>>>>> code due to sessions (i guess its a session related problem anyway).
>>>>>
>>>>> Everytime I do an update (to a JSF tag for example), I find that I 
>>>>> have to reload the application, and restart the browser to get it 
>>>>> to run correctly. Its ok when I edit some backend code, but its 
>>>>> extremely annoying having to reload and close browser all the time 
>>>>> when I update a tag value. The session seems to keep the bean 
>>>>> values after you reload.
>>>>>
>>>>> How do you lot get around this problem?
>>>>>
>>>>> I'm using MyEclipse with the latest MyFaces release.
>>>>>
>>>>> Regards,
>>>>> Eurig
>>>>>
>>>
>>>
> 
> 

Re: Development problems with JSF

Posted by Juergen Melzer <my...@hotmail.de>.
I found out that the StateManager caches the view so I have a workaround for 
you.
Write a class like:
public class NonCachedStatemanagerImpl extends JspStateManagerImpl
{
  public UIViewRoot restoreView(FacesContext facescontext, String viewId, 
String renderKitId)
  {
    HttpServletRequest request = (HttpServletRequest) 
facescontext.getExternalContext().getRequest();
    if (request.getParameterMap().size() == 0)
    {
      return null;
    }
    return super.restoreView(facescontext, viewId, renderKitId);
  }
}

write in your faces-config.xml:
<state-manager>xxx.NonCachedStatemanagerImpl</state-manager>

You will see that you can change your jsp side without restart your 
context....

Juergen




>From: Eurig Jones <eu...@fugro-robertson.com>
>Reply-To: "MyFaces Discussion" <us...@myfaces.apache.org>
>To: MyFaces Discussion <us...@myfaces.apache.org>
>Subject: Re: Development problems with JSF
>Date: Mon, 28 Nov 2005 14:06:31 +0000
>
>I see what you're doing here. The problem is is that you dont want to 
>remove the values after every single call to your myFaces servlet, just the 
>very first one after a code change.
>
>Also, I didn't realise MyFaces had a development mode. If so, what does it 
>do exactly?
>
>Thanks,
>Eurig
>
>Martin van den Bemt wrote:
>
>>In my case I use my own myfaces servlet, check if the site is in 
>>development mode, and just remove the jsf specific values from the 
>>session.
>>Something like this :
>>
>>                 HttpSession session = ((HttpServletRequest) 
>>request).getSession();
>>                 if (session != null) {
>>                     Enumeration en = session.getAttributeNames();
>>                     while (en.hasMoreElements()) {
>>                         String name = (String) en.nextElement();
>>                         if (name.indexOf(target) != -1) {
>>                             // remove this key...
>>                             System.out.println("NOT REMOVING SESSION 
>>ATTRIBUTE : " + name);
>>                             session.removeAttribute(name);
>>                             // and stop the while loop.
>>                             break;
>>                         }
>>
>>                     }
>>                 }
>>
>>target = the jsf session key (just print out everything in the session to 
>>see how the key is contrsucted)
>>
>>Since this a pretty abnormal use case, maybe this can be done in some 
>>prerendering phase in myfaces, but I really don't have a clue how to 
>>handle that, but you want this to happen before the session is read by 
>>myfaces and in a place where you can get a hold of the HttpSession.
>>
>>Mvgr,
>>Martin
>>
>>Eurig Jones wrote:
>>
>>>How do i clear the session?? Can you do this everytime you reload the app 
>>>or something? I'm not sure how to remove myfaces specific session 
>>>attributes either.
>>>
>>>Martin van den Bemt wrote:
>>>
>>>>Just clear the session or remove myfaces specific session attributes 
>>>>(that's what I do to make sure everything is reparsed).
>>>>I thought the session attribute for the page is named after the jsp 
>>>>filename on the physical filesystem.
>>>>
>>>>Mvgr.
>>>>Martin
>>>>
>>>>Eurig Jones wrote:
>>>>
>>>>>Hi,
>>>>>
>>>>>I've been having a lot of trouble this week developing my JSF 
>>>>>application. I've found it very time consuming to update/test my code 
>>>>>due to sessions (i guess its a session related problem anyway).
>>>>>
>>>>>Everytime I do an update (to a JSF tag for example), I find that I have 
>>>>>to reload the application, and restart the browser to get it to run 
>>>>>correctly. Its ok when I edit some backend code, but its extremely 
>>>>>annoying having to reload and close browser all the time when I update 
>>>>>a tag value. The session seems to keep the bean values after you 
>>>>>reload.
>>>>>
>>>>>How do you lot get around this problem?
>>>>>
>>>>>I'm using MyEclipse with the latest MyFaces release.
>>>>>
>>>>>Regards,
>>>>>Eurig
>>>>>
>>>
>>>
>

_________________________________________________________________
Sie suchen E-Mails, Dokumente oder Fotos? Die neue MSN Suche Toolbar mit 
Windows-Desktopsuche liefert in sekundenschnelle Ergebnisse. Jetzt neu! 
http://desktop.msn.de/ Jetzt gratis downloaden!


Re: Development problems with JSF

Posted by Eurig Jones <eu...@fugro-robertson.com>.
I see what you're doing here. The problem is is that you dont want to 
remove the values after every single call to your myFaces servlet, just 
the very first one after a code change.

Also, I didn't realise MyFaces had a development mode. If so, what does 
it do exactly?

Thanks,
Eurig

Martin van den Bemt wrote:

> In my case I use my own myfaces servlet, check if the site is in 
> development mode, and just remove the jsf specific values from the 
> session.
> Something like this :
>
>                 HttpSession session = ((HttpServletRequest) 
> request).getSession();
>                 if (session != null) {
>                     Enumeration en = session.getAttributeNames();
>                     while (en.hasMoreElements()) {
>                         String name = (String) en.nextElement();
>                         if (name.indexOf(target) != -1) {
>                             // remove this key...
>                             System.out.println("NOT REMOVING SESSION 
> ATTRIBUTE : " + name);
>                             session.removeAttribute(name);
>                             // and stop the while loop.
>                             break;
>                         }
>
>                     }
>                 }
>
> target = the jsf session key (just print out everything in the session 
> to see how the key is contrsucted)
>
> Since this a pretty abnormal use case, maybe this can be done in some 
> prerendering phase in myfaces, but I really don't have a clue how to 
> handle that, but you want this to happen before the session is read by 
> myfaces and in a place where you can get a hold of the HttpSession.
>
> Mvgr,
> Martin
>
> Eurig Jones wrote:
>
>> How do i clear the session?? Can you do this everytime you reload the 
>> app or something? I'm not sure how to remove myfaces specific session 
>> attributes either.
>>
>> Martin van den Bemt wrote:
>>
>>> Just clear the session or remove myfaces specific session attributes 
>>> (that's what I do to make sure everything is reparsed).
>>> I thought the session attribute for the page is named after the jsp 
>>> filename on the physical filesystem.
>>>
>>> Mvgr.
>>> Martin
>>>
>>> Eurig Jones wrote:
>>>
>>>> Hi,
>>>>
>>>> I've been having a lot of trouble this week developing my JSF 
>>>> application. I've found it very time consuming to update/test my 
>>>> code due to sessions (i guess its a session related problem anyway).
>>>>
>>>> Everytime I do an update (to a JSF tag for example), I find that I 
>>>> have to reload the application, and restart the browser to get it 
>>>> to run correctly. Its ok when I edit some backend code, but its 
>>>> extremely annoying having to reload and close browser all the time 
>>>> when I update a tag value. The session seems to keep the bean 
>>>> values after you reload.
>>>>
>>>> How do you lot get around this problem?
>>>>
>>>> I'm using MyEclipse with the latest MyFaces release.
>>>>
>>>> Regards,
>>>> Eurig
>>>>
>>
>>


Re: Development problems with JSF

Posted by Martin van den Bemt <mv...@ibl-software.nl>.
In my case I use my own myfaces servlet, check if the site is in 
development mode, and just remove the jsf specific values from the session.
Something like this :

                 HttpSession session = ((HttpServletRequest) 
request).getSession();
                 if (session != null) {
                     Enumeration en = session.getAttributeNames();
                     while (en.hasMoreElements()) {
                         String name = (String) en.nextElement();
                         if (name.indexOf(target) != -1) {
                             // remove this key...
                             System.out.println("NOT REMOVING SESSION 
ATTRIBUTE : " + name);
                             session.removeAttribute(name);
                             // and stop the while loop.
                             break;
                         }

                     }
                 }

target = the jsf session key (just print out everything in the session 
to see how the key is contrsucted)

Since this a pretty abnormal use case, maybe this can be done in some 
prerendering phase in myfaces, but I really don't have a clue how to 
handle that, but you want this to happen before the session is read by 
myfaces and in a place where you can get a hold of the HttpSession.

Mvgr,
Martin

Eurig Jones wrote:
> How do i clear the session?? Can you do this everytime you reload the 
> app or something? I'm not sure how to remove myfaces specific session 
> attributes either.
> 
> Martin van den Bemt wrote:
> 
>> Just clear the session or remove myfaces specific session attributes 
>> (that's what I do to make sure everything is reparsed).
>> I thought the session attribute for the page is named after the jsp 
>> filename on the physical filesystem.
>>
>> Mvgr.
>> Martin
>>
>> Eurig Jones wrote:
>>
>>> Hi,
>>>
>>> I've been having a lot of trouble this week developing my JSF 
>>> application. I've found it very time consuming to update/test my code 
>>> due to sessions (i guess its a session related problem anyway).
>>>
>>> Everytime I do an update (to a JSF tag for example), I find that I 
>>> have to reload the application, and restart the browser to get it to 
>>> run correctly. Its ok when I edit some backend code, but its 
>>> extremely annoying having to reload and close browser all the time 
>>> when I update a tag value. The session seems to keep the bean values 
>>> after you reload.
>>>
>>> How do you lot get around this problem?
>>>
>>> I'm using MyEclipse with the latest MyFaces release.
>>>
>>> Regards,
>>> Eurig
>>>
> 
> 

Re: Development problems with JSF

Posted by Eurig Jones <eu...@fugro-robertson.com>.
How do i clear the session?? Can you do this everytime you reload the 
app or something? I'm not sure how to remove myfaces specific session 
attributes either.

Martin van den Bemt wrote:

> Just clear the session or remove myfaces specific session attributes 
> (that's what I do to make sure everything is reparsed).
> I thought the session attribute for the page is named after the jsp 
> filename on the physical filesystem.
>
> Mvgr.
> Martin
>
> Eurig Jones wrote:
>
>> Hi,
>>
>> I've been having a lot of trouble this week developing my JSF 
>> application. I've found it very time consuming to update/test my code 
>> due to sessions (i guess its a session related problem anyway).
>>
>> Everytime I do an update (to a JSF tag for example), I find that I 
>> have to reload the application, and restart the browser to get it to 
>> run correctly. Its ok when I edit some backend code, but its 
>> extremely annoying having to reload and close browser all the time 
>> when I update a tag value. The session seems to keep the bean values 
>> after you reload.
>>
>> How do you lot get around this problem?
>>
>> I'm using MyEclipse with the latest MyFaces release.
>>
>> Regards,
>> Eurig
>>


Re: Development problems with JSF

Posted by Martin van den Bemt <mv...@ibl-software.nl>.
Just clear the session or remove myfaces specific session attributes 
(that's what I do to make sure everything is reparsed).
I thought the session attribute for the page is named after the jsp 
filename on the physical filesystem.

Mvgr.
Martin

Eurig Jones wrote:
> Hi,
> 
> I've been having a lot of trouble this week developing my JSF 
> application. I've found it very time consuming to update/test my code 
> due to sessions (i guess its a session related problem anyway).
> 
> Everytime I do an update (to a JSF tag for example), I find that I have 
> to reload the application, and restart the browser to get it to run 
> correctly. Its ok when I edit some backend code, but its extremely 
> annoying having to reload and close browser all the time when I update a 
> tag value. The session seems to keep the bean values after you reload.
> 
> How do you lot get around this problem?
> 
> I'm using MyEclipse with the latest MyFaces release.
> 
> Regards,
> Eurig
>