You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by SO...@austin.rr.com on 2007/03/17 14:11:39 UTC

FacesContext.addMessage in an action method

I have seemingly tried everything.  I put forceId on the <t:inputText>
(which sets the id properly); I tried a validator and calling
addMessage() from within the validator method, which although it is
bulky it did work and the error message appeared; page-level validation
works (an error message appears if I leave the field empty).  However,
it does not work if I call FacesContext.addMessage() from within the
action method.  The error message does not show up.  Is there something
else I have to do???  Like a PhaseListener or something?  Some other
setting somewhere?  I am absolutely sure I am getting the correct id
because I even used a binding property.  I could really use some help. 
This shouldn't be that difficult.  Thanks!

Re: Ajax4jsf w.r.t. FacesContext.addMessage in an action method

Posted by Adrian Mitev <ad...@googlemail.com>.
What is your question?

2007/3/17, SOSELLA@austin.rr.com <SO...@austin.rr.com>:
>
> Just thought of something...I am using Ajax4jsf.  Could the Ajax4jsf
> filter be messing things up?
>

Ajax4jsf w.r.t. FacesContext.addMessage in an action method

Posted by SO...@austin.rr.com.
Just thought of something...I am using Ajax4jsf.  Could the Ajax4jsf
filter be messing things up?

position : beating this dead horse again

Posted by SO...@austin.rr.com.
I am using <t:inputCalendar> and I put a <t:panelGroup
style="position:absolute;"> around it to try to anchor the popup on the
image icon.  This works fairly well, but I noticed that if I scroll down
on the page and then click on the image icon to popup the dialog, the
dialog is offset by the amount that I scrolled.  Anyone know the right
way to anchor the popup to the icon?

Re: Additional: problem (using facelets)

Posted by Mike Kienenberger <mk...@gmail.com>.
http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk is the
official location right now.

My guess is that mouseListener takes a method binding rather than a
value binding.  You'll need to create a facelets tag handler that
tells facelets what the method signature of the mouseListener method
is.

