Re: Adding new Render Kit

2005-06-15 Thread Martin Marinschek
you are absolutely right, would be nice to have a fully validated renderkit.

If you look into your faces-config.xml (the one which is delivered
with MyFaces), you will find a render-kit node which looks something
like the following:





HTML_BASIC




javax.faces.Command
org.apache.myfaces.Button

org.apache.myfaces.renderkit.html.ext.HtmlButtonRenderer



javax.faces.Command
org.apache.myfaces.Link

org.apache.myfaces.renderkit.html.ext.HtmlLinkRenderer


.


What you do know is copy this render-kit node to a separate location
in your personal (or if you donate it back to MyFaces, to the MyFaces
one) faces-config.xml.

First change the renderkit to something like HTML_401 or whatever you want.

Next change all the renderer-class entries to the classes you implemented.

Done - all you have to do now is to reset your renderkit id in the
application section of the faces-config, something like that:

...

HTML_401
 wrote:
> Martin Marinschek wrote:
> 
> >Well, yes, but in this case you are reusing the standard renderkit!
> >
> >if you just want to define an additional renderkit, you "copy" the
> >standard render-kit definition, give it a new rederkit-id, set your
> >renderer names as appropriate, and set the default renderkit to your
> >special render-kit id
> >
> >regards,
> >
> >Martin
> >
> >On 6/15/05, Mark <[EMAIL PROTECTED]> wrote:
> >
> >
> >>Craig McClanahan wrote:
> >>
> >>
> >>
> >>>On 14 Jun 2005 12:42:01 -, mfaine <[EMAIL PROTECTED]> wrote:
> >>>
> >>>
> >>>
> >>>
> Basically I just need to know how to make the current myfaces components 
> use
> my Renderer classes which are subclasses of the ones that come with 
> myfaces.
> If anyone can tell me how or point me to the right docs I would 
> appreciate it.
> 
> 
> 
> 
> >>>You can accomplish this by defining your own renderer elements in a
> >>>faces-config.xml file that is loaded *after* the standard one for the
> >>>JSF implementation you are using.  The key requirement is to use the
> >>>same values for  and  that the
> >>>standard renderer definitions do (for the standard components, these
> >>>values are all in the JSF spec; for the MyFaces extension components,
> >>>look in the faces-config.xml file that defines them).
> >>>
> >>>Craig
> >>>
> >>>
> >>>
> >>>
> >>>
> Thanks,
> -Mark
> 
> 
> 
> 
> 
> 
> >>>
> >>>
> >>>
> >>>
> >>Thanks, I think I got this working now.
> >>
> >>-Mark
> >>
> >>
> >>
> >
> >
> >
> >
> Could you point me to more detailed instructions on doing that?  I'm
> interested in possibly offering up any changes back to the myfaces
> developers.   It would be better in that case that it be a separate
> render kit instead of  reusing the standard render kit.
> 
> Thanks,
> -Mark
> 
>


Re: Adding new Render Kit

2005-06-15 Thread Mark

Martin Marinschek wrote:


Well, yes, but in this case you are reusing the standard renderkit!

if you just want to define an additional renderkit, you "copy" the
standard render-kit definition, give it a new rederkit-id, set your
renderer names as appropriate, and set the default renderkit to your
special render-kit id

regards,

Martin

On 6/15/05, Mark <[EMAIL PROTECTED]> wrote:
 


Craig McClanahan wrote:

   


On 14 Jun 2005 12:42:01 -, mfaine <[EMAIL PROTECTED]> wrote:


 


Basically I just need to know how to make the current myfaces components use
my Renderer classes which are subclasses of the ones that come with myfaces.
If anyone can tell me how or point me to the right docs I would appreciate it.


   


You can accomplish this by defining your own renderer elements in a
faces-config.xml file that is loaded *after* the standard one for the
JSF implementation you are using.  The key requirement is to use the
same values for  and  that the
standard renderer definitions do (for the standard components, these
values are all in the JSF spec; for the MyFaces extension components,
look in the faces-config.xml file that defines them).

Craig



 


Thanks,
-Mark




   




 


Thanks, I think I got this working now.

-Mark

   




 

Could you point me to more detailed instructions on doing that?  I'm 
interested in possibly offering up any changes back to the myfaces 
developers.   It would be better in that case that it be a separate 
render kit instead of  reusing the standard render kit.


Thanks,
-Mark



Re: Messages and navigation rule redirects

2005-06-15 Thread Richard Wallace

Richard Wallace wrote:


Matt Blum wrote:

The Faces servlet does a forward by default, so all you need to do is 
take out the redirect tag from your navigation rule, and that's what 
will happen.


Well, ok.  But I guess I'm just not understanding where the code to 
put the messages in the session would be in that case.  Would it have 
to be in the JSP page?


Rather than do something like that could I instead save the messages 
to the session after the render response phase with a phase listener 
and then restore them before the restore view phase with another?
This should work assuming that when a  element is 
encountered it dequeues messages it displays, otherwise the messages 
will just continually be added to the session and displayed over and 
over again.  As long as this is the case, I don't see a reason this 
wouldn't work, what do you think?


Well you can forget that.  My assumption was incorrect, the messages are 
not dequeued by the  element.  Not only that, but when 
doing an add the render response phase for that page is never reached 
because it redirects to the other page instead.  Makes sense, but isn't 
too helpful in my situation =P.


Oh well, I'll have to figure out another way or just live with it the 
way it is.


Rich