You can find some examples of how to do this (it's trivial) at this
location.  Note that you'll want to create a ScheduleComponentHandler
class like the two examples at the bottom of the page in addition to
specifying the handler in your tag entry in taglib.xml file.

http://wiki.java.net/bin/view/Projects/FaceletsTaglibsMyfacesSandbox

When you're done, please update the tomahawk facelets page with the taghandler.

On 4/2/07, SOSELLA@austin.rr.com <SO...@austin.rr.com> wrote:
> Some more info... seems like the mouseListener method is not being
> called.  I am pretty sure that it used to be called prior to me porting
> to facelets.
>
> I downloaded the "tomahawk.taglib.xml" file that I found on the net, but
> I added the "schedule" tag myself and listed
> "org.apache.myfaces.Schedule" as the <component-type>.  Does anyone have
> an official "tomahawk.taglib.xml" file?  Any ideas about what might be
> going on?
>

Additional: problem (using facelets)

Posted by SO...@austin.rr.com.
Some more info... seems like the mouseListener method is not being
called.  I am pretty sure that it used to be called prior to me porting
to facelets.

I downloaded the "tomahawk.taglib.xml" file that I found on the net, but
I added the "schedule" tag myself and listed
"org.apache.myfaces.Schedule" as the <component-type>.  Does anyone have
an official "tomahawk.taglib.xml" file?  Any ideas about what might be
going on?

problem (using facelets)

Posted by SO...@austin.rr.com.
I have been porting my code to facelets.  I am using <t:schedule> and
all seemed to work and render properly, but when now I go to click on
the schedule, the event type is always SCHEDULE_NOTHING_CLICKED.  I did
not change any attributes or attribute values for the <t:schedule> tag.
 Has anyone else seen this issue?  The schedule handler action is being
called, but the event type is always SCHEDULE_NOTHING_CLICKED.

Re: StreamingAddResource Exception with Facelets

Posted by Gerald Müllan <bi...@gmail.com>.
Hi,

i had once exactly the same exception, but didn`t invest more time on this.

Mario as the initial author told me that maybe some filter mappings
don`t do their job correctly. I tried, but had no success. Maybe Mario
knows more on this topic.

cheers,

Gerald

On 3/29/07, SOSELLA@austin.rr.com <SO...@austin.rr.com> wrote:
> I am trying to incorporate the performance improvements using:
>
> <context-param>
>    <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
>
> <param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value>
> </context-param>
>
> with <t:document*>  when using facelets.
>
> I am getting an exception when the first page is accessed:
>
> Unknown error while serving resource: null/header.css, message : For
> input string: "null"
>
> The error seems to go away after accessing the front page the first
> time; but I am not sure if it is an error that happens per session.
>
> Does anyone have any ideas about this?  Should I not use that
> performance tip if using facelets?
>


-- 
http://www.irian.at

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

Professional Support for Apache MyFaces

StreamingAddResource Exception with Facelets

Posted by SO...@austin.rr.com.
I am trying to incorporate the performance improvements using:

<context-param>
   <param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
  
<param-value>org.apache.myfaces.component.html.util.StreamingAddResource</param-value>
</context-param>

with <t:document*>  when using facelets.

I am getting an exception when the first page is accessed:

Unknown error while serving resource: null/header.css, message : For
input string: "null"

The error seems to go away after accessing the front page the first
time; but I am not sure if it is an error that happens per session.

Does anyone have any ideas about this?  Should I not use that
performance tip if using facelets?

Re: ajax4jsf 1.1 RC2 - session serialization write error

Posted by Adrian Mitev <ad...@googlemail.com>.
Could you post that in the new ajax4jsf forum at jboss.com [1]

[1] http://jboss.com/index.html?module=bb&op=viewforum&f=259

2007/3/26, SOSELLA@austin.rr.com <SO...@austin.rr.com>:
>
> I just downloaded and imported version 1.1 rc2 of AJAX4JSF (from a
> version I downloaded sometime in Dec. 2006).  I am now getting a
> 'Session Serialization Error' when stopping my Tomcat server.  I know
> you can turn off Session Serialization, but does anyone anything in
> particular that might be causing this exception?
>

ajax4jsf 1.1 RC2 - session serialization write error

Posted by SO...@austin.rr.com.
I just downloaded and imported version 1.1 rc2 of AJAX4JSF (from a
version I downloaded sometime in Dec. 2006).  I am now getting a
'Session Serialization Error' when stopping my Tomcat server.  I know
you can turn off Session Serialization, but does anyone anything in
particular that might be causing this exception?

Re: Facelets and JSP...how to port JSP code.

Posted by David Delbecq <de...@oma.be>.
En l'instant précis du 21/03/07 16:01, Olivier Ziller GMail Lists
s'exprimait en ces termes:
> Hello,
>
> David Delbecq wrote:
>> Hi, you have 2 possibilities
>>
>> 1) You move this code to a facelet tag handler and make foo a JSF
>> managed bean
>>
>> 2) you create 2 custom facelets tags that support JSP inclusion (this is
>> a pretty usefull thing to do when migrating code, we did it here)
>> (why 2 tags, because you have case when you want jsp included during
>> facelets restor view, and case when you want this to occur during
>> component rendering, depending on jsp code)
>>   
> could you please give a small example on how to do that?
For (1), there are docs and example on the net about creating your own
facelets tag handler (
http://www.jsfcentral.com/articles/facelets_2-2.html
http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk )

For (2), it's just a matter of, in your taghandler or custom component
renderer, getting the servlet controller, locate the appropriate servlet
and make a forward() to it servlet (yes, a JSP is a servlet). It will
then naturally execute and give back, immediatly after execution, 
control to your component  or taghanlder. This way, execution of
facelets don't stop.