You can fix the reload issue with a token, which is a 
server-generated value stored submitted with the form that's checked 
on submission and invalidated, so that if the form is re-submitted, 
the server will detect it.  This would allow you to, if the form is 
resubmitted, redirect the user to an error page or somesuch (or do 
anything else you wanted to do).  This is something you should do 
anyway, because even if you do a redirect the user could always use 
the browser's back button and resubmit the form.


Craig McClanahan has included an excellent JSF-friendly 
implementation of this in Shale.  See the javadocs here:
http://people.apache.org/~craigmcc/shale-core-javadocs/org/apache/shale/component/Token.html 
 



I'm not worried about the user hitting the back button and 
resubmitting the form.  They'd have to actually want to go back to the 
form and resubmit it.  And that might be a perfectly valid use-case 
for some people, using their browsers navigation rather than the site 
navigation.




On 6/14/05, *Richard Wallace* <[EMAIL PROTECTED] 
> wrote:


Matt Blum wrote:

> This has been asked a number of times on this mailing list.
>
> The messages are stored in the request object, so you're losing 
them

> with the redirect.  You should probably use a forward, unless
there's
> a truly compelling reason to use a redirect.  If you must use a
> redirect (say, so users can bookmark the resulting page), you'll
have
> to first forward to something that will extract the messages
from the
> request and put them in the session, and then do the redirect
you were
> trying to do in the first place.
>
> -Matt.

The main purpose is to avoid the user being able to hit the browsers
reload button and having the form submitted a second time and a
duplicate entry being created in the database.  How would I use a
forward?  I'm not exactly sure how to do that.  Is that in the
navigation rule or somewhere else?  Will that accomplish what I 
need?


Thanks,
Rich

>
> On 6/14/05, *Richard Wallace* <[EMAIL PROTECTED]

> >> wrote:
>
> Hello again,
>
> This should be a pretty simple problem.  In the CRUD app
that I'm
> using
> as a proof-of-concept for using JSF here at work I've got
everything
> working and think I'm starting to understand some of the
nuances of
> JSF.  But one thing that is not working as I expected is the
> handling of
> messages.
>
> When a user creates an object (say a contact), after filling
out the
> form and hitting submit they are redirected to the contact 
list

> page via
> the navigational rule:
>
> 
> /contact/add.jsp
> 
> #{contactHandler.saveContact
}
> success
> /contact/list.jsp
> 
> 
> 
>
> That works and all, but in the contactHandler.saveContact()
method
> I am
> also adding an informational message that the contact was 
saved

> just to
> give the user a warm fuzzy feeling.  So, in my list.jsp page I
> have the
>  followed immediately by .  But 
nothing is

> displayed when the user is redirected to this page after
successfully
> adding a contact.  I know I'm adding it right 

Re: managed map properties - bug or spec loophole?

2005-06-15 Thread Martin Marinschek
Ok, it's been some time, but I have implemented your suggestion...

try it out in SVN-Head (or the nightly build)...

I think that you are right, even if the spec is not clear about that
issue, it might be nice for the users to have that feature.

regards,

Martin

On 6/12/05, Erik Gustavson <[EMAIL PROTECTED]> wrote:
> I've been playing around with managed properties recently and noticed some
> behavior that I did not quite expect when using map-entries against a Map
> property on my managed bean.
>  
>  If I create a set of map values like this, everything works fine and I get
> my values in a map in my managed bean.
>  
>  
>  
>  someMapping
>  
>  
>  key1
>  value1
>  
>  
>  key2
>  value2
>  
>   
>   
>   
>  
>  However, I decided I wanted my values to be sorted, so I added in a line to
> specify the exact type of Map (TreeMap) class I wanted to be created for me:
>  
>  
>  
>  someMapping
>  java.util.TreeMap
>  
>  
>  key1
>  value1
>  
>  
>  key2
>  value2
>  
>   
>   
>   
>  
>  When MyFaces attempt to create my bean, it blows up trying to coerce a
> HashMap to a TreeMap (see stack trace at end of email). Looking through the
> code, I can see that in
> ManagedBeanBuilder.initializeProperties the value is being
> created as a HashMap. To me, this looks like a bug... the value should be
> created as a HashMap only if the property's Class value is not set (and if
> it's type is set to a non-Map, an class-cast exception would be thrown)
>  
>  something like:
>  
>  case ManagedProperty.TYPE_MAP:
>  if (property.getPropertyClass != null) {
>  Class mapClass =
> ClassUtils.simpleJavaTypeToClass(property.getPropertyClass());
>  value = mapClass.newInstance();
>  } else {
>value = new HashMap();
>  }
>  
>  initializeMap(facesContext, property.getMapEntries(),
> (Map) value);
>  break;
>  
>  etc... etc... same would probably go for Lists as well.
>  
>  Any thoughts on this? I'm not an expert of the JSF spec - is there any
> mention about if its legal to combine map-entries with a specific property
> class in your faces config xml?
>  
>  
>  --- Stack Trace Below 
>  
>  Caused by: javax.faces.FacesException: Cannot coerce java.util.HashMap to
> java.util.TreeMap
>  at
> org.apache.myfaces.util.ClassUtils.convertToType(ClassUtils.java:321)
>  at
> org.apache.myfaces.config.ManagedBeanBuilder.initializeProperties(ManagedBeanBuilder.java:150)
>  at
> org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:63)
>  at
> org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:328)
>  at
> org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:637)
>  at
> org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
>  at
> org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
>  at
> org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:441)
>  ... 42 more
>  Caused by: javax.servlet.jsp.el.ELException: Attempt to
> coerce a value of type "java.util.HashMap" to type "java.util.TreeMap"
>  at
> org.apache.commons.el.Logger.logError(Logger.java:481)
>  at
> org.apache.commons.el.Logger.logError(Logger.java:498)
>  at
> org.apache.commons.el.Logger.logError(Logger.java:566)
>  at
> org.apache.commons.el.Coercions.coerceToObject(Coercions.java:799)
>  at
> org.apache.commons.el.Coercions.coerce(Coercions.java:343)
>  at
> org.apache.myfaces.util.ClassUtils.convertToType(ClassUtils.java:314)
>  ... 49 more
>  
>  
>  
>  
>