PS: another thing you might want to consider, it's possible to have both
facelets and JSP based JSF at the same time (see this
http://wiki.java.net/bin/view/Projects/FaceletsFAQ#How_do_I_use_Facelets_and_JSP_in
)
>
> thanks in advance
>> En l'instant précis du 21/03/07 13:29, SOSELLA@austin.rr.com s'exprimait
>> en ces termes:
>>   
>>> I have been considering moving to Facelets.  I have studied it and like
>>> what I see.  One problem I see is how to port my JSP code into Facelets.
>>>  By this I mean, in some of my pages, I have JSP code
>>>
>>> <jsp:useBean id="foo" class="com.myapp.bean.fooClass" scope="session" />
>>> <%
>>>    if (!foo.isLoaded())
>>>    {
>>>       response.sendRedirect("login.jsf");
>>>    }
>>> %>
>>>
>>>
>>> Does anyone know how you might port this?  I am open to design changes
>>> as well.
>>>
>>> Thanks!
>>>   
>>>     
>>
>>
>>   


Re: Facelets and JSP...how to port JSP code.

Posted by Olivier Ziller GMail Lists <ol...@gmail.com>.
Hello,

David Delbecq wrote:
> Hi, you have 2 possibilities
>
> 1) You move this code to a facelet tag handler and make foo a JSF
> managed bean
>
> 2) you create 2 custom facelets tags that support JSP inclusion (this is
> a pretty usefull thing to do when migrating code, we did it here)
> (why 2 tags, because you have case when you want jsp included during
> facelets restor view, and case when you want this to occur during
> component rendering, depending on jsp code)
>   
could you please give a small example on how to do that?

thanks in advance
> En l'instant précis du 21/03/07 13:29, SOSELLA@austin.rr.com s'exprimait
> en ces termes:
>   
>> I have been considering moving to Facelets.  I have studied it and like
>> what I see.  One problem I see is how to port my JSP code into Facelets.
>>  By this I mean, in some of my pages, I have JSP code
>>
>> <jsp:useBean id="foo" class="com.myapp.bean.fooClass" scope="session" />
>> <%
>>    if (!foo.isLoaded())
>>    {
>>       response.sendRedirect("login.jsf");
>>    }
>> %>
>>
>>
>> Does anyone know how you might port this?  I am open to design changes
>> as well.
>>
>> Thanks!
>>   
>>     
>
>
>   

Re: Facelets and JSP...how to port JSP code.

Posted by David Delbecq <de...@oma.be>.
Hi, you have 2 possibilities

1) You move this code to a facelet tag handler and make foo a JSF
managed bean

2) you create 2 custom facelets tags that support JSP inclusion (this is
a pretty usefull thing to do when migrating code, we did it here)
(why 2 tags, because you have case when you want jsp included during
facelets restor view, and case when you want this to occur during
component rendering, depending on jsp code)
En l'instant précis du 21/03/07 13:29, SOSELLA@austin.rr.com s'exprimait
en ces termes:
> I have been considering moving to Facelets.  I have studied it and like
> what I see.  One problem I see is how to port my JSP code into Facelets.
>  By this I mean, in some of my pages, I have JSP code
>
> <jsp:useBean id="foo" class="com.myapp.bean.fooClass" scope="session" />
> <%
>    if (!foo.isLoaded())
>    {
>       response.sendRedirect("login.jsf");
>    }
> %>
>
>
> Does anyone know how you might port this?  I am open to design changes
> as well.
>
> Thanks!
>   


Facelets and JSP...how to port JSP code.

Posted by SO...@austin.rr.com.
I have been considering moving to Facelets.  I have studied it and like
what I see.  One problem I see is how to port my JSP code into Facelets.
 By this I mean, in some of my pages, I have JSP code

<jsp:useBean id="foo" class="com.myapp.bean.fooClass" scope="session" />
<%
   if (!foo.isLoaded())
   {
      response.sendRedirect("login.jsf");
   }
%>