RE: Displaying and linking search results

2005-06-15 Thread Srikanth Madarapu
I have a search results page in which I display the results in a dataTable. 
When user selects a particular row to see the details, the backing bean gets 
the clicked row details by calling getRowData on the dataTable's DataModel 
object. Use that row object to get the details and render the detail page.

HTH.

-Original Message-
From: Daniel Murley [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 14, 2005 9:24 AM
To: Myfaces users
Subject: Displaying and linking search results


Hi all,

I'm currently building on JBoss and MyFaces.  I'm having a problem being
able to link search results to another page.

Effectively what happens at the moment is the user enters some criteria,
hits search, the backing bean in a request scope, grabs the information and
makes it available to the page.

However at this point i'm a little stumped, as I don't know how to be able
to link these results to other pages.

My initial thinking was along the lines of :


  


However this doesn't seem to be working.  Am I on the right track here, or
is there a better way to do this?

Thanks,

Daniel



Re: two instances of my PhaseListener

2005-06-15 Thread Martin Marinschek
You are welcome!

regards,

Martin

On 6/15/05, Daniel Zwink <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> on 15.06.2005 18:02 Martin Marinschek said the following:
> 
> > I think (would need to look it up in the spec, though) that the
> > faces-config.xml is taken automatically...
> 
> You're right: JSF Spec 1.1, section 10.1.3
> 
> Thanks for your help!
> 
> 
> Daniel
> --
> Orientation in Objects GmbH
> Weinheimerstr. 68
> D-68309 Mannheim
> http://www.oio.de
> Tel +49(0)621-71839-0
> Fax. +49(0)621-71839-50
>


Duplicate id components in subview

2005-06-15 Thread Jordi Puiggené
A duplicated components id exception is thrown when using diferent subviews.
Well, here is my code:

Default.jsp



...some components...

 






DetailsView.jsp:
<%
DefaultPageBean defaultPage = (DefaultPageBean) javax.faces.context.FacesContext
.getCurrentInstance().getApplication()
.getVariableResolver().resolveVariable(

javax.faces.context.FacesContext
.getCurrentInstance(), 
"default");
%>


















 




The method getSecondaryView() returns a relative path of another jsp file.
The methods showAnalysisView() and showTemplatesView() assigns
specific relative paths to different jsp: When lnkShowAnalysis is
clicked, DetailsViewBackingBean assigns as a secondaryView from
DefaultPageBackingBean the relative path for analysis.jsp. As previous
situation, when lnkShowTemplates is clicked, templates.jsp will be
shown.

When templates.jsp is shown and I click over lnkShowAnalysis, an error
of duplicated ids is throwed. For avoiding that I set specific ids to
all components from all jsp, but it causes strange behaviour: The
secondary view is shown alternatively (it means that if it's shown on
current request, on next request will not be shown and viceversa).

Also, I noticed that the number of components into child subview are
involved in problem: If I have 4 components declared on secondary view
and I remove one of them the exception is not throwed. Furthermore, if
I declare more components than 3 in the same view the exception is
ever shown.
The number of components in child subviews are limited by parent
number of declared components?

After reading some posts I think that my problem could be resolved
applying one of these solutions:

http://forum.java.sun.com/thread.jspa?threadID=524925&messageID=3642843
 
but is possible to solve this problem without setting as transient the
context into decode-methods or without creating a session backing bean
with method createUniqueId()?

Sorry for my english,
Jordi


Duplicate id components in subview

2005-06-15 Thread Jordi Puiggené
A duplicated components id exception is thrown when using diferent subviews.
Well, here is my code:

Default.jsp



...some components...








DetailsView.jsp:
<%
DefaultPageBean defaultPage = (DefaultPageBean) javax.faces.context.FacesContext
.getCurrentInstance().getApplication()
.getVariableResolver().resolveVariable(
   
javax.faces.context.FacesContext
   
.getCurrentInstance(), "default");
%>























The method getSecondaryView() returns a relative path of another jsp file.
The methods showAnalysisView() and showTemplatesView() assigns
specific relative paths to different jsp: When lnkShowAnalysis is
clicked, DetailsViewBackingBean assigns as a secondaryView from
DefaultPageBackingBean the relative path for analysis.jsp. As previous
situation, when lnkShowTemplates is clicked, templates.jsp will be
shown.

When templates.jsp is shown and I click over lnkShowAnalysis, an error
of duplicated ids is throwed. For avoiding that I set specific ids to
all components from all jsp, but it causes strange behaviour: The
secondary view is shown alternatively (it means that if it's shown on
current request, on next request will not be shown and viceversa).

Also, I noticed that the number of components into child subview are
involved in problem: If I have 4 components declared on secondary view
and I remove one of them the exception is not throwed. Furthermore, if
I declare more components than 3 in the same view the exception is
ever shown.
The number of components in child subviews are limited by parent
number of declared components?

After reading some posts I think that my problem could be resolved
applying one of these solutions:

http://forum.java.sun.com/thread.jspa?threadID=524925&messageID=3642843

but is possible to solve this problem without setting as transient the
context into decode-methods or without creating a session backing bean
with method createUniqueId()?

Sorry for my english,
Jordi


Re: two instances of my PhaseListener

2005-06-15 Thread Daniel Zwink

Hi,

on 15.06.2005 18:02 Martin Marinschek said the following:


I think (would need to look it up in the spec, though) that the
faces-config.xml is taken automatically...


You're right: JSF Spec 1.1, section 10.1.3

Thanks for your help!


Daniel
--
Orientation in Objects GmbH
Weinheimerstr. 68
D-68309 Mannheim
http://www.oio.de
Tel +49(0)621-71839-0
Fax. +49(0)621-71839-50


Radio buttons in dataTable

2005-06-15 Thread Peter Mahoney
I am trying to use the x:selectOneRadio component with the spread 
layout. The radio button choices are rendered dynamically as part of a 
dataTable. However, the setter in the backing bean is not being called 
and I am getting an error in the logs:


"There should always be a submitted value for an input if it is 
rendered, its form is submitted, and it is not disabled or read-only."


from HtmlRendererUtils. This method appears to be looking for a value 
submitted by the x:selectOneRadio component. However, each of the 
options has been rendered with a unique name and therefore is not being 
found. Is this correct? As only one value can be submitted, surely the 
names should all be the same?


The code which causes this is:


   
   
   value="#{question.booleanResponse}" required="true" 
rendered="#{question.typeOne}" disabled="#{!handler.poll.updatable}" 
layout="spread">

   
   
   value="#{question.responses}" rendered="#{question.typeMany}" 
disabled="#{!handler.poll.updatable}" layout="spread">

   
 

 
 
  rendered="#{question.typeOne}"/>
  

  


This code worked correctly with the RI.

Peter


Re: two instances of my PhaseListener

2005-06-15 Thread Martin Marinschek
I think (would need to look it up in the spec, though) that the
faces-config.xml is taken automatically...

regards,

Martin

On 6/15/05, Daniel Zwink <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> on 15.06.2005 15:37 Martin Marinschek said the following:
> 
> > this is the code from MyFaces, and it shows that the phase listener
> > should only be added once:
> > [...]
> 
> Yep.
> 
> > I shortly looked over the rest of the code, don't see any problems there...
> >
> > Maybe you got two faces-config.xml files in different directories and
> > this is why they are called twice?
> 
> After debugging the faces servlet initialisation (which is done through
> "org.apache.myfaces.webapp.StartupServletContextListener") I found the
> solution:
> 
> During the servlet initialisation the method "configure()" in
> "org.apache.myfaces.config.FacesConfigurator" is called. This method
> calls a number of other methods to read configuration (files).
> Especially the following two methods are important in this case:
> 
>   feedContextSpecifiedConfig();
>   feedWebAppConfig();
> 
> Due to the fact that I declared my faces config file in web.xml as a
> context-param it was read twice because it is read from web.xml through
> "feedContextSpecifiedConfig()" and also hard coded in "feedWebAppConfig()"!
> 
> - snip -
> String systemId = "/WEB-INF/faces-config.xml";
> - snap -
> 
> 
> Is this desired behaviour? I thought I have to declare my faces config
> file in web.xml and didn't know, that it is hard coded.
> 
> 
> Greets, Daniel
> --
> Orientation in Objects GmbH
> Weinheimerstr. 68
> D-68309 Mannheim
> http://www.oio.de
> Tel +49(0)621-71839-0
> Fax. +49(0)621-71839-50
>


Re: Messages and navigation rule redirects

2005-06-15 Thread Matt Blum
If you do a forward, you don't need to put the messages in the
session.  A forward is entirely server-side, so there's only one
request being processed.  That's why a forward is by far the
easiest way to deal with the issue.

If you must use a redirect, however, you will have to do some extra
work.  You will not be able to use the 
component by itself, because so far as I'm aware (and I don't have time
to look at the javadocs or source code right now) it only will look for
messages in request scope, so will miss anything you put in session
scope.  You will have to write some custom code to put the
messages in the session, or in the FacesContext (which is itself stored
in the session, of course), and to retrieve them from there.  When
you retrieve them, you will as you indicate have to also remove them,
or they will persist.

I think using phase listeners would probably work to do what you want,
but I'm not expert enough in JSF to be certain.  You might be able
to use one to extract any messages from the request and put them in the
session, then another to retrieve them from the session (and remove
them from the session at the same time), and put them into the new
request that will have been created by the redirect, so the
 tag can access them as normal.

You should only go that route if you're sure you really need to,
though, IMHO.  I think you might be much better served by using
forwards, with tokens where necessary to protect against accidental
resubmission.

-MattOn 6/15/05, Richard Wallace <[EMAIL PROTECTED]> wrote:
Matt Blum wrote:> The Faces servlet does a forward by default, so all you need to do is> take out the redirect tag from your navigation rule, and that's what> will happen.>Well, ok.  But I guess I'm just not understanding where the code to put
the messages in the session would be in that case.  Would it have to bein the JSP page?Rather than do something like that could I instead save the messages tothe session after the render response phase with a phase listener and
then restore them before the restore view phase with another?This should work assuming that when a  element isencountered it dequeues messages it displays, otherwise the messageswill just continually be added to the session and displayed over and
over again.  As long as this is the case, I don't see a reason thiswouldn't work, what do you think?Rich> You can fix the reload issue with a token, which is a server-generated> value stored submitted with the form that's checked on submission and
> invalidated, so that if the form is re-submitted, the server will> detect it.  This would allow you to, if the form is resubmitted,> redirect the user to an error page or somesuch (or do anything else
> you wanted to do).  This is something you should do anyway, because> even if you do a redirect the user could always use the browser's back> button and resubmit the form.>> Craig McClanahan has included an excellent JSF-friendly implementation
> of this in Shale.  See the javadocs here:> http://people.apache.org/~craigmcc/shale-core-javadocs/org/apache/shale/component/Token.html
> 
>I'm not worried about the user hitting the back button and resubmittingthe form.  They'd have to actually want to go back to the form andresubmit it.  And that might be a perfectly valid use-case for some
people, using their browsers navigation rather than the site navigation.>> On 6/14/05, *Richard Wallace* <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote:>> Matt Blum wrote:>> > This has been asked a number of times on this mailing list.> >
> > The messages are stored in the request object, so you're losing them> > with the redirect.  You should probably use a forward, unless> there's> > a truly compelling reason to use a redirect.  If you must use a
> > redirect (say, so users can bookmark the resulting page), you'll> have> > to first forward to something that will extract the messages> from the> > request and put them in the session, and then do the redirect
> you were> > trying to do in the first place.> >> > -Matt.>> The main purpose is to avoid the user being able to hit the browsers> reload button and having the form submitted a second time and a
> duplicate entry being created in the database.  How would I use a> forward?  I'm not exactly sure how to do that.  Is that in the> navigation rule or somewhere else?  Will that accomplish what I need?
>> Thanks,> Rich>> >> > On 6/14/05, *Richard Wallace* <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> > [EMAIL PROTECTED]> 
[EMAIL PROTECTED]>>> wrote:> >> > Hello again,> >> > This should be a pretty simple problem.  In the CRUD app> that I'm
> > using> > as a proof-of-concept for using JSF here at work I've got> everything> > working and think I'm starting to unde