Does anyone know how you might port this?  I am open to design changes
as well.

Thanks!

Re: FacesContext.addMessage in an action method

Posted by Volker Weber <v....@inexso.de>.
Hi,

not only the same page,
returning null rerenders the same already existing view.
This is exactly the same behavior as a normal validation failure.

Regards,
  Volker

2007/3/19, Simon Lessard <si...@gmail.com>:
> Yes, returning null reloads the same page.
>
>
> On 3/18/07, SOSELLA@austin.rr.com < SOSELLA@austin.rr.com> wrote:
> > Simon,
> >
> > Yes.  I am using <redirect /> in my navigation rules.  What is the
> > behavior of JSF if you return null?  Does it stay on that page?
> >
> > Thanks for the tip.  This might be the explanation I have been seeking.
> >
> >
> > ----- Original Message -----
> > From: Simon Kitching < simon.kitching@rhe.co.nz>
> > Date: Sunday, March 18, 2007 3:48 pm
> > Subject: Re: FacesContext.addMessage in an action method
> > To: MyFaces Discussion <users@myfaces.apache.org >
> >
> > >
> > > Adding error messages from action methods works fine for me.
> > >
> > > And they certainly should show up, even if you don't provide a
> > > component
> > > or client-id (these are optional parameters).
> > >
> > > Are you perhaps returning a navigation string from your action
> > > method
> > > and then using <redirect/> in your navigation rules? This would
> > > definitely discard any registered messages...
> > >
> > > I suggest returning NULL from your action method if you are
> > > reporting
> > > any errors.
> > >
> > > Regards,
> > >
> > > Simon
> > >
> >
>
>

Re: FacesContext.addMessage in an action method

Posted by Simon Lessard <si...@gmail.com>.
Yes, returning null reloads the same page.

On 3/18/07, SOSELLA@austin.rr.com <SO...@austin.rr.com> wrote:
>
> Simon,
>
> Yes.  I am using <redirect /> in my navigation rules.  What is the
> behavior of JSF if you return null?  Does it stay on that page?
>
> Thanks for the tip.  This might be the explanation I have been seeking.
>
>
> ----- Original Message -----
> From: Simon Kitching <si...@rhe.co.nz>
> Date: Sunday, March 18, 2007 3:48 pm
> Subject: Re: FacesContext.addMessage in an action method
> To: MyFaces Discussion <us...@myfaces.apache.org>
>
> >
> > Adding error messages from action methods works fine for me.
> >
> > And they certainly should show up, even if you don't provide a
> > component
> > or client-id (these are optional parameters).
> >
> > Are you perhaps returning a navigation string from your action
> > method
> > and then using <redirect/> in your navigation rules? This would
> > definitely discard any registered messages...
> >
> > I suggest returning NULL from your action method if you are
> > reporting
> > any errors.
> >
> > Regards,
> >
> > Simon
> >
>

Re: FacesContext.addMessage in an action method

Posted by SO...@austin.rr.com.
Simon,

Yes.  I am using <redirect /> in my navigation rules.  What is the
behavior of JSF if you return null?  Does it stay on that page?

Thanks for the tip.  This might be the explanation I have been seeking.


----- Original Message -----
From: Simon Kitching <si...@rhe.co.nz>
Date: Sunday, March 18, 2007 3:48 pm
Subject: Re: FacesContext.addMessage in an action method
To: MyFaces Discussion <us...@myfaces.apache.org>

> 
> Adding error messages from action methods works fine for me.
> 
> And they certainly should show up, even if you don't provide a 
> component 
> or client-id (these are optional parameters).
> 
> Are you perhaps returning a navigation string from your action 
> method 
> and then using <redirect/> in your navigation rules? This would 
> definitely discard any registered messages...
> 
> I suggest returning NULL from your action method if you are 
> reporting 
> any errors.
> 
> Regards,
> 
> Simon
> 

Re: FacesContext.addMessage in an action method

Posted by Simon Kitching <si...@rhe.co.nz>.
SOSELLA@austin.rr.com wrote:
> I have seemingly tried everything.  I put forceId on the <t:inputText>
> (which sets the id properly); I tried a validator and calling
> addMessage() from within the validator method, which although it is
> bulky it did work and the error message appeared; page-level validation
> works (an error message appears if I leave the field empty).  However,
> it does not work if I call FacesContext.addMessage() from within the
> action method.  The error message does not show up.  Is there something
> else I have to do???  Like a PhaseListener or something?  Some other
> setting somewhere?  I am absolutely sure I am getting the correct id
> because I even used a binding property.  I could really use some help. 
> This shouldn't be that difficult.  Thanks!

Adding error messages from action methods works fine for me.

And they certainly should show up, even if you don't provide a component 
or client-id (these are optional parameters).

Are you perhaps returning a navigation string from your action method 
and then using <redirect/> in your navigation rules? This would 
definitely discard any registered messages...

I suggest returning NULL from your action method if you are reporting 
any errors.

Regards,

Simon

Re: FacesContext.addMessage in an action method

Posted by Mike Kienenberger <mk...@gmail.com>.
Note that you'd need something like this as well

<input binding="#{bean.myComponent}" ...

transient private UIInput myComponent;
public UIInput getMyComponent() { return this.myComponent; }
public void setMyComponent(UIInput myComponent) { this.myComponent =
myComponent; }

On 3/17/07, Simon Lessard <si...@gmail.com> wrote:
> Hello,
>
> What id are you using exactly? To add a message to FacesContext you have to
> use clientId, not the base id, so the message addition should be done this
> way:
>
> public String myAction()
> {
>   FacesMessage message = new FacesMessage("My message");
>   FacesContext context = FacesContext.getCurrentInstance();
>
>   context.addMessage(myComponent.getClientId(context), message);
>
>   return null;
> }
>
>
> Regards,
>
> ~ Simon
>
>
>  On 3/17/07, SOSELLA@austin.rr.com <SO...@austin.rr.com> wrote:
> > I have seemingly tried everything.  I put forceId on the <t:inputText>
> > (which sets the id properly); I tried a validator and calling
> > addMessage() from within the validator method, which although it is
> > bulky it did work and the error message appeared; page-level validation
> > works (an error message appears if I leave the field empty).  However,
> > it does not work if I call FacesContext.addMessage() from within the
> > action method.  The error message does not show up.  Is there something
> > else I have to do???  Like a PhaseListener or something?  Some other
> > setting somewhere?  I am absolutely sure I am getting the correct id
> > because I even used a binding property.  I could really use some help.
> > This shouldn't be that difficult.  Thanks!
> >
>
>

Re: FacesContext.addMessage in an action method

Posted by Simon Lessard <si...@gmail.com>.
Hello,

What id are you using exactly? To add a message to FacesContext you have to
use clientId, not the base id, so the message addition should be done this
way:

public String myAction()
{
  FacesMessage message = new FacesMessage("My message");
  FacesContext context = FacesContext.getCurrentInstance();

  context.addMessage(myComponent.getClientId(context), message);

  return null;
}


Regards,

~ Simon

On 3/17/07, SOSELLA@austin.rr.com <SO...@austin.rr.com> wrote:
>
> I have seemingly tried everything.  I put forceId on the <t:inputText>
> (which sets the id properly); I tried a validator and calling
> addMessage() from within the validator method, which although it is
> bulky it did work and the error message appeared; page-level validation
> works (an error message appears if I leave the field empty).  However,
> it does not work if I call FacesContext.addMessage() from within the
> action method.  The error message does not show up.  Is there something
> else I have to do???  Like a PhaseListener or something?  Some other
> setting somewhere?  I am absolutely sure I am getting the correct id
> because I even used a binding property.  I could really use some help.
> This shouldn't be that difficult.  Thanks!
>