Re: two instances of my PhaseListener

2005-06-15 Thread Daniel Zwink

Hi,

on 15.06.2005 15:37 Martin Marinschek said the following:


this is the code from MyFaces, and it shows that the phase listener
should only be added once:
[...]


Yep.


I shortly looked over the rest of the code, don't see any problems there...

Maybe you got two faces-config.xml files in different directories and
this is why they are called twice?


After debugging the faces servlet initialisation (which is done through 
"org.apache.myfaces.webapp.StartupServletContextListener") I found the 
solution:


During the servlet initialisation the method "configure()" in 
"org.apache.myfaces.config.FacesConfigurator" is called. This method 
calls a number of other methods to read configuration (files). 
Especially the following two methods are important in this case:


 feedContextSpecifiedConfig();
 feedWebAppConfig();

Due to the fact that I declared my faces config file in web.xml as a 
context-param it was read twice because it is read from web.xml through 
"feedContextSpecifiedConfig()" and also hard coded in "feedWebAppConfig()"!


- snip -
String systemId = "/WEB-INF/faces-config.xml";
- snap -


Is this desired behaviour? I thought I have to declare my faces config 
file in web.xml and didn't know, that it is hard coded.



Greets, Daniel
--
Orientation in Objects GmbH
Weinheimerstr. 68
D-68309 Mannheim
http://www.oio.de
Tel +49(0)621-71839-0
Fax. +49(0)621-71839-50


Duplicate id components in subview

2005-06-15 Thread Jordi Puiggené
Sorry, 
The mail was sent without finishing !!
It wasn't a joke :))


Duplicate id components in subview

2005-06-15 Thread Jordi Puiggené
Hi,

I have some problems working with child subviews. 
Here is my code:
Page_1.jsp






Re: Pure client side tabbed pane

2005-06-15 Thread Werner Punz

Ok I will have to answer myself, sorry again for all this mess,
I found the bug, the tabbed panes now finally work as expected
(sans keeping the tabbing stage between refreshes, which I will
add later)

Have much fun with the component.
(I am using it myself already in a project,
the component replaced my old javascript mix)

Werner



Re: Messages and navigation rule redirects

2005-06-15 Thread Richard Wallace

Matt Blum wrote:

The Faces servlet does a forward by default, so all you need to do is 
take out the redirect tag from your navigation rule, and that's what 
will happen.


Well, ok.  But I guess I'm just not understanding where the code to put 
the messages in the session would be in that case.  Would it have to be 
in the JSP page?


Rather than do something like that could I instead save the messages to 
the session after the render response phase with a phase listener and 
then restore them before the restore view phase with another? 

This should work assuming that when a  element is 
encountered it dequeues messages it displays, otherwise the messages 
will just continually be added to the session and displayed over and 
over again.  As long as this is the case, I don't see a reason this 
wouldn't work, what do you think?


Rich

You can fix the reload issue with a token, which is a server-generated 
value stored submitted with the form that's checked on submission and 
invalidated, so that if the form is re-submitted, the server will 
detect it.  This would allow you to, if the form is resubmitted, 
redirect the user to an error page or somesuch (or do anything else 
you wanted to do).  This is something you should do anyway, because 
even if you do a redirect the user could always use the browser's back 
button and resubmit the form.


Craig McClanahan has included an excellent JSF-friendly implementation 
of this in Shale.  See the javadocs here:
http://people.apache.org/~craigmcc/shale-core-javadocs/org/apache/shale/component/Token.html 



I'm not worried about the user hitting the back button and resubmitting 
the form.  They'd have to actually want to go back to the form and 
resubmit it.  And that might be a perfectly valid use-case for some 
people, using their browsers navigation rather than the site navigation.




On 6/14/05, *Richard Wallace* <[EMAIL PROTECTED] 
> wrote:


Matt Blum wrote:

> This has been asked a number of times on this mailing list.
>
> The messages are stored in the request object, so you're losing them
> with the redirect.  You should probably use a forward, unless
there's
> a truly compelling reason to use a redirect.  If you must use a
> redirect (say, so users can bookmark the resulting page), you'll
have
> to first forward to something that will extract the messages
from the
> request and put them in the session, and then do the redirect
you were
> trying to do in the first place.
>
> -Matt.

The main purpose is to avoid the user being able to hit the browsers
reload button and having the form submitted a second time and a
duplicate entry being created in the database.  How would I use a
forward?  I'm not exactly sure how to do that.  Is that in the
navigation rule or somewhere else?  Will that accomplish what I need?

Thanks,
Rich

>
> On 6/14/05, *Richard Wallace* <[EMAIL PROTECTED]

> >> wrote:
>
> Hello again,
>
> This should be a pretty simple problem.  In the CRUD app
that I'm
> using
> as a proof-of-concept for using JSF here at work I've got
everything
> working and think I'm starting to understand some of the
nuances of
> JSF.  But one thing that is not working as I expected is the
> handling of
> messages.
>
> When a user creates an object (say a contact), after filling
out the
> form and hitting submit they are redirected to the contact list
> page via
> the navigational rule:
>
> 
> /contact/add.jsp
> 
> #{contactHandler.saveContact
}
> success
> /contact/list.jsp
> 
> 
> 
>
> That works and all, but in the contactHandler.saveContact()
method
> I am
> also adding an informational message that the contact was saved
> just to
> give the user a warm fuzzy feeling.  So, in my list.jsp page I
> have the
>  followed immediately by .  But nothing is
> displayed when the user is redirected to this page after
successfully
> adding a contact.  I know I'm adding it right because I'm
doing it
> the
> same way on the /contact/edit.jsp page which doesn't
redirect after a
> successful edit.
>
> The only things I can think of that would cause this is that
JSF is
> processing the /contact/add.jsp page before doing the
redirect, and
> there is a  tag in there in case there is some
> validation
> error or some other pr

Re: two instances of my PhaseListener

2005-06-15 Thread Martin Marinschek
this is the code from MyFaces, and it shows that the phase listener
should only be added once:

// add phase listeners
for (Iterator iterator =
_dispenser.getLifecyclePhaseListeners(); iterator.hasNext();)
{
String listenerClassName = (String) iterator.next();
try
{
lifecycle.addPhaseListener((PhaseListener)
ClassUtils.newInstance(listenerClassName));
} catch (ClassCastException e)
{
log.error("Class " + listenerClassName + " does not
implement PhaseListener");
}
}

I shortly looked over the rest of the code, don't see any problems there...

Maybe you got two faces-config.xml files in different directories and
this is why they are called twice?

regards,

Martin

On 6/15/05, Daniel Zwink <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> on 15.06.2005 00:57 Werner Punz said the following:
> >>
> >> I'm using Tomcat 5.5.9 and MyFaces 1.0.9. When I deploy my war-file
> >> the two debug-lines are printed twice on sysout with different
> >> hashcodes which indicates to me that the phase listener is instanced
> >> twice, too.
> >>
> >> If I request a JSF-Page the beforePhase- and afterPhase-method are
> >> also called twice for each phase.
> >>
> >> Is this normal behaviour? I hope not :-). Any hints?
> >>
> >>
> > did you check your rootId?
> >
> > String rootId = event.getFacesContext().getViewRoot().getViewId();
> >
> > the reason for doing that simply is, that the phase listeners
> > get chained, and basically at every request you run into the chain
> > of phase listeners sending different root ids, the phase listeners
> > are supposed to trigger on the phase (via callback) and on the rootid
> > which is sent into the listener cycle.
> 
> It's the same viewId. I don't think there are two requests (guessing you
> assumed that). I have no redirect and no forwarding - just a "plain"
> faces site with some content from a database (same behaviour if I call a
> simple "Hello World" page).
> 
> As I said, there seem to be two instances 'cause the constructor is
> called twice while deploying my test application to tomcat.
> 
> Any ideas?
> 
> 
> Daniel
> --
> Orientation in Objects GmbH
> Weinheimerstr. 68
> D-68309 Mannheim
> http://www.oio.de
> Tel +49(0)621-71839-0
> Fax. +49(0)621-71839-50
>


Re: two instances of my PhaseListener

2005-06-15 Thread Daniel Zwink

Hi,

on 15.06.2005 00:57 Werner Punz said the following:


I'm using Tomcat 5.5.9 and MyFaces 1.0.9. When I deploy my war-file 
the two debug-lines are printed twice on sysout with different 
hashcodes which indicates to me that the phase listener is instanced 
twice, too.


If I request a JSF-Page the beforePhase- and afterPhase-method are 
also called twice for each phase.


Is this normal behaviour? I hope not :-). Any hints?



did you check your rootId?

String rootId = event.getFacesContext().getViewRoot().getViewId();

the reason for doing that simply is, that the phase listeners
get chained, and basically at every request you run into the chain
of phase listeners sending different root ids, the phase listeners
are supposed to trigger on the phase (via callback) and on the rootid
which is sent into the listener cycle.


It's the same viewId. I don't think there are two requests (guessing you 
assumed that). I have no redirect and no forwarding - just a "plain" 
faces site with some content from a database (same behaviour if I call a 
simple "Hello World" page).


As I said, there seem to be two instances 'cause the constructor is 
called twice while deploying my test application to tomcat.


Any ideas?


Daniel
--
Orientation in Objects GmbH
Weinheimerstr. 68
D-68309 Mannheim
http://www.oio.de
Tel +49(0)621-71839-0
Fax. +49(0)621-71839-50


Re: BUG: using Converters

2005-06-15 Thread Daniel Zwink

Hi,

on 15.06.2005 11:42 Stefan Lischke said the following:
>

[...]
I'm willing to help with this bug, but i'm not able to debug the stuff,
cause the sources are divided into many dirs and eclipse only accepts

> one source folder as an attachment to a jar.


Any ideas?


Not related to the bug but related to the source handling of Eclipse: 
Just zip the root source directory and add the zip file to the jar.



Daniel
--
Orientation in Objects GmbH
Weinheimerstr. 68
D-68309 Mannheim
http://www.oio.de
Tel +49(0)621-71839-0
Fax. +49(0)621-71839-50


Re: Pure client side tabbed pane

2005-06-15 Thread Werner Punz

Werner Punz wrote:

Just wanted to drop a note, for the people who were waiting
for a pure client side tabbed pane, that I dropped
the first working version, refactored out of my project and bound to the 
myfaces server side tabs, into the sourceforge repo.




Ok command back, the component does not work yet, sorry, but somewhere
along the way I am losing the value to the backend bean bindings.
I am not sure where the problem exactly is, this will be very tough to 
find...
I probably have to postpone it until next week, to get things up and 
running correctly.


Sorry, if that has caused any troubles.

Werner



Re: Adding a validator programmatically

2005-06-15 Thread Csík Norbert
Maybe the encodeChildren method is never called. Due to the spec "This
method will only be called if the rendersChildren property is true."

On 6/14/05, Balaji Saranathan <[EMAIL PROTECTED]> wrote:
> 
> 
> Hi,
> 
> I'm trying to create a custom component and one of my requirements is to
> attach the Regular Expression Validator of myfaces to the input fields
> created by the component. I did a addValidator() to the HtmlInputText
> component that I created in the encodeChildren() of the custom component
> class. However, the validate() is not being called at all. Am I missing
> something here?
> 
> TIA
> bala
> 
> 
> 
> 
> Confidentiality Notice
> 
> The information contained in this electronic message and any attachments to 
> this message are intended
> for the exclusive use of the addressee(s) and may contain confidential or 
> privileged information. If
> you are not the intended recipient, please notify the sender at Wipro or 
> [EMAIL PROTECTED] immediately
> and destroy all copies of this message and any attachments.
> 


-- 
 Norbert Csík


Re: BUG: using Converters

2005-06-15 Thread Martin Marinschek
Hi Stefan,

how about setting up the MyFaces examples as a project and debugging it there?

regards,

Martin

On 6/15/05, Stefan Lischke <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> The last day i played with the converter stuff and the result is, that i
> switched back to the SUN JSF RI, cause myfaces is not handling converter
> stuff properly. With myfaces my converter.getAsString(...) and
> converter.getAsObject(...) is called with a null value as Object or String
> argument.
> 
> The use case:
> I'm using the SelectItem constructor with an object instead of String or an
> Integer as the first value. So the converter.getAsString(...) is called.
> After selecting in a h:selectOneListbox the converter.getAsObject is called.
> 
> I'm willing to help with this bug, but i'm not able to debug the stuff,
> cause the sources are divided into many dirs and eclipse only accepts one
> source folder as an attachment to a jar.
> 
> Any ideas?
> 
> Stefan
> 
> --
> Stefan Lischke NOVACOM Gesellschaft für Internet Services
> Software Engineering  Software Engineering und Consulting mbH
> 
> Dovestr. 1   fon: +49 30 3980540 fax: +49 30 39805411
> D-10587 Berlin   gsm: +49 171 2367112  http://www.novacom.net
> 
>


BUG: using Converters

2005-06-15 Thread Stefan Lischke
Hi,

The last day i played with the converter stuff and the result is, that i
switched back to the SUN JSF RI, cause myfaces is not handling converter
stuff properly. With myfaces my converter.getAsString(...) and
converter.getAsObject(...) is called with a null value as Object or String
argument.

The use case:
I'm using the SelectItem constructor with an object instead of String or an
Integer as the first value. So the converter.getAsString(...) is called.
After selecting in a h:selectOneListbox the converter.getAsObject is called.

I'm willing to help with this bug, but i'm not able to debug the stuff,
cause the sources are divided into many dirs and eclipse only accepts one
source folder as an attachment to a jar.

Any ideas?

Stefan

--
Stefan Lischke NOVACOM Gesellschaft für Internet Services
Software Engineering  Software Engineering und Consulting mbH

Dovestr. 1   fon: +49 30 3980540 fax: +49 30 39805411
D-10587 Berlin   gsm: +49 171 2367112  http://www.novacom.net



Re: Jsf and multilanguage

2005-06-15 Thread Csík Norbert
Yes Kalle is right, the real solution for i18n is using a special
ResourceBundle. I've used the default ResourceBundle - using
.properties files - and that was awsome. It was easy to implement,
easy to use, easy to manage.

On 6/9/05, Korhonen, Kalle <[EMAIL PROTECTED]> wrote:
> I think you are doing it the wrong way. In a multilingual application, all 
> the resources should come from a ResourceBundle (in your case, a custom DB 
> resourcebundle), and you would use the built-in locale support to choose the 
> correct resourcebundle. Then, you don't need to care whether the localizable 
> text is in an attribute or a in a text node.
> 
> Kalle
> 
> > -Original Message-
> > From: Stefan Lischke [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, June 09, 2005 6:50 AM
> > To: users@myfaces.apache.org
> > Subject: Jsf and multilanguage
> >
> > Hi,
> >
> > First thumbs up for the myfaces project, we are using it for
> > a webadmin.
> > I have written an own component derived from the OutputText
> > component to use our self developed multilanguage system. So
> > i can put a key inside the tags value and the component looks
> > the key up in the DB and fills in the right language.
> > This works very good.
> >
> > But now i have a problem, there are some tags, e.g.
> > selectItem where i can only put the visible text in an
> > attribute (itemValue). Now i cannot use our languageOutputText tag.
> >
> > Any ideas, what can solve my problem, to also see the right
> > language at selectItems?
> >
> > Thanx for any help
> >
> > stefan
> >
> > --
> > Stefan Lischke NOVACOM Gesellschaft für
> > Internet Services
> > Software Engineering  Software Engineering und
> > Consulting mbH
> >
> > Dovestr. 1   fon: +49 30 3980540 fax: +49
> > 30 39805411
> > D-10587 Berlin   gsm: +49 171 2367112
> > http://www.novacom.net
> >
> 


-- 
 Csík Norbert  http://norbert.web.elte.hu/
 Programtervező matematikus
 Trilobita Informatikai Rt. - rendszertervező fejlesztőmérnök
___ keep sm:)ing _ooo__C( O O )L__ooo__
http://www.aion.hu/ - A csik.NET otthona
http://www.spreadfirefox.com/ - Rediscover the web
Elméletileg nincs különbség az elmélet és a gyakorlat között,
gyakorlatilag viszont...


JSCookMenu actions in Sun JSF RI + myfaces-extensions

2005-06-15 Thread Juan Medín Piñeiro
Hi,

   For some reason JSCookMenu is ignoring the actions assigned to the
NavigationMenuItem's. I'm using Sun RI (RSA 6.0 distribution) and the
myfaces-extensions.jar.

   Converting the POSTto a GET (just to know what is being sent), this
is the string:

http://localhost:8080/testApp/faces/index.jsp?autoScroll=&jscook_action=formIndex__id0_menu%3AtestOption

   "testOption" is the action, so it's being sent without problems.

   The relevant parts of faces-config.xml are:

   
* 
   
   test
   /testpage.jsp
   
   

   
* 
   
   /whateverSelected.jsp
   
   

Please notice that the second rule should be executed in any case.
Well, the browser just reloads the current page every time I select an
option in the menu. JSCookMenu ignores both rules.Looks like the menu
isn't aware of the config file.

   Could anyone confirm that JSCookMenu actions work without problems in
Sun JSF RI + myfaces-extensions? Is there anything else I should add
to the web.xml besides the extensions filter?

Thanks in advance,

   - Juan


RE: Displaying and linking search results

2005-06-15 Thread Daniel Murley
Ok so in the example, it works.

But my question then becomes, what is the defining factor that actually
makes it work?  I notice there is no use of the  tag in the
dataTable.jsp.  There is however a use of PanelLayout, but surely this
couldn't make a difference?

It really seems like I'm missing something here, and maybe its something
really obvious, or some sort of conflict, I don't know, but its driving me
crazy!


-Original Message-
From: Adrian Merrall [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 15 June 2005 3:48 PM
To: MyFaces Discussion
Subject: Re: Displaying and linking search results


> This thought had actually occured to me, and as such I changed the scope,
> however it had no effect.  Is it possible theres some issue with having
> commandlinks inside datatables?

Yup.  As a complete newbie to anything other than trivial servlets and
JSP pages I struggled with this and found a lot of suggestions but
none worked for me.  Putting the backing bean into the session seemed
to be the most common but that made no change.

In the end I faithfully followed the list example webapp in the source
package.  Look at the examples web app and in particular the
datatable.jsp and countryform.jsp files and their backing beans (IIRC
the backing bean for datatable.jsp is SimpleCountryList.java).

In the examples webapp, look under examples -> components ->
master/detail example to see it in action.

These examples used an x:datatable tag, and x:commandLink and an
x:updateActionListener to ensure the request bean for the individual
item you want to display is set for you.

Once I pretty much made my code exactly the same as the example it
worked very well.

HTH
Adrian




JSCookMenu actions in Sun JSF RI + myfaces-extensions

2005-06-15 Thread Juan Medín Piñeiro
Hi,

  For some reason JSCookMenu is ignoring the actions assigned to the
NavigationMenuItem's. I'm using Sun RI (RSA 6.0 distribution) and the
myfaces-extensions.jar.

  Converting the POSTto a GET (just to know what is being sent), this
is the string:

http://localhost:8080/testApp/faces/index.jsp?autoScroll=&jscook_action=formIndex__id0_menu%3AtestOption

  "testOption" is the action, so it's being sent without problems.

  The relevant parts of faces-config.xml are:

  
   * 
  
  test
  /testpage.jsp
  
  

  
   * 
  
  /whateverSelected.jsp
  
  

Please notice that the second rule should be executed in any case.
Well, the browser just reloads the current page every time I select an
option in the menu. JSCookMenu ignores both rules.Looks like the menu
isn't aware of the config file.

  Could anyone confirm that JSCookMenu actions work without problems in
Sun JSF RI + myfaces-extensions? Is there anything else I should add
to the web.xml besides the extensions filter?

Thanks in advance,

  - Juan