Re: NPE when doing a dispatch()

2006-06-08 Thread Richard Wallace
)
at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:292)
at
org.acegisecurity.ui.switchuser.SwitchUserProcessingFilter.doFilter(SwitchUserProcessingFilter.java:382)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:108)
at
org.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter(SecurityEnforcementFilter.java:197)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:143)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:154)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:214)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:246)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:220)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.securechannel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:168)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:173)
at
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)


Richard Wallace wrote:
 Hey everyone,

 I'm trying to use the ExternalContext.dispatch() method to direct a
 person to a page if they haven't done something they were supposed to
 yet.  My code looks like this:

 if (hasTakenAssessment ()) {
 try {
 getExternalContext ().dispatch
 (/assessment/report/default.html);
 return;
 } catch (IOException ioe

NPE when doing a dispatch()

2006-06-07 Thread Richard Wallace
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hey everyone,

I'm trying to use the ExternalContext.dispatch() method to direct a
person to a page if they haven't done something they were supposed to
yet.  My code looks like this:

if (hasTakenAssessment ()) {
try {
getExternalContext ().dispatch
(/assessment/report/default.html);
return;
} catch (IOException ioe) {
throw new RuntimeException (ioe);
}
}

When the dispatch() is called I get a NPE when the renderkit tries to
figure out the content type.  I'm using myfaces-1.1.1 (I'll upgrade to
1.1.3 when tomahawk gets put in the maven repos), and the offending
line is

contentTypeListString = (String)
   
context.getExternalContext().getRequestHeaderMap().get(Accept);

That causes the below exception to be thrown.  I've used this before
successfully.  Any ideas what could be going wrong this time?

Thanks,
Rich

java.lang.NullPointerException
at
org.apache.myfaces.renderkit.html.HtmlRendererUtils.selectContentType(HtmlRendererUtils.java:919)
at
org.apache.myfaces.renderkit.html.HtmlRenderKitImpl.createResponseWriter(HtmlRenderKitImpl.java:105)
at
org.apache.shale.faces.ValidatorRenderKit.createResponseWriter(ValidatorRenderKit.java:108)
at
org.apache.shale.clay.faces.ClayViewHandler.renderView(ClayViewHandler.java:340)
at
org.apache.shale.view.faces.ViewViewHandler.renderView(ViewViewHandler.java:151)
at
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:292)
at
org.acegisecurity.ui.switchuser.SwitchUserProcessingFilter.doFilter(SwitchUserProcessingFilter.java:382)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:98)
at
org.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter(SecurityEnforcementFilter.java:197)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:143)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:154)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:214)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:246)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:156)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.securechannel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:168)
at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:303)
at
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:173)
at
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:120)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:71)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.shale.faces.ShaleApplicationFilter.doFilter(ShaleApplicationFilter.java:275)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)

Re: [shale] JSF AJAX components using Shale

2006-04-21 Thread Richard Wallace

Craig McClanahan wrote:

On 4/21/06, *Werner Punz* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:

Richard Wallace schrieb:
 Hey everyone,

 I hope you don't mind the cross post, but I just wanted to point
this
 out to everyone.
 https://blueprints.dev.java.net/ajaxcomponents.html

 The AJAX components use Dojo for the client-side and build on
 Shale-remoting for the server-side.  I had a similar idea and
was even
 working on creating some components in my spare time, but hadn't
gotten
 this far.  I know there are also some components in MyFaces
sandbox, but
 I don't think those are as far along as these either.


Neat, I was aware that Sun was looking into Dojo, but I was not aware
that they have started to use it.


We've been working on it for a while, just not talked a lot about it 
yet :-).  There's also a set of these AJAX components available that 
work nicely with Creator.


Craig

That it's been in the works for a while is good news.  I'd love to have 
more information.  This would surely help get the web designer at my 
office off my back about wanting to add some cool ajax stuff to our 
webapps.  I've been wanting to do that too, but just haven't had the 
opportunity to actually write the components myself.


Any idea when we can expect more information about this stuff?

Rich



Re: [shale] JSF AJAX components using Shale

2006-04-21 Thread Richard Wallace

Craig McClanahan wrote:
On 4/21/06, *Richard Wallace* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Craig McClanahan wrote:
 On 4/21/06, *Werner Punz* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:

 Richard Wallace schrieb:
  Hey everyone,
 
  I hope you don't mind the cross post, but I just wanted to
point
 this
  out to everyone.
  https://blueprints.dev.java.net/ajaxcomponents.html
 
  The AJAX components use Dojo for the client-side and build on
  Shale-remoting for the server-side.  I had a similar idea and
 was even
  working on creating some components in my spare time, but
hadn't
 gotten
  this far.  I know there are also some components in MyFaces
 sandbox, but
  I don't think those are as far along as these either.
 

 Neat, I was aware that Sun was looking into Dojo, but I was
not aware
 that they have started to use it.


 We've been working on it for a while, just not talked a lot about it
 yet :-).  There's also a set of these AJAX components available that
 work nicely with Creator.

 Craig

That it's been in the works for a while is good news.  I'd love to
have
more information.  This would surely help get the web designer at my
office off my back about wanting to add some cool ajax stuff to our
webapps.  I've been wanting to do that too, but just haven't had the
opportunity to actually write the components myself.

Any idea when we can expect more information about this stuff?


The BluePrints Catalog components (based on JSF 1.2), as well as the 
JSF 1.1 set, are available at [1].  For Creator 2, simply connect to 
the Update Center after you install it, and you'll be able to download 
the newer version of the JSF 1.1 components.  You can download Creator 
by starting at [2], as well as access a bunch of tutorials about using 
the AJAX based components in a Creator based application.


Craig

[1] https://blueprints.dev.java.net/ajaxcomponents.html
[2] http://developers.sun.com/jscreator/ 
http://developers.sun.com/jscreator/


Any plans to make it easier to use these components without having to 
have Creator and/or Glassfish is what I'm really wondering.  I prefer to 
use just plain Tomcat when I can, and I've come to really like Eclipse 
for my IDE.  But I do all my building, running of tests and deployment 
using Maven.  Right now it seems like it would be very difficult for me 
to even try and get a sample webapp up and running that uses these 
components with my preferred development tools.


Rich


Re: Using images for selectItem labels

2006-04-20 Thread Richard Wallace

Richard Wallace wrote:
I'd like to use images as the labels for the selectItems in 
selectOneRadio component.  Since itemLabel is an attribute of the 
selectItem component, I can't just use a graphicImage.  Am I going to 
have to hack together some funky text label to do it?  Something like


f:selectItem itemValue=1 itemLabel=img 
src=quot;#{facesContext.externalContext.requestContextPath}/images/label1.pngquot; 
/


Or is there a better way of accomplishing this?

Thanks,
Rich
Well, the above idea doesn't work.  Not that that surprises me too 
much.  It just displays the text rather than the image.  So is there any 
way to accomplish this with things as they are, or would it require a 
custom selectItem component to be written?  And if so, does anyone know 
of one out there already?


Thanks,
Rich


[shale] JSF AJAX components using Shale

2006-04-20 Thread Richard Wallace

Hey everyone,

I hope you don't mind the cross post, but I just wanted to point this 
out to everyone. 


https://blueprints.dev.java.net/ajaxcomponents.html

The AJAX components use Dojo for the client-side and build on 
Shale-remoting for the server-side.  I had a similar idea and was even 
working on creating some components in my spare time, but hadn't gotten 
this far.  I know there are also some components in MyFaces sandbox, but 
I don't think those are as far along as these either.


Very cool and exciting stuff.  I especially like the AJAX fileupload and 
the validator.  The progress bar is cool too, but I can't see any way to 
use it in cases where the progress is indeterminate like processing a 
credit card or some other task that you don't know how long it's going 
to take.


Rich


Re: updateActionListener questions (re: Shale Clay mostly)

2006-04-19 Thread Richard Wallace

Martin Marinschek wrote:

I was already wondering myself. It would fit better in the component,
if there is one.

Manfred?

@Rich: Can you do a patch - would be great.

  
On closer inspection I think I see why it is in the tag class rather 
than the component itself.  It uses the 
UIComponentTag.isValueReference() to determine if the value attribute is 
a value binding or not.  I think that should be fine where it is, so 
just adding a setProperty(String) method and creating a value binding 
from that will work.  I tested it in my own app by subclassing 
UpdateActionListener and adding the method.  Works as it should.  
Attached is a patch of UpdateActionListener and UpdateActionListenerTag 
to add the setProperty(String) method and create the value binding and 
in the tag class to just pass along the string value to the component 
rather than create the value binding there.  I'm open to 
comments/criticisms.


Rich

regards,

Martin

On 4/19/06, Richard Wallace [EMAIL PROTECTED] wrote:
  

I'm trying to make use of the Tomahawk updateActionListener action
listener in a Shale Clay based app and was having problems getting it to
work properly.  After doing some debugging I realized that the problem
was that I was trying to map to the property property on the
UpdateActionListener class thinking that the tag property attribute
just passed the value through.

On closer inspection I realized this isn't the case and that the
UpdateActionListenerTag itself takes the value set for the property
attribute and creates a value binding which is passed to the
UpdateActionListener with the setPropertyBinding() method.  Similarly,
the UpdateActionListenerTag also figures out if the value attribute is
supposed to be an actual value object or a value binding.

I searched this list and this was also a problem when trying to
integrate with Facelets.  So my question is why is all this work done in
the UpdateActionListenerTag class instead of in the UpdateActionListener
class itself?  Then the tag class would just pass the values through
like all the other tags in JSF.

Rich





--

http://www.irian.at

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

Professional Support for Apache MyFaces
  


Index: src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListenerTag.java
===
--- src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListenerTag.java	(revision 395279)
+++ src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListenerTag.java	(working copy)
@@ -79,7 +79,7 @@
 FacesContext facesContext = FacesContext.getCurrentInstance();
 Application application = facesContext.getApplication();
 UpdateActionListener al = new UpdateActionListener();
-al.setPropertyBinding(application.createValueBinding(_property));
+al.setProperty(_property);
 if (UIComponentTag.isValueReference(_value))
 {
 al.setValueBinding(application.createValueBinding(_value));
Index: src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListener.java
===
--- src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListener.java	(revision 395279)
+++ src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListener.java	(working copy)
@@ -68,6 +68,11 @@
 private ValueBinding _valueBinding;
 private Converter _converter;
 
+public void setProperty (String property) {
+setPropertyBinding (FacesContext.getCurrentInstance ().getApplication ().createValueBinding (property));
+}
+
+
 public void setPropertyBinding(ValueBinding propertyBinding)
 {
 _propertyBinding = propertyBinding;


Re: updateActionListener questions (re: Shale Clay mostly)

2006-04-19 Thread Richard Wallace

Richard Wallace wrote:

Martin Marinschek wrote:

I was already wondering myself. It would fit better in the component,
if there is one.

Manfred?

@Rich: Can you do a patch - would be great.

  
On closer inspection I think I see why it is in the tag class rather 
than the component itself.  It uses the 
UIComponentTag.isValueReference() to determine if the value attribute 
is a value binding or not.  I think that should be fine where it is, 
so just adding a setProperty(String) method and creating a value 
binding from that will work.  I tested it in my own app by subclassing 
UpdateActionListener and adding the method.  Works as it should.  
Attached is a patch of UpdateActionListener and 
UpdateActionListenerTag to add the setProperty(String) method and 
create the value binding and in the tag class to just pass along the 
string value to the component rather than create the value binding 
there.  I'm open to comments/criticisms.


Rich
Ok, I was wrong.  You do need to also change the setValue() method.  I'm 
not sure about the best way to do this, so I just assumed it would be a 
value binding and everything works as it should:


   public void setValue (Object value) {
   setValueBinding (FacesContext.getCurrentInstance 
().getApplication ().createValueBinding (value.toString ()));

   }


regards,

Martin

On 4/19/06, Richard Wallace [EMAIL PROTECTED] wrote:
 

I'm trying to make use of the Tomahawk updateActionListener action
listener in a Shale Clay based app and was having problems getting 
it to

work properly.  After doing some debugging I realized that the problem
was that I was trying to map to the property property on the
UpdateActionListener class thinking that the tag property attribute
just passed the value through.

On closer inspection I realized this isn't the case and that the
UpdateActionListenerTag itself takes the value set for the property
attribute and creates a value binding which is passed to the
UpdateActionListener with the setPropertyBinding() method.  Similarly,
the UpdateActionListenerTag also figures out if the value 
attribute is

supposed to be an actual value object or a value binding.

I searched this list and this was also a problem when trying to
integrate with Facelets.  So my question is why is all this work 
done in
the UpdateActionListenerTag class instead of in the 
UpdateActionListener

class itself?  Then the tag class would just pass the values through
like all the other tags in JSF.

Rich





--

http://www.irian.at

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

Professional Support for Apache MyFaces
  




Index: 
src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListenerTag.java
===
--- 
src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListenerTag.java
   (revision 395279)
+++ 
src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListenerTag.java
   (working copy)
@@ -79,7 +79,7 @@
 FacesContext facesContext = FacesContext.getCurrentInstance();
 Application application = facesContext.getApplication();
 UpdateActionListener al = new UpdateActionListener();
-
al.setPropertyBinding(application.createValueBinding(_property));
+al.setProperty(_property);
 if (UIComponentTag.isValueReference(_value))
 {
 al.setValueBinding(application.createValueBinding(_value));
Index: 
src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListener.java
===
--- 
src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListener.java
  (revision 395279)
+++ 
src/main/java/org/apache/myfaces/custom/updateactionlistener/UpdateActionListener.java
  (working copy)
@@ -68,6 +68,11 @@
 private ValueBinding _valueBinding;
 private Converter _converter;
 
+public void setProperty (String property) {

+setPropertyBinding (FacesContext.getCurrentInstance ().getApplication 
().createValueBinding (property));
+}
+

+
 public void setPropertyBinding(ValueBinding propertyBinding)
 {
 _propertyBinding = propertyBinding;
  




Using images for selectItem labels

2006-04-19 Thread Richard Wallace
I'd like to use images as the labels for the selectItems in 
selectOneRadio component.  Since itemLabel is an attribute of the 
selectItem component, I can't just use a graphicImage.  Am I going to 
have to hack together some funky text label to do it?  Something like


f:selectItem itemValue=1 itemLabel=img 
src=quot;#{facesContext.externalContext.requestContextPath}/images/label1.pngquot; 
/


Or is there a better way of accomplishing this?

Thanks,
Rich


updateActionListener questions (re: Shale Clay mostly)

2006-04-18 Thread Richard Wallace
I'm trying to make use of the Tomahawk updateActionListener action 
listener in a Shale Clay based app and was having problems getting it to 
work properly.  After doing some debugging I realized that the problem 
was that I was trying to map to the property property on the 
UpdateActionListener class thinking that the tag property attribute 
just passed the value through. 

On closer inspection I realized this isn't the case and that the 
UpdateActionListenerTag itself takes the value set for the property 
attribute and creates a value binding which is passed to the 
UpdateActionListener with the setPropertyBinding() method.  Similarly, 
the UpdateActionListenerTag also figures out if the value attribute is 
supposed to be an actual value object or a value binding.


I searched this list and this was also a problem when trying to 
integrate with Facelets.  So my question is why is all this work done in 
the UpdateActionListenerTag class instead of in the UpdateActionListener 
class itself?  Then the tag class would just pass the values through 
like all the other tags in JSF.


Rich


Error with /META-INF/faces-config.xml

2006-04-05 Thread Richard Wallace
I've got a jar that has a custom converter.  I'm trying to set it up so 
that there is a faces-config.xml in the jar file that will be used to 
make the converter available.  When the webapp loads tho, I'm getting:


Caused by: java.io.FileNotFoundException: JAR entry 
META-INF/faces-config.xml not found


The faces-config.xml file is pretty simple, just:

?xml version=1.0 encoding=UTF-8?
!DOCTYPE faces-config PUBLIC
   -//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN
   http://java.sun.com/dtd/web-facesconfig_1_0.dtd;

faces-config
 converter
   converter-idcom.contentconnections.mpl.Response/converter-id
 
converter-classcom.contentconnections.mpl.common.jsf.ResponseConverter/converter-class

 /converter
/faces-config

So I don't think that's the problem.  And anyways, it's not saying the 
thing is invalid, just that it can't find it even tho I've examined the 
jar file and it is indeed there.


What could be causing this? 


Thanks,
Rich


Browser based component decisions

2006-04-04 Thread Richard Wallace

Hey all,

I'm looking at trying to add some more advanced UI elements to a webapp 
I'm developing.  One thing that I'm concerned about is that this is an 
app that will be used by the general public, not just in-house.  That 
means I have no control over the OS or browser used to access the site.  
Naturally I want as many people as possible to be able to access the 
site.  So I need to do some kind of selection process for when to 
display the cool components and when to display the regular components.


My use case at the moment is that I'm trying to replace a set of radio 
buttons with a slider, the one from Yahoo!s library.  I haven't created 
the JSF component yet and before I invest too much time into it I want 
to determine if it's feasible and how hard it is to do this kind of 
browser based component usage decision making. 
Could it be something as simple as:


h:panelGroup rendered=#{browser.coolComponentCapable}
 rw:inputSlider ...
/h:panelGroup
h:panelGroup rendered=#{!browser.coolComponentCapable}
 h:selectOneRadio ...
/h:panelGroup

Or is there a better way?

Thanks,
Rich


Re: Browser based component decisions

2006-04-04 Thread Richard Wallace

Craig McClanahan wrote:
On 4/4/06, *Richard Wallace* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Hey all,

I'm looking at trying to add some more advanced UI elements to a
webapp
I'm developing.  One thing that I'm concerned about is that this is an
app that will be used by the general public, not just in-house.  That
means I have no control over the OS or browser used to access the
site.
Naturally I want as many people as possible to be able to access the
site.  So I need to do some kind of selection process for when to
display the cool components and when to display the regular
components.

My use case at the moment is that I'm trying to replace a set of radio
buttons with a slider, the one from Yahoo!s library.  I haven't
created
the JSF component yet and before I invest too much time into it I
want
to determine if it's feasible and how hard it is to do this kind of
browser based component usage decision making.
Could it be something as simple as:

h:panelGroup rendered=#{browser.coolComponentCapable }
  rw:inputSlider ...
/h:panelGroup
h:panelGroup rendered=#{!browser.coolComponentCapable}
  h:selectOneRadio ...
/h:panelGroup

Or is there a better way? 



If you're writing the inputSlider component yourself, it would be more 
user friendly to have the component do its own check on user agent, 
and emit the correct kind of markup accordingly. 
We had thought about that, but there's not always going to be a clear 
if you can't use the slider, use this component instead.  I mean, in 
my situation I want to be able to use radio buttons, but that wouldn't 
work if the slider moves in increments smaller than the tick marks.  In 
that situation you could wind up with dozens of radio buttons, so you 
may want to provide a dropdown or something else entirely.  I suppose 
the question I should ask is: Can 2 components be bound to the same 
backing bean property if one of them is not rendered and will that cause 
any problems, such as the non-rendered component overwriting the value 
set by the rendered component?
If you don't have control over the components, then what you describe 
will work -- but you don't need separate panelGroup elements:


h:panelGroup
rw:inputSlider rendered=#{browser.coolComponentCapable} .../
h:selectOneRadio rendered=#{not 
browser.coolComponentCapable} .../

/h:panelGroup

Or, if you don't need the parent to think this is a single component, 
just dispense with the panel group entirely.
You're right, of course.  Don't know why I thought I needed to have them 
wrapped in panel groups.  Oh well.


Rich


Validation questions

2006-04-04 Thread Richard Wallace
I've got 2 forms that I'm trying to do validation on.  One form is an 
assessment form, where the user needs to answer each question.  For the 
validation if a user doesn't enter a response, we want error messages at 
the top of the page that say:


Questions 1, 3, and 7 have not been answered.

So, I've been thinking about what the best way to do that is.  The best 
thing that I can think of is to not use the required attribute and 
instead use a custom required validator to put some error object in a 
form specific list of validation errors.  Then have a JSF component that 
is similar to the messages component - it shouldn't extend it because I 
want form specific validation not page specific - that checks if there 
are any errors in the validation error list and creates appropriate 
message(s).


A default implementation of the new messages component could act just 
like the existing JSF validation and just pump out messages from 
resource properties for the type of control being used.  Someone that 
wanted more control over the error messages could create a custom 
subclass of the messages component that creates one or more messages in 
the format they want.  So, for my case, instead of having something like:


Question 1 has not been answered.
Question 3 has not been answered.
Question 7 has not been answered.

I can condense it into something more user friendly like at the 
beginning of this message.


The second form I'm trying to work with is a user registration form.  On 
this form the user either enters a certificate number that will allow 
them to sign up or they enter their credit card information.  Basically, 
if the certificate is there then the credit card information doesn't 
matter.  But, if the certificate isn't present then the credit card 
information is required.  How should I handle this scenario?  Just add 
the extra validation code in my backing bean so that when the form is 
submitted it does all the checking?  What do you all think?


Thanks for the input,
Rich


Re: Validation questions

2006-04-04 Thread Richard Wallace

Mike Kienenberger wrote:

On 4/4/06, Richard Wallace [EMAIL PROTECTED] wrote:
  

For the
validation if a user doesn't enter a response, we want error messages at
the top of the page that say:

Questions 1, 3, and 7 have not been answered.

So, I've been thinking about what the best way to do that is.  The best
thing that I can think of is to not use the required attribute and
instead use a custom required validator to put some error object in a
form specific list of validation errors.  Then have a JSF component that
is similar to the messages component - it shouldn't extend it because I
want form specific validation not page specific - that checks if there
are any errors in the validation error list and creates appropriate
message(s).



You do want to use the required attribute.   Validators are not
triggered if the value is null, so you can't make a standard required
validator.   It is possible to simulate a custom required validator
(see http://wiki.apache.org/myfaces/OptionalValidationFramework), but
it isn't going to help you in any way 

How so?

and it doesn't fit in well with JSF.
  
I'm not sure I really care too much about fitting in with JSF in 
regards to validation.  I just want something that works.

Instead, you want to generate standard required validation messages,
then create a custom renderer for the messages component that
consolidates each of these messages into something else, probably by a
specific id pattern.I also think you'd be better off extending the
existing messages renderer than creating it yourself.

  
Sounds like a hack to get around a poor validation system.  Is there any 
way to completely replace the JSF validation process with something more 
flexible?  I mean, honestly, this is a pretty simple use case that is 
extremely difficult to implement.  I have to wonder why the required 
attribute is treated as a special case as well.  Validation in JSF seems 
to be just a mess.  I really like JSF overall, but anytime I start 
thinking about doing any validation I have to take a couple of shots of 
whiskey and bite down on something hard to try and forget about the pain.

The second form I'm trying to work with is a user registration form.  On
this form the user either enters a certificate number that will allow
them to sign up or they enter their credit card information.  Basically,
if the certificate is there then the credit card information doesn't
matter.  But, if the certificate isn't present then the credit card
information is required.  How should I handle this scenario?  Just add
the extra validation code in my backing bean so that when the form is
submitted it does all the checking?  What do you all think?



Yes, I think the best bet is to make neither component required, but
do certificate/credit card validation on each component as normal.

Then in your submit action, check that one-and-only-one of the
components have a  non-null value.
  




Re: Validation questions

2006-04-04 Thread Richard Wallace

Mike Kienenberger wrote:

Mike Kienenberger wrote:


It is possible to simulate a custom required validator
(see http://wiki.apache.org/myfaces/OptionalValidationFramework), but
it isn't going to help you in any way
  


On 4/4/06, Richard Wallace [EMAIL PROTECTED] wrote:
  

How so?



No matter what you do, you're still going to have to write java code
that consolidates messages to display them.   It's just as easy to
consolidate FacesMessages as it is to consolidate some custom data
type that you'd conceivably generate in a custom required validator. 
And the required validator controller component is slow due to the

fact that it has to walk the entire component tree a couple times in
order to fire the validation and then adjust the component validation
state.
  
I guess you're right about the FacesMessages.  The only thing I'm not 
sure about is how to differentiate the messages I would want to 
consolidate from messages that I want to display as is. 

Another thing that I find a little annoying is that you either have 
messages tied to a component or global to the page.  You can't have 
messages tied to a form. 

And, of course, one of the biggest pains is customizing messages on a 
per component basis.  What I want is to be able to set the message to be 
displayed for a specific instance rather than for all types of that 
component across the application.


I don't know, maybe the solution to my problem is to just have the 
validation done in my backing bean.  The thing is that that seems to be 
the solution to a lot of my validation use cases.  In fact, I don't 
think I've run into a single real world use case where the standard JSF 
validation works.




Instead, you want to generate standard required validation messages,
then create a custom renderer for the messages component that
consolidates each of these messages into something else, probably by a
specific id pattern.I also think you'd be better off extending the
existing messages renderer than creating it yourself.
  


  

Sounds like a hack to get around a poor validation system.



In this case, it's not the validation system that's the problem.  It's
the displaying of validation errors.   The system logged them as
FacesMessages, so you simply need to change how they're displayed.  
The messages component renderer is the place to change that.


  
But how do you differentiate the messages to be consolidated from those 
that shouldn't be?

 Is there any
way to completely replace the JSF validation process with something more
flexible?  I mean, honestly, this is a pretty simple use case that is
extremely difficult to implement.



Sure.  JSF is completely pluggable, so you could create your own
lifecycle factory and create a lifecycle that skips or replaces the
process validation phase.  However, coming up with something more
flexible is going to be a task.   You're also going to probably break
components that expect a processValidation phase to occur.   It'd be
interesting to hear what you have in mind.   I've yet to see any
decent validation implementations.   Before you get too far into it,
take a look at subforms (talked about more below) as they solve some
of the weaknesses of JSF validation.

  
I'm not sure of exactly what I'd do.  At the moment I'm thinking that 
the three things that I'd really like to see are more customizable 
messages, required being a child element rather than a component 
attribute, and for messages tied to forms in addition to global and 
component messages.  I was probably being a little extreme when I said 
completely replace.  I was just on a bit of a rant cause I've spent to 
much time banging my head against the wall trying to figure out the best 
way of doing things with JSF validation.

I have to wonder why the required
attribute is treated as a special case as well.



I think having the required attribute as a special case was an example
of an implementation detail influencing the spec.   I'm sure the idea
is that if there's no value, then there's no point in validating it.  
But unfortunately, it's an ugly special-case that you have to

constantly work around since it's not treated as a real validator
but is instead implemented separately as part of every component.

  

Validation in JSF seems
to be just a mess.  I really like JSF overall, but anytime I start
thinking about doing any validation I have to take a couple of shots of
whiskey and bite down on something hard to try and forget about the pain.



I agree :)   It's why I tried to write the OptionalValidationFramework :)

However, I think using the MyFaces sandbox subform component or the
ADFFaces subform component is probably a better solution than OVF.  
For one thing, OVF doesn't work well with vanilla JSF 1.1 (requires

facelets + 1.1 or requires 1.2).

I don't think subform components will help with this specific
situation, but they'll be helpful in other partial validation
situations

Re: Validation questions

2006-04-04 Thread Richard Wallace

Craig McClanahan wrote:



On 4/4/06, *Richard Wallace* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Mike Kienenberger wrote:
 Mike Kienenberger wrote:

 It is possible to simulate a custom required validator
 (see
http://wiki.apache.org/myfaces/OptionalValidationFramework), but
 it isn't going to help you in any way


 On 4/4/06, Richard Wallace  [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:

 How so?


 No matter what you do, you're still going to have to write java code
 that consolidates messages to display them.   It's just as easy to
 consolidate FacesMessages as it is to consolidate some custom data
 type that you'd conceivably generate in a custom required validator.
 And the required validator controller component is slow due to the
 fact that it has to walk the entire component tree a couple times in
 order to fire the validation and then adjust the component
validation
 state.

I guess you're right about the FacesMessages.  The only thing I'm not
sure about is how to differentiate the messages I would want to
consolidate from messages that I want to display as is.


Note that your use cases for consolidation are probably on the 20% 
side of the 80/20 rule :-).


Another thing that I find a little annoying is that you either have
messages tied to a component or global to the page.  You can't have
messages tied to a form.


Don't feel limited to using the standard message and messages 
components.  If the messages themselves are tied to individual input 
components, writing a version of the h:messages renderer that picks 
out only the messages for components nested inside a particular form 
is pretty easy.


Well sure, for someone as familiar with it all as you are it's probably 
no big deal at all.  Now that I've got the general approach from the 
description you give down below even I could probably handle it.


And, of course, one of the biggest pains is customizing messages on a
per component basis.  What I want is to be able to set the message
to be
displayed for a specific instance rather than for all types of that
component across the application.

I don't know, maybe the solution to my problem is to just have the
validation done in my backing bean.  The thing is that that seems
to be
the solution to a lot of my validation use cases.  In fact, I don't
think I've run into a single real world use case where the
standard JSF
validation works.


That (validation in the backing bean) seems like the right answer for 
*application* defined vaidations that cross multiple components, which 
includes the use case you are describing.  JSF's validation framework 
is focused on single component sorts of validations.


Alright, that makes sense then.  I was thinking that the validation 
framework in JSF was meant to be a general purpose, handle everything 
validation related framework.


 Instead, you want to generate standard required validation
messages,
 then create a custom renderer for the messages component that
 consolidates each of these messages into something else,
probably by a
 specific id pattern.I also think you'd be better off
extending the
 existing messages renderer than creating it yourself.



 Sounds like a hack to get around a poor validation system.


 In this case, it's not the validation system that's the
problem.  It's
 the displaying of validation errors.   The system logged them as
 FacesMessages, so you simply need to change how they're displayed.
 The messages component renderer is the place to change that.


But how do you differentiate the messages to be consolidated from
those
that shouldn't be?


Here's a strategy for dealing with all the errors related to 
components in a particular form:


* Build a variant of the standard h:messages component that takes some
  sort of reference to the containing form component.

* At rendering time for this component, start doing a recursive tree 
search of

  the form component's children.

* For each component that might have been a source of validation 
errors (simplest
  test is instanceof EditableValueHolder but you might have special 
cases too),
  call FacesContext.getMessages(String clientId) to grab any messages 
assigned

  to that client.

* Consolidate all the messages accumulated during this tree search in 
any manner

  that you desire.

That's a great run down.  I'll give this a try sometime soon I think.  
The only thing I'm not sure about with that is how could you do global 
messages, form specific messages, and component specific messages.  
That's probably not a very likely scenario so it's no big deal if I 
can't have my cake and eat it too.
 


  Is there any
 way to completely replace the JSF validation process

Yahoo! User Interface Library

2006-04-03 Thread Richard Wallace

Hey everyone,

A web designer at work just showed me the DHTML/Javascript libraries 
that Yahoo! released about a month ago at 
http://developer.yahoo.com/yui/index.html.


They look pretty slick and are really well done.  I'm just curious if 
anyone else here has seen them and done any work with integrating some 
of the interface components into JSF.


The one I'm particularly interested in at the moment is the slider 
widget.  It's a much better alternative to providing users with a bunch 
of radio buttons.  And the way it works is seems like it would be very 
flexible.  What I want to do is create something like a 
yahoo:inputSlider component.  Doesn't look like it would be too 
complicated, and if no one else has done it yet would probably be a nice 
foray for me into the world of JSF component development.


Thoughts?
Rich


Re: Yahoo! User Interface Library

2006-04-03 Thread Richard Wallace
This is the first time I've seen Rico. It looks pretty cool. I 
definitely like some of the components there, like the LiveGrid data 
table and the accordion. And the drag and drop is definitely cool. But, 
at the moment the slider is what I'm most interested in. I agree it 
would be nice if all these new frameworks and js component libraries 
were to be consolidated into one so the focus could be on new features 
rather than reinventing the wheel 200 times, but the same could be said 
of any other framework.


Have you used all the Rico components in JSF? I'm particularly 
interested in hearing about the LiveGrid data table and how it works 
when used in a JSF environment.


Does anyone have a list of the JSF component libraries that are out 
there? I know there are some commercial ones that basically AJAXify any 
JSF component (like AjaxFaces), and like ICEFaces that is an AJAX 
enabled JSF implementation, but what other ajax libraries are out there 
other than the sandbox? Are there any?


Mert Çalışkan wrote:

yet another javascript framework..
we were happy with rico  prototype... :)
Actually it has some nifty features.
In the mean time it made me wonder..Anyone using a javascript-enabled 
multi-language supported calendar component? (like the yahoo's 
/default calendar/)...

Mert
On 4/3/06, *Mike Kienenberger* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


On 4/3/06, Jurgen Lust [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
 There are some very nice components there, especially the drag
and drop
 stuff and, indeed, the slider. The license is BSD however, that
might be
 a problem...

No, the BSD license is not a problem.






Re: Simple progress bar

2006-02-23 Thread Richard Wallace

Arshad Ali wrote:
You can use animated gif for that, just put animated gif in a DIV 
tag, and set visible true / false according to the action


--
Syed Arshad Ali 
That's a little too simple for what I need.  I still need the progress 
bar to be able to check the server to see when the transaction is done 
processing.  I don't want to leave the user hanging for 30 seconds if 
the transaction only takes 5 to process.  The existing progress bars are 
good, the only problem I have with them is that they seem to only 
display percent done and don't have the ability to display work being 
done on an process that can't be known.  Then again, maybe the best 
thing to do is to put the range from 1 to whatever the payment gateway 
timeout is and do it that way.


Rich


Simple progress bar

2006-02-22 Thread Richard Wallace
I'm trying to find a simple progress bar to use in a webapp that has to 
run a credit card transaction.  The payment gateway could take up to 30 
seconds to return a response, so I need to display something to the user 
while that is happening.  I know there is an AJAX component in the 
Blueprints catalog and in ADF Faces.  But from what I can tell from both 
of those is that they will display something like a percent done to the 
user.  What I want is more like the kind of progress bar that just gives 
the user an indication that something is going on.  It shouldn't display 
a percentage because there is no real way to determine how much time is 
actually left to finish processing the transaction.  Is there an old 
school progress indicator component out there?


Thanks,
Rich


Re: t:message and summaryFormat

2006-02-03 Thread Richard Wallace
So, am I way off base on what the summaryFormat attribute for 
t:message is supposed to be?  Is there another way to have per input 
field error messages?


Rich

Richard Wallace wrote:

Hello all,

I'm trying to use the summaryFormat attribute of the tomahawk message 
component with the following:


 h:form id=form onsubmit=return validateForm(this);
   h:panelGroup
 h:outputLabel for=textInput value=Input /
 h:inputText id=textInput required=true /
 t:message for=textInput summaryFormat=You must enter a 
value for {1}.  If you don't, you'll be sorry! /

   /h:panelGroup
   br /
   h:commandButton action=doIt /
 /h:form

According to the web site, this should display the error message Your 
must enter a value for Input.  If you don't, you'll be sorry!  
Instead, I'm seeing the plain old Input: Value is required.  I'm 
using myfaces and tomahawk 1.1.1,  do I need to be using a snapshot 
version?


Thanks,
Rich




t:message and summaryFormat

2006-02-02 Thread Richard Wallace

Hello all,

I'm trying to use the summaryFormat attribute of the tomahawk message 
component with the following:


 h:form id=form onsubmit=return validateForm(this);
   h:panelGroup
 h:outputLabel for=textInput value=Input /
 h:inputText id=textInput required=true /
 t:message for=textInput summaryFormat=You must enter a 
value for {1}.  If you don't, you'll be sorry! /

   /h:panelGroup
   br /
   h:commandButton action=doIt /
 /h:form

According to the web site, this should display the error message Your 
must enter a value for Input.  If you don't, you'll be sorry!  Instead, 
I'm seeing the plain old Input: Value is required.  I'm using 
myfaces and tomahawk 1.1.1,  do I need to be using a snapshot version?


Thanks,
Rich


Re: JSF Components For Acegi Security Framework

2006-01-19 Thread Richard Wallace

Very cool!

What about a component for handling user logins?  Or do you use a 
regular jsp/html page for submitting a form to the 
j_acegi_security_check url (or whatever your filter processing url might 
be)?


Cagatay Civici wrote:

Hi,

I've implemented custom jsf components that can be used to integrate 
Acegi into JSF. Acegi has built-in JSP tags for securing components 
but no support for JSF, my aim is to do the same thing for the JSF 
environment.


Related information can be found at my blog;
http://www.jroller.com/page/cagataycivici?entry=acegi_jsf_components_hit_the 



I've released the component in sourceforge jsf-comp. The component is 
under Apache License.

http://sourceforge.net/projects/jsf-comp/

If you are planning to use JSF-Spring-Acegi together in your 
applications, this component could be a possible solution.


Regards,

Cagatay Civici




Restore-view phase question

2006-01-15 Thread Richard Wallace

Hello all,

I have a question regarding the restore-view phase.  What I want to do 
is create a phase listener to try and process get parameters.  The idea 
is that I'd have a phase listener which registers for the after 
restore-view event.  So, my question is, if there is no view to restore, 
such as a first visit to the page, is this event always fired?


Another thought I'd had is that I'd like to be able to determine whether 
there was any view to restore in my phase listener so I know whether to 
look at the get parameters or not.  If there was a view to restore, I 
don't really care about the get parameters because the user is coming 
from another JSF page.  Otherwise, they could be coming from a link sent 
in an email or something else and I want to use the get parameters to 
set properties (like search parameters, etc.) on my backing beans.  So, 
is there a way to determine if the user came from a JSF page or a plain 
old link?


Thanks,
Rich


Re: JSF Flaw: Comopnent not preserving it state

2006-01-13 Thread Richard Wallace
The biggest problem I can see with making the default value for this 
true for the dataTable component is that the DataModel could very well 
be backed by data loaded from an ORM tool such as Hibernate.  In this 
case, it would be very easy to run into LazyInitializationExceptions or 
equivalent.  Also, as pointed out, if the data is loaded from the 
database, other users interacting with the system could cause a user to 
see stale data.  A refresh button for the table is a poor solution to 
this, because in my experience when a user sees a new page load they 
expect the data to be the latest.  Making them have to hit an additional 
refresh button would just confuse them.


On a bit of a different note, something I've run into with DataTables 
that bugs me is the way JSF handles the Master-Detail pattern.  Using 
the traditional way of finding the object the user selected with the 
DataModel.getRowData() method is error-prone if another user adds an 
object that would appear in the table before the one the user is trying 
to drill-down on.  The user could wind up with an off-by-one error, 
getting the object above the one they selected.  I don't know what the 
best solution to this is.  In the past I've tried to use the 
t:updateActionListener to set an id parameter in the backing bean and 
load just the object I'm interested in for the details as an alternative 
to using the DataModel.getRowData() method.  But I'm not sure that's any 
better for consistency because I'm not sure when the parameter for the 
updateActionListener is actually set.  If it's when the master page is 
loaded, then it will work fine.  But if it's when the view is being 
restored when the link to go to the detail page is clicked, then this is 
still error-prone.  Of course, it also doesn't solve the problem of 
having to do the select for all the things that would show up in the 
master list when all you're interested in is the single object you want 
to get details on.


Just my 2c worth.

Rich

Yee CN wrote:

I definitely consider this a flaw. There is no reason why a dataTable should
behave differently from an inputText. preserveDataModel should be enforced
in all components and enabled by default. It should only be disabled with
explicit settings.

This has been a major stumbling block for me to get a clear understanding of
the JSF technology. Judging from the discussions in this news group - I
think I am not the only one.

What is the possibility of rectifying this in JSF spec?

Regards,
Yee

-Original Message-
From: Simon Kitching [mailto:[EMAIL PROTECTED] 
Sent: Saturday, 14 January 2006 12:15 PM

To: MyFaces Discussion
Subject: Re: AW: An optimised pattern for using t:dataTable - please verify.

On Fri, 2006-01-13 at 15:27 +0100, Matthias Kahlau wrote:
  

Hi Simon!

You wrote:



NB: The default behaviour (no preserveDataModel) is flawed because it
doesn't get (2) right for datasets that may be changed by something
other than the viewing user.
  

Isn't this only a problem if the dataModel is directly backed by the
database, so that the database is accessed on each call of getDataModel()?



Well, it's flawed for any dataset that may be changed by something
other than the viewing user. But yes the most common situation that
occurs in is when an app is retrieving data from a shared database.

When all the data is held in memory and does not change (ie is static
reference data) then of course the default behaviour is fine. However
that isn't often the case.

Regards,

Simon

  




Re: Partial page refresh in JSF?

2005-12-07 Thread Richard Wallace
Have you looked at AjaxAnywhere (http://ajaxanywhere.sourceforge.net/) 
yet? It works exactly this way, giving you zones on the page that get 
reloaded when certain actions occur.


Jeremy Sager wrote:


Hi guys –

Thanks in advance for your answer to this question…

My company is trying to put together a web client application using 
JSF that has the look and feel of the Eclipse Rich Client Platform.


While we’ve had a good bit of success so far, I’ve run into an issue 
that I’m hoping you guys can give me some advice on.


Basically, I need to do partial page refreshes. I have a page with 
three subpages on it that I am controlling the layout of with tiles, 
although I am not tied to tiles at this point if it isn’t the right 
answer.


I need to be able to click on a hyperlink on one of the subpages and 
initiate a refresh action on another one of the subpages without 
refreshing the parent page, because two of my subpages require 
significant database action and hence take some time to load, and a 
user might typically want to click on a decent number of links in 
quick succession. (For those of you familiar with RCP, clicking a link 
in the view opens up a new editor in the editor pane).


I was hoping that you guys could throw some advice my way on how to 
refresh the pages in a subview or tile without refreshing the whole 
darn thing.


Jeremy Sager

Data Communications Product Manager

Chesapeake System Solutions

410.356.6805 x120

[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]





Re: [OT] Generic search in Hibernate

2005-10-08 Thread Richard Wallace

Werner Punz wrote:

Richard Wallace wrote:
  

How do you normally do search functionality like this?  Do you expose
the Hibernate query API to the JSF layer?


No, that is why the BO-DAO Pattern existis, I usually
and that works exceptionally well, split the application
into three layers
one which is tied to JSF sort of the UI layer then the business object
layer which encapsules all the functionality needed in a semi/reusable
abstracted business layer and over that layer automated transactions
are woven via aop (spring in the last two cases)
and the pure database access is moved into DAO objects.

It is more overhead to program, but in the end you get resuable business logic
and a rather good abstraction of the data access layer.

In the long run probably a move of the BO layer to EJB3 will make sense
(I am using Spring for that now)
but EJB was sort of a no touch thing to me, up until recently, due to the 
overhead
complexity and glue code involved with it, that will change soon with EJB3.

  
Yes, this is the EXACT situation I'm in.  I have my DAOs only doing data 
access and have a BO, or service layer, that is where I do all the 
more complicated business logic stuff and JSF only ever accesses the 
service API.  I also use Spring and have my transactions woven in with 
aop and plan to also use acegi to weave in authorization.
  

The main reason I wanted to try and abstract it was in case we did see
some need in the future to swtich to a different ORM tool like EJB 3 or
whatever else is the latest greatest.  I mean, in theory, the
presentation layer shouldn't care one wit what the data access layer
uses to get it's job done.  That's the whole reason for abstracting the
Hibernate stuff in DAOs.


I think DAO should be enough, you just pass the parameter lists
you determine into the DAO and have the query logic there
figure it out.
No need for another layer of query abstraction,
you might also consider to move all your query stuff which is not
categorized to a central place so that you can adjust that.
But moving that stuff into a DAO layer if you do it cleanly should
be sufficient to give you the chance to move the
data access into another system, one of the reasons why
the DAO pattern exists at all.

  
The only reason I'm reluctant to do something like a parameter list is 
because it's pretty limited to the kind of queries you can do.  Usually 
you'll be stuck only doing an and or an or on all the parameters and 
can't really do anything more complex.  For most situations that would 
be ok but there are a couple of situations in which I will need to be 
able to do more expressive queries.
  

I don't think my situation is all that different from others that are
out there.  I have Hibernate at the lowest level doing data access,
spring in the middle managing services which use the data access layer
and then JSF at the presentation layer utilizing the APIs the services
expose.  I guess I'm just curious about what the best practices are and
what people would think if I exposed the fact that the data layer is
using Hibernate at the presentation layer by using the Hibernate
criteria API.



No as I said... push the query data through your layers
as POJOs into the DAO layer and have the dao layer deal with it on the query 
level.
But do not push controls or something else JSF related into either the Business 
Layer
or the DAO layer, you lose portability and and up in a mess which is hard to 
clean
afterwards.

Generally following the DAO-BO approach with a clean separation of concerns
is currently to my knowledge considered a very good approach. You get other 
benefits
from it, like you can AOP the interfaces and do other stuff (like adding 
automated transaction
handling on business level, you can do a simulation on parts of the system
which are not finished and then IoC the parts you just get in etc...)

The downside of this pattern is, it is rather
coding intensive and definitely not suitable for
quick hacks and swiftly written applications.
The ideal idea would be to have a collection of
business objects which you can apply to a workflow
the system has to perform, but that idea is unfortunately good on paper
but does not work out as expected in reality. Hence the whole EJB approach
sort of was a good idea but did not work fully out.

  
Alright, it sounds like there are a couple of approaches that I can 
explore. 

1) Passing a list of parameters to the DAOs and let them build the 
criteria or query to be executed.  One interesting thing here is that I 
could actually use some query by example kind of thing and then just use 
Hibernates query by example capabilities.  Otherwise, this is probably 
going to be something like a list of some kind of object that 
encapsulates the property, the operation and the value to do the 
filtering with.  This would limit me to doing only disjunctions and 
conjunctions, but it does put all the data access specific logic in the 
DAOs where they should

Re: Message Panel in JSF/MyFaces

2005-10-07 Thread Richard Wallace
Have you taken a look at AjaxAnywhere 
(http://ajaxanywhere.sourceforge.net/)?  I haven't used it yet but I 
plan to for all my data tables that will be sortable and pageable etc.  
The basic principal is that you mark zones of the page as ajax 
reloadable and then you use javascript to reload whichever zone you want 
whenever you want it reloaded.  They don't have true JSF components yet, 
but you can still use it with JSF.  Here's a demo 
http://ajaxanywhere.sweetdev-labs.org:8080/ajaxAnywhereDemo/facesFrame.jsp.  
They plan on adding more JSF capabilities in the next version AFAIK.


Rich

MarcV wrote:

Hello,

we have to implement a message panel where the a-synchronous
messages from the server will be displayed in real-time and avoiding
the usual refresh page.
The messages will be of 3 audience : All, group of user, specific user.

We've saw in the Sandbox the auto-update table with Ajax...

Is it suitable for that ?
Is it compatible with Sun RI
Do you have any other tips/tools/recommendation for that ?

--
A+,
MarcV.
  




[OT] Generic search in Hibernate

2005-10-07 Thread Richard Wallace

Hey all,

I'm just wondering how anyone has implemented like a generic search 
using Hibernate as a backend.  More specifically, when the data access 
layer (Hibernate) is abstracted away from the presentation layer (JSF).


I I'm trying to find some way of creating some kind of search ability 
that can have a user defined number and type of parameters.  The problem 
I'm running into is that the data access library being used is 
completely abstracted from JSF so I need some neutral type of criteria 
or query to pass to the underlying system. 

I've toyed with creating a custom criteria API that can then be 
translated into whatever backend criteria API is in use, whether it's 
Hibernate, EJB 3 or something else.  But it's a complicated issue even 
for some of the seemingly simple things that I'm trying to do.



How do you guys approach this kind of problem?

Thanks,
Rich


Re: [OT] Generic search in Hibernate

2005-10-07 Thread Richard Wallace
How do you normally do search functionality like this?  Do you expose 
the Hibernate query API to the JSF layer? 

The main reason I wanted to try and abstract it was in case we did see 
some need in the future to swtich to a different ORM tool like EJB 3 or 
whatever else is the latest greatest.  I mean, in theory, the 
presentation layer shouldn't care one wit what the data access layer 
uses to get it's job done.  That's the whole reason for abstracting the 
Hibernate stuff in DAOs. 

I don't think my situation is all that different from others that are 
out there.  I have Hibernate at the lowest level doing data access, 
spring in the middle managing services which use the data access layer 
and then JSF at the presentation layer utilizing the APIs the services 
expose.  I guess I'm just curious about what the best practices are and 
what people would think if I exposed the fact that the data layer is 
using Hibernate at the presentation layer by using the Hibernate 
criteria API.


Werner Punz wrote:

Richard Wallace wrote:
  

Hey all,

I'm just wondering how anyone has implemented like a generic search
using Hibernate as a backend.  More specifically, when the data access
layer (Hibernate) is abstracted away from the presentation layer (JSF).

I I'm trying to find some way of creating some kind of search ability
that can have a user defined number and type of parameters.  The problem
I'm running into is that the data access library being used is
completely abstracted from JSF so I need some neutral type of criteria
or query to pass to the underlying system.
I've toyed with creating a custom criteria API that can then be
translated into whatever backend criteria API is in use, whether it's
Hibernate, EJB 3 or something else.  But it's a complicated issue even
for some of the seemingly simple things that I'm trying to do.




Well abstracting the already abstracted hibernate query api does not really
make that much sense unless you plan to switch the db access layers.
All I can say is, dont do it and even if you try to do it, it is not worth
the effort.

But as for crtieria queries, you can go for the Hibernate criteria queries
to get a dynamic query behavior.

  




Re: Hibernate and Datascroller

2005-09-29 Thread Richard Wallace
The problem is that the bean that holds the list of data for the table 
is session scoped.  So, on the first request to the page the hibernate 
query is done and then you store the resulting List in the HTTP 
session.  On a subsequent request to the page you try to access data in 
the List that you didn't access on a previous request.  Since the List 
is lazily loaded and you are no longer operating within the same 
Hibernate session that was used to do the query you get the lazy 
initialization exception. 

A general rule of thumb that I've had to adopt is to never put a 
Hibernate returned object or List in the HTTP session because if there 
is any lazy loading involved, whether they're elements in a List or 
properties of an object, you will get the LLE.  It's better just to 
re-run the query.  If you're using the 2nd level cache and query caching 
then it's not that much more overhead and much less work than trying to 
do something like DTOs.


Rich

Ryan Wynn wrote:


Any hibernate-spring experts out there that could tell me how I can 
still get a LazyInit exception inside my spring 
OpenSessionInViewFilter.  My stack trace clearly says I am inside the 
Filter.  Exception - No session or session was closed.


This is happening when using the myfaces datascroller for a datatable 
and paging.  Bean that holds List of data for table is session scoped.


Unfortunately, the data is a list of hibernate objects.  I probably 
should be copying these into plain pojos for the view, but that is not 
what I am doing.  Probably because then I could need to replicate my 
entire object tree. 




t:updateActionListener and Master-detail

2005-09-29 Thread Richard Wallace

Hey all,

I'm running into a situation that's got me very confused.  Basically I'm 
using the t:updateActionListener to do the master-detail pattern as in 
the examples.  The problem I'm running into is that the value passed to 
the property doesn't seem to be correct all the time.  I think the 
problem is that the list that I'm trying to drill down into is a 
filtered list and is filtered based on some state in the backing bean.  
I'm not preserving the state of the filters in the backing bean so when 
the data model is recreated it does so without the filters and uses 
instead an unfiltered list.  I can use t:saveState to save the 
filters, that's no problem. 

What I am a bit surprised by though is that the value parameter to the 
t:updateActionListener doesn't seem to be figured out until after the 
user clicks the commandLink.  I was expecting the value of the parameter 
to be determined when the page first loads so that you're guaranteed 
that the value used when the page loads is the same value set in the 
property attribute.  Otherwise, it seems this is could result in 
problems if, for instance, the data model changes (elements are added 
and/or removed) in between the two requests.  That's one of the reasons 
I was using the t:updateActionListener rather than doing something 
more like a handler that gets the data model and uses the getRowData() 
to get the currently selected object.


I know I could use the preserveDataModel attribute on the extended data 
table to make it unnecessary to refetch the data list, but I'm using 
Hibernate here so that's not really possible.  I also don't want to do 
that because the list could be quite large and change pretty frequently.


Is it possible to change the t:updateActionListener to determine the 
value that is going to be set on the property when the page loads rather 
than after the commandLink or button is clicked?



Thanks,
Rich


Long[] and selectManyListbox

2005-09-26 Thread Richard Wallace

Hey all,

I'm trying to use a selectManyListbox component on a page to allow the 
user to select multiple things.  The SelectItems are created from a list 
returned from Hibernate so the value object is of type Long.  In my 
backing bean I'm using the following methods:


public Long[] getSelectedItems();
public void setSelectedItems (Long[] ids);

The page comes up just fine to start with but when I try to submit it I 
get conversion error.  The headlines from the stack trace are:


javax.faces.el.EvaluationException: Cannot set value for expression 
'#{departmentTypeHandler.selectedInstitutionTypeIds}' to a new value of 
type [Ljava.lang.Object;


Caused by: javax.servlet.jsp.el.ELException: Attempt to coerce a value 
of type [Ljava.lang.Object; to type [Ljava.lang.Long;


I tried setting a converter on the selectManyListbox with 
converter=javax.faces.Long to try and make it convert the String[] to 
a Long[].  But that didn't work at all, seemed as if the converter 
didn't even get used.  Is this the right approach or do I need to create 
a converter for converting a String[] to a Long[]? 

I know I could probably convert the value to of the SelectItems to 
Strings, but I'd rather not do that unless I absolutely have to.  Seems 
a little hackish.  What else might I try?


Thanks,
Rich


Re: Long[] and selectManyListbox

2005-09-26 Thread Richard Wallace
Ok, well what's weird is that I couldn't even do it if I set the return 
type and parameter type and stuff to String[].  It was still giving me 
the same problems.  The only way I could get this to work is by 
returning an Object[] and in the setter having the parameter be an 
Object[].  But then I can just do a direct cast to a Long of elements of 
that array, so it is, in fact, a Long[].


I'm chalking this up to odd conversion issues that others seem to be 
reporting.


Richard Wallace wrote:

Hey all,

I'm trying to use a selectManyListbox component on a page to allow the 
user to select multiple things.  The SelectItems are created from a 
list returned from Hibernate so the value object is of type Long.  In 
my backing bean I'm using the following methods:


public Long[] getSelectedItems();
public void setSelectedItems (Long[] ids);

The page comes up just fine to start with but when I try to submit it 
I get conversion error.  The headlines from the stack trace are:


javax.faces.el.EvaluationException: Cannot set value for expression 
'#{departmentTypeHandler.selectedInstitutionTypeIds}' to a new value 
of type [Ljava.lang.Object;


Caused by: javax.servlet.jsp.el.ELException: Attempt to coerce a value 
of type [Ljava.lang.Object; to type [Ljava.lang.Long;


I tried setting a converter on the selectManyListbox with 
converter=javax.faces.Long to try and make it convert the String[] 
to a Long[].  But that didn't work at all, seemed as if the converter 
didn't even get used.  Is this the right approach or do I need to 
create a converter for converting a String[] to a Long[]?
I know I could probably convert the value to of the SelectItems to 
Strings, but I'd rather not do that unless I absolutely have to.  
Seems a little hackish.  What else might I try?


Thanks,
Rich




t:dataList and Sets

2005-09-26 Thread Richard Wallace

Hey all,

I was just trying to get a Hibernate mapped collection, a Set, displayed 
on a page with a t:dataList component.  Much to my chagrin I started to 
get exceptions like javax.servlet.ServletException: ServletException in 
'/admin/departmentType/list.jsp': javax/servlet/jsp/jstl/sql/Result 
which I thought was really odd since I don't use any such beast in my 
app, it's all Hibernate based.


I thought that maybe something was wrong with my collection mapping so 
tried just doing a h:outputText value=#{myPojo.myMappedCollection} / 
and it displayed the correct data.  So I did some digging in the 
tomahawk docs and it says for supported types see JSF Spec 4.1.3.  Of 
course, that is a spec doesn't include sets, only Lists and ResultSets.  
So I can only guess myfaces tried to map the collection to a ResultSet 
and failed and so gave the not so informative message.


Looking on the list for dataTable and Hibernate messages to see how 
people had coped with this I found that the t:dataTable component can 
create DataModels directly from Sets.  So, what I'm wondering is why 
doesn't the t:dataList support this?


That would make life so much simpler for me and probably others using 
Hibernate like this.  Thoughts?


Thanks,
Rich


Re: t:dataList and Sets

2005-09-26 Thread Richard Wallace
Oh ok cool.  Was that fix included in the 1.1.0 release?  That's what 
I'm using and I'm having problems with.


Rich

Bruno Aranda wrote:

Well, since 15 september this is already implemented in myfaces (see
MYFACES-565 http://issues.apache.org/jira/browse/MYFACES-565).

Best regards,

Bruno

2005/9/27, Richard Wallace [EMAIL PROTECTED]:
  

Hey all,

I was just trying to get a Hibernate mapped collection, a Set, displayed
on a page with a t:dataList component.  Much to my chagrin I started to
get exceptions like javax.servlet.ServletException: ServletException in
'/admin/departmentType/list.jsp': javax/servlet/jsp/jstl/sql/Result
which I thought was really odd since I don't use any such beast in my
app, it's all Hibernate based.

I thought that maybe something was wrong with my collection mapping so
tried just doing a h:outputText value=#{myPojo.myMappedCollection} /
and it displayed the correct data.  So I did some digging in the
tomahawk docs and it says for supported types see JSF Spec 4.1.3.  Of
course, that is a spec doesn't include sets, only Lists and ResultSets.
So I can only guess myfaces tried to map the collection to a ResultSet
and failed and so gave the not so informative message.

Looking on the list for dataTable and Hibernate messages to see how
people had coped with this I found that the t:dataTable component can
create DataModels directly from Sets.  So, what I'm wondering is why
doesn't the t:dataList support this?

That would make life so much simpler for me and probably others using
Hibernate like this.  Thoughts?

Thanks,
Rich






Re: t:updateActionListener help

2005-09-21 Thread Richard Wallace
Let this be a reminder to us all not to try and fix problems late at 
night after having worked and being really exhausted.  The problem was 
that I didn't define the tomahawk taglib on the listing page.  I'm not 
sure why using the t:updateActionListener tag didn't cause a JSP 
exception when no namespace with the t prefix was defined, but adding 
the taglib def to the page fixed the problem and all works as it should.


Rich

Richard Wallace wrote:

Hello all,

I'm trying to get t:updateActionListener working but am having some 
problems.  I've got the following table on one page:


h:dataTable value=#{institutionHandler.institutionsModel} 
var=institution styleClass=tableReport rowClasses=row,altrow

   h:column
   f:facet name=header
   h:outputText value=#{labels.institutionNameLabel} /
   /f:facet
   h:outputText value=#{institution.name} /
   /h:column
   h:column
   f:facet name=header
   h:outputText value=#{labels.viewLabel} /
   /f:facet
   h:commandLink action=viewInstitution immediate=true
   h:outputText value=#{labels.viewLabel} /
   t:updateActionListener 
property=#{institutionHandler.currentInstitutionId} 
value=#{institution.id} /

   /h:commandLink
   /h:column
/h:dataTable

When the InstitutionHandler.setCurrentInstitutionId() method is called 
the institution is loaded from the Hibernate backend.  The view page 
that it goes to just displays the institution information in 
non-editable form with a link to allow the user to edit it.


In theory everything should be working well, as far as I understand.  
The strange thing is that when the view page is loaded no institution 
has been loaded because the institution id hasn't been properly set.  
I did some logging and the 
InstititionHandler.setCurrentInstitutionId() method is only ever 
called on the listing page.  On the view page the 
InstititionHandler.setCurrentInstitutionId() method is never called, 
only the InstititionHandler.getCurrentInstitutionId() method is called.


Is there something I'm missing here?

Thanks,
Rich




t:updateActionListener help

2005-09-20 Thread Richard Wallace

Hello all,

I'm trying to get t:updateActionListener working but am having some 
problems.  I've got the following table on one page:


h:dataTable value=#{institutionHandler.institutionsModel} 
var=institution styleClass=tableReport rowClasses=row,altrow

   h:column
   f:facet name=header
   h:outputText value=#{labels.institutionNameLabel} /
   /f:facet
   h:outputText value=#{institution.name} /
   /h:column
   h:column
   f:facet name=header
   h:outputText value=#{labels.viewLabel} /
   /f:facet
   h:commandLink action=viewInstitution immediate=true
   h:outputText value=#{labels.viewLabel} /
   t:updateActionListener 
property=#{institutionHandler.currentInstitutionId} 
value=#{institution.id} /

   /h:commandLink
   /h:column
/h:dataTable

When the InstitutionHandler.setCurrentInstitutionId() method is called 
the institution is loaded from the Hibernate backend.  The view page 
that it goes to just displays the institution information in 
non-editable form with a link to allow the user to edit it.


In theory everything should be working well, as far as I understand.  
The strange thing is that when the view page is loaded no institution 
has been loaded because the institution id hasn't been properly set.  I 
did some logging and the InstititionHandler.setCurrentInstitutionId() 
method is only ever called on the listing page.  On the view page the 
InstititionHandler.setCurrentInstitutionId() method is never called, 
only the InstititionHandler.getCurrentInstitutionId() method is called.


Is there something I'm missing here?

Thanks,
Rich


Re: Best way to use object properties from a List to create Select Items?

2005-09-09 Thread Richard Wallace
This is something I've been fighting with too.  I've just been doing the 
backingBean.getDomainObjectAsSelectItems() kind of method that returns 
either a SelectItem[] or a List.  The biggest thing I don't like about 
that is that the iteration over the collection is done twice, once to 
convert the domain objects into select items and then again to display 
the select items.  It's probably not too big a deal because using a 
select or radio buttons or whatever wouldn't be a good idea for too 
long a list of domain objects, but it's one area that should be more 
optimized.


I looked at using either the TransformedList or the LazyList from 
Commons Collections, but neither seems to do what I want.  
TransformedList only transforms things as they are added to the list not 
as they are gotten.  LazyList doesn't provide anyway to parameterize the 
creation of the elements as they are accessed.  Does anyone know of 
another package out there that provides for transforming elements in a 
List as they are accessed?


I wouldn't think it would be too tough to implement.  You're basically 
wrapping a List with another that has custom get() and iterator() 
methods.  You'd probably want to have something like a caching list that 
would cache modifications.  If sometihng is not in that list you check 
the wrapped list and do the transform and put it in the cache and return 
it.  The hardest part is the iterator(), I'm not at all sure what that 
would look like.  I guess it would basically wrap the two iterators from 
the wrapped list and the cache list.  When a i.next() is called check if 
the cached list iterator has a next, if not check the wrapped list 
iterator and if it has a next then get it, transform it, add it to the 
cached list and return it.  I'm pretty sure you can do this with a list, 
but I'm not sure about other collection types (like Sets, which is what 
Hibernate likes to use so much).  Also, you'd probably want to require 
that the wrapped list be unmodifiable.


Anyways, just some thoughts that I've been kicking around about 
converting collections of domain objects into a list or array of 
SelectItems.


Rich

Martin Marinschek wrote:


I think this is indeed a great idea, Rick!

if you want to provide a new tag, extend from the existing SelectItems
tag - it should be quite easy to get up to speed with this component.

regards,

Martin

On 9/8/05, Rick Reumann [EMAIL PROTECTED] wrote:
 


On 9/8/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote:
   


However, as you say, there's always room for
improvement.
 


Yup. And I understand JSF/MyFaces is still relatively young.

I do think a tag to support this would be nice.

As an interim solution I'll probably create a method that returns a
SelectItems array...

SelectItems[] createSelectItemsFromCollection( Collection col, String
valueProp, String labelProp ) {

then using the reflection API, I should be able to return an array of
SelectItems. This method could then be used for *any* Collection
within the application.

   




 





Re: JSF + Spring + Hibernate

2005-09-01 Thread Richard Wallace

Joshua Davis wrote:


Transfer Object is a design pattern frequently used with EJB:
http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html
.
Your managed beans could copy the Hibernate-mapped objects (I call them
Persistent Domain Objects) into simple POJOs that aren't mapped.  Leave
these in the session, stick them in a cache, store them in base64 encoded
hidden input fields, or whatever.

 

I guess I'm just not seeing the reason to use this with Hibernate.  I 
mean the whole point of Hibernate is to be able to persist you're POJO 
and use them wherever you see fit and not have to worry about all the 
complications that arise from EJBs.  That's the ideal at least.  The 
reality is that you do have to worry about the Hibernate session and 
loading objects and performing opertations within a session, but I'm 
having a hard time buying into the idea of using transfer objects with 
Hibernate. 

That's the 
first time I've ever heard anyone mention that.  The problem 
with telling Hibernate to initialize the object graph is 
that, in most cases I think, the use of Hibernate is 
abstracted away from the webapp layer.  So your backing beans 
don't really know they need to do that and even if they did 
they couldn't.
   



The DAO should do it.  The backing beans (business session pattern) can ask
the DAO to do it in an abstract way.

 

I'm guessing you're referring to something like having a secondary 
parameter so it looks something like myDao.get (oid, lazyLoad) or 
something like that.  To me that's still bad because you need to know 
something about the way objects are stored at a very high level.  In 
reality, the backing beans probably don't even access the DAOs directly, 
but do it via some middle tier service object.


And setting the lazy attribute to false is a 
workaround, but could lead to large graphs being loaded into 
many users HTTP sessions.  
   



This works for simple graphs only.  For complex graphs, your DAO (which is
the only thing in your system that should import Hibernate) can pick and
chose which objects to initialize.   What this is doing is essentially
turning your PDOs into Transfer Objects.

 

The problem with have the DAOs pick and choose which objects to 
initialize is that it assumes knowledge of the context in which they 
will be used.  I mean, how can you know apriori what you need to 
initialize in a get(oid) method?  You have no idea where it will be used. 

Reassociating the object with the session has a similar 
problem as trying to initialize the object from within the 
webapp layer before putting it in the session.  Your webapp 
simply does not know that you are using Hibernate.  And even 
if it did, it has no access to the actual Hibernate session.
I toyed around at one time with the idea of trying to create 
a servlet filter that would automatically reassociate 
anything in the HTTP session with the Hibernate session.  
There are a couple of problems with that tho.  First off, 
it's not always easy to determine what objects are Hibernate 
persisted objects and which aren't.  Second, if the actual 
Hibernate object is wrapped in a backing bean that is 
actually put in the HTTP session simply scanning objects in 
the HTTP session won't work.  Finally, what convinced me it 
was a bad idea is that the only ways to reassociate an object 
with a Hibernate session that I was able to find is to use 
merge(), update(), or lock().  The first two will update the 
database with the object you provide, and locking requires 
the underlying data in the db hasn't changed.  So you'd lose 
any changes that could have occured while the object was in 
the session.
   



Yikes! That sounds complicated.  ;)
The only reason you would want to reassociate the objects is if you want to
update them.  If you are just using the session as a cache, then these
objects should not be mapped.   That will cause all kinds of headaches.

 

But there is at least one situation I can think of where it makes sense 
and that is a users profile.  The situation that I was running into was 
that a users profile had the standard contact information, but then had 
links to other domain objects the user was responsible for.  What I 
would up having to do is separate all that out from the user profile and 
create a separate myDao.get(curerntUser) kind of thing, which is what I 
was getting at before.  Maybe this is the right way to do it, but it 
also seems to kind of make sense to be able to simply say 
currentUser.getMyStuff(), you know what I mean?


So, like I said, just refetching the Hibernate objects for 
each request is much easier and doesn't cause too much extra 
load on the database if your using the 2nd level cache.
   



Bingo!  You've got it there.  To me, it makes sense to use Transfer Objects,
or at least make the integration layer (where the DAOs live) able to provide
initialized sub-graphs - mapped objects turned into Transfer Objects.
Which brings me back to JSF...  

Re: Bypassing validation while still preserving values

2005-08-25 Thread Richard Wallace

Enrique Medina wrote:


Hi Richard,

I've been reading your post, but I think I'm missing something...

If you set immediate=false, then only two phases will be executed:

1) Restore view
2) Apply request values

so, as you correctly say, the model will not be updated, as the 
Update Model phase is not invoked.


But AFAIK one thing is the component and another is the model. I mean, 
the component must be always updated independently of the value for 
the immediate attribute, so I don't understand why you loose your 
component values between requests (maybe it's just a matter of scope, 
and not really the immediate attribute).


You are correct.  In this situation, when the user clicks the command 
link they are forwarded to a different page so they can do a quick add 
on the drop-down and then send them back to the main page with the 
information from before they clicked the link repopulated in the form.  
That's why I need the model updated is because then on the form that 
gets redirected to I can easily have x:saveState elements for each of 
the model values I want to save while the user goes to a different 
page.  Then when they go back to the main page the saved values get put 
back in the model and the page looks just like when they left it except 
that now there's a new item in the drop-down.


Rich


Just my 2 cents ;-)

2005/8/24, Richard Wallace [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]:


James Reynolds wrote:

Ooo! I know this one!

I lean heavily on the Core JSF book by Geary  Horstmann, there
is some
good info on this in the page life cycle in Chapter
7.  Specifically,
the Immediate Components information on page 292.  As you
mentioned, the
immediate attribute must be set to true for your components.  The
portion I tripped up on was adding context.renderResponse ();
at the
end of my ValueChangeEvent code for the
valueChangeListener.  Then, the
model maintained the previous state of my page without firing
validation.



The problem with that is that then the model doesn't get updated when
the command link is clicked so on the page they get directed to can't
preserve the model info cause it was never updated.  The situation I
have in mind is something like:

The user loads the page.  They enter some contact info.  They
click on
one of the command links.  The contact info shouldn't be validated but
the model values should be udpated.  If you look at the lifecycle the
validation occurs before updating the model values.  And immediate
event
handling gets handled before validation.  So, if I set the immediate
attribute to true it will forward to the quick add page before
validating the data or updating the model.  So t:saveState will be
preserving old information, not the latest info the user entered.

JR

-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 24, 2005 10:14 AM
To: MyFaces Discussion
Subject: Bypassing validation while still preserving values

Hey everyone,

I've got a form that has a couple of optional command links on
it.  They
are basically quick add buttons so a user can quickly add things to
drop downs if they aren't there.  When these quick add buttons are
clicked the user is sent to an add page, the user enters the new
info
and is then redirected back to the original page where the new
entry is
selected and all the other data is preserved from before they clicked
the quick add button.  The backing beans involved are request
scoped
and the values filled in before clicking the quick add button are
preserved through the process using the t:saveState element.

I'm trying to get the validation correct. I want all the form
elements
to be required when the user clicks the submit button, but when
they hit

the quick add link the validation should be bypassed.   I
thought of
doing this with the immediate attribute set to true on the quick
add
command links but if I do that then any data the user entered on that
page load (contact info type stuff) is lost.  So I kind of need to
bypass the validation but still update the model values if one of
the
command links are clicked, but have full validation done when the
command button is pressed.

I was looking at the new OptionalValidation Framework but I'm not
sure
exactly how to apply it in this case.  I mean, what I really want
is to
have the validation type be none when command links are used and hard
otherwise.

Any ideas?

Thanks,
Rich









Re: Bypassing validation while still preserving values

2005-08-25 Thread Richard Wallace

Mike Kienenberger wrote:


Sorry, I've been on vacation the last week.

The default for the Optional Validation Framework is hard, so it's
just a matter of setting validation to none for your command links,
and wrapping all of your validators/converters.

Note that if validation is set to none, your model isn't going to be
updated.  You'll  need to pull out any values with
getSubmittedValue().

Note that you can't have it both ways -- if you're not validating
data, then you can't update the model since the data may not be valid.
 You really want to be preserving your submitted values, not your
model values.
 

Ok, that's reasonable.  How can I preserve the submitted values instead 
of trying to get the model values updated so I can preserve them?


Thanks,
Rich


-Mike

On 8/24/05, Richard Wallace [EMAIL PROTECTED] wrote:
 


Hey everyone,

I've got a form that has a couple of optional command links on it.  They
are basically quick add buttons so a user can quickly add things to
drop downs if they aren't there.  When these quick add buttons are
clicked the user is sent to an add page, the user enters the new info
and is then redirected back to the original page where the new entry is
selected and all the other data is preserved from before they clicked
the quick add button.  The backing beans involved are request scoped
and the values filled in before clicking the quick add button are
preserved through the process using the t:saveState element.

I'm trying to get the validation correct. I want all the form elements
to be required when the user clicks the submit button, but when they hit
the quick add link the validation should be bypassed.   I thought of
doing this with the immediate attribute set to true on the quick add
command links but if I do that then any data the user entered on that
page load (contact info type stuff) is lost.  So I kind of need to
bypass the validation but still update the model values if one of the
command links are clicked, but have full validation done when the
command button is pressed.

I was looking at the new OptionalValidation Framework but I'm not sure
exactly how to apply it in this case.  I mean, what I really want is to
have the validation type be none when command links are used and hard
otherwise.

Any ideas?

Thanks,
Rich

   





Bypassing validation while still preserving values

2005-08-24 Thread Richard Wallace

Hey everyone,

I've got a form that has a couple of optional command links on it.  They 
are basically quick add buttons so a user can quickly add things to 
drop downs if they aren't there.  When these quick add buttons are 
clicked the user is sent to an add page, the user enters the new info 
and is then redirected back to the original page where the new entry is 
selected and all the other data is preserved from before they clicked 
the quick add button.  The backing beans involved are request scoped 
and the values filled in before clicking the quick add button are 
preserved through the process using the t:saveState element. 

I'm trying to get the validation correct. I want all the form elements 
to be required when the user clicks the submit button, but when they hit 
the quick add link the validation should be bypassed.   I thought of 
doing this with the immediate attribute set to true on the quick add 
command links but if I do that then any data the user entered on that 
page load (contact info type stuff) is lost.  So I kind of need to 
bypass the validation but still update the model values if one of the 
command links are clicked, but have full validation done when the 
command button is pressed.


I was looking at the new OptionalValidation Framework but I'm not sure 
exactly how to apply it in this case.  I mean, what I really want is to 
have the validation type be none when command links are used and hard 
otherwise.


Any ideas?

Thanks,
Rich


Re: Bypassing validation while still preserving values

2005-08-24 Thread Richard Wallace
Like I said, I tried that.  The problem with that is that the model 
values don't get updated and so can't be preserved with the 
t:saveState component.


Sean Schofield wrote:


Use immediate=true on your command links.

sean

On 8/24/05, Richard Wallace [EMAIL PROTECTED] wrote:
 


Hey everyone,

I've got a form that has a couple of optional command links on it.  They
are basically quick add buttons so a user can quickly add things to
drop downs if they aren't there.  When these quick add buttons are
clicked the user is sent to an add page, the user enters the new info
and is then redirected back to the original page where the new entry is
selected and all the other data is preserved from before they clicked
the quick add button.  The backing beans involved are request scoped
and the values filled in before clicking the quick add button are
preserved through the process using the t:saveState element.

I'm trying to get the validation correct. I want all the form elements
to be required when the user clicks the submit button, but when they hit
the quick add link the validation should be bypassed.   I thought of
doing this with the immediate attribute set to true on the quick add
command links but if I do that then any data the user entered on that
page load (contact info type stuff) is lost.  So I kind of need to
bypass the validation but still update the model values if one of the
command links are clicked, but have full validation done when the
command button is pressed.

I was looking at the new OptionalValidation Framework but I'm not sure
exactly how to apply it in this case.  I mean, what I really want is to
have the validation type be none when command links are used and hard
otherwise.

Any ideas?

Thanks,
Rich

   





Re: Bypassing validation while still preserving values

2005-08-24 Thread Richard Wallace

James Reynolds wrote:


Ooo! I know this one!

I lean heavily on the Core JSF book by Geary  Horstmann, there is some
good info on this in the page life cycle in Chapter 7.  Specifically,
the Immediate Components information on page 292.  As you mentioned, the
immediate attribute must be set to true for your components.  The
portion I tripped up on was adding context.renderResponse(); at the
end of my ValueChangeEvent code for the valueChangeListener.  Then, the
model maintained the previous state of my page without firing
validation.

 

The problem with that is that then the model doesn't get updated when 
the command link is clicked so on the page they get directed to can't 
preserve the model info cause it was never updated.  The situation I 
have in mind is something like:


The user loads the page.  They enter some contact info.  They click on 
one of the command links.  The contact info shouldn't be validated but 
the model values should be udpated.  If you look at the lifecycle the 
validation occurs before updating the model values.  And immediate event 
handling gets handled before validation.  So, if I set the immediate 
attribute to true it will forward to the quick add page before 
validating the data or updating the model.  So t:saveState will be 
preserving old information, not the latest info the user entered.



JR

-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 24, 2005 10:14 AM

To: MyFaces Discussion
Subject: Bypassing validation while still preserving values

Hey everyone,

I've got a form that has a couple of optional command links on it.  They
are basically quick add buttons so a user can quickly add things to
drop downs if they aren't there.  When these quick add buttons are
clicked the user is sent to an add page, the user enters the new info
and is then redirected back to the original page where the new entry is
selected and all the other data is preserved from before they clicked
the quick add button.  The backing beans involved are request scoped
and the values filled in before clicking the quick add button are
preserved through the process using the t:saveState element. 


I'm trying to get the validation correct. I want all the form elements
to be required when the user clicks the submit button, but when they hit

the quick add link the validation should be bypassed.   I thought of 
doing this with the immediate attribute set to true on the quick add 
command links but if I do that then any data the user entered on that

page load (contact info type stuff) is lost.  So I kind of need to
bypass the validation but still update the model values if one of the
command links are clicked, but have full validation done when the
command button is pressed.

I was looking at the new OptionalValidation Framework but I'm not sure
exactly how to apply it in this case.  I mean, what I really want is to
have the validation type be none when command links are used and hard
otherwise.

Any ideas?

Thanks,
Rich

 





outputFormat and links

2005-08-15 Thread Richard Wallace

Hello,

I would like to do something like the following:

   h:outputFormat value=To view your report click {0}.
   f:paramh:outputLink 
value=report.jsfh:outputText value=here //h:outputLink/f:param

   /h:outputFormat

But this is not valid according to the tld so I tried without wrapping 
the h:outputLink in the f:param tags and got this as the output:


   a id=_id12 href=report.jsf here /a

To view your report click {0}.  


Any ideas on how I can do this?

Thanks,
Rich


outputFormat and links

2005-08-15 Thread Richard Wallace

Hello,

I would like to do something like the following:

   h:outputFormat value=To view your report click {0}.
   f:paramh:outputLink 
value=report.jsfh:outputText value=here //h:outputLink/f:param

   /h:outputFormat

But this is not valid according to the tld so I tried without wrapping 
the h:outputLink in the f:param tags and got this as the output:


   a id=_id12 href=report.jsf here /a

To view your report click {0}.  


Any ideas on how I can do this?

Thanks,
Rich


Re: Post login redirection

2005-08-14 Thread Richard Wallace

Just realized I forgot to attach the diff.  Sorry, it was late =P

Rich

Richard Wallace wrote:


Hello,

I'm still having issues with the ExternalContext.redirect() method and 
I'm wondering if anyone has a workaround.  The issue comes up when I'm 
trying to redirect a user to a page they requested before logging in.  
A simple externalContext.redirect() should work but I wind up with 
this exception.


java.lang.IllegalStateException
   at 
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:352) 

   at 
org.apache.myfaces.context.servlet.ServletExternalContextImpl.redirect(ServletExternalContextImpl.java:489) 

   at 
org.apache.myfaces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:148) 

   at 
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:85) 


   at javax.faces.component.UICommand.broadcast(UICommand.java:106)
   at 
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:87)
   at 
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:161)
   at 
org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:270) 

   at 
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)

   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
   at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237) 

   at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) 



This means that in spite of the ExternalContext.redirect() method 
being called, which is supposed to call 
FacesContext.responseComplete(), the navigation rules are still being 
processed and trying to redirect the user for a second time in the 
same request.  This causes Tomcat to throw the IllegalStateException.


After looking through the code for ExternalContext, it's clear that 
it's not calling FacesContext.responseComplete().  I tried adding that 
after my call to ExternalContext.redirect() and got the same result.  
So, it seems that the NavigationHandler is ignoring the 
FacesContext.responseComplete().


I've taken a closer look at the source and it seems that the problem 
could be solved by wrapping lines 83-88 in 
impl/src/java/org/apache/myfaces/application/ActionListenerImpl.java 
in an if statement that checks the FacesContext.getResponseComplete() 
return value.  I've attached a diff that does just that.  Hopefully 
this is acceptable cause this is something that I'd really like to 
mark as done on my todo list =P


Thanks,
Rich



Index: src/java/org/apache/myfaces/application/ActionListenerImpl.java
===
--- src/java/org/apache/myfaces/application/ActionListenerImpl.java 
(revision 232576)
+++ src/java/org/apache/myfaces/application/ActionListenerImpl.java 
(working copy)
@@ -80,12 +80,14 @@
 }
 }
 
-NavigationHandler navigationHandler = 
application.getNavigationHandler();
-navigationHandler.handleNavigation(facesContext,
-   fromAction,
-   outcome);
-   //Render Response if needed
-   facesContext.renderResponse();
-
+if (facesContext.getResponseComplete()) 
+{
+NavigationHandler navigationHandler = 
application.getNavigationHandler();
+navigationHandler.handleNavigation(facesContext,
+   fromAction,
+   outcome);
+//Render Response if needed
+facesContext.renderResponse();
+}
 }
 }


Re: Changes over the last 3 months?

2005-08-11 Thread Richard Wallace
Many of the attributes that used to work on images don't anymore.  This 
is for better compliance with the JSF tag lib spec.  I had similar 
problems when I upgraded to a nightly snapshot.  The attributes used to 
work but shouldn't have.  The simple solution (and I believe the correct 
one) is to move them to a style class.


Rich

Neal Haggard wrote:



We've been using the 1.0.9 myfaces jar untouched since around May.  I pulled 
the nightly build last night and am getting a bunch of errors with 
h:graphicImage, things that were previously working fine.

h:graphicImage url=/images/logo.gif border=0 width=62 height=24 hspace=2 
vspace=2 alt=Our Logo /

First it was complaining that getHSpace() wasn't found on the GraphicImage 
component.  So I pulled the hspace and vspace attributes, figuring they weren't 
that big of a deal.

Next it says:

Attribute border invalid for tag graphicImage according to TLD

Since when is border invalid for images?  Am I missing something?  It appears 
that HtmlGraphicImageTag still has a setBorder() method.  Is it possible 
someone accidentally deleted the border attribute on the image TLD?

--
Neal Haggard
Senior Systems Developer
Knowledge Management Center
SAS Instititute
 





Tracking down duplicate ids

2005-08-08 Thread Richard Wallace

Hey everybody,

Got a nasty little problem that I'm not sure what the best way to go 
about solving it is.  I've got a page with a couple of dataTables and a 
couple of forms on it.  One form and dataTable is for one type of object 
and the other form and dataTable are for another type of object.  The 
forms are for adding new instances.


The problem I'm running into is that after adding an instance of either 
type I get these exceptions:


javax.faces.FacesException: cannot add component with id '_id55' and 
path : {Component-Path : [Class: 
javax.faces.component.html.HtmlOutputText,Id: _id55]} to its parent 
component. This might be a problem due to duplicate ids.


On most of the elements I'm just letting myfaces generate the ids, so 
I'm not sure how this is happening.  If I just goto the url directly 
after doing the add it works fine and the new entries are shown.


What's the best way to track down what is actually causing this?  Should 
I just start giving ids to all my jsf elements or what?


Thanks,
Rich


Re: Tracking down duplicate ids

2005-08-08 Thread Richard Wallace
Ok, a bit of an update.  The issue only comes up when I have both of the 
tables on the same page.  If I comment one out with %-- % tags then 
everything works fine when adding.  I can comment out either one so it's 
not a problem specific to just one of the tables, it's something about 
having them both that is causing the problem.


Any ideas?

Thanks again,
Rich

Balaji Saranathan wrote:

I'm not sure about the problem at your hand, 
But I have found it extremely helpful and clean in assigning the IDs

myself to all the components in a page. It helps in debugging too.

-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 08, 2005 2:58 PM

To: MyFaces Discussion
Subject: Tracking down duplicate ids


Hey everybody,

Got a nasty little problem that I'm not sure what the best way to go 
about solving it is.  I've got a page with a couple of dataTables and a 
couple of forms on it.  One form and dataTable is for one type of object


and the other form and dataTable are for another type of object.  The 
forms are for adding new instances.


The problem I'm running into is that after adding an instance of either 
type I get these exceptions:


javax.faces.FacesException: cannot add component with id '_id55' and 
path : {Component-Path : [Class: 
javax.faces.component.html.HtmlOutputText,Id: _id55]} to its parent 
component. This might be a problem due to duplicate ids.


On most of the elements I'm just letting myfaces generate the ids, so 
I'm not sure how this is happening.  If I just goto the url directly 
after doing the add it works fine and the new entries are shown.


What's the best way to track down what is actually causing this?  Should

I just start giving ids to all my jsf elements or what?

Thanks,
Rich




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.
 





Re: Tracking down duplicate ids

2005-08-08 Thread Richard Wallace
After putting ids on all the elements in the tables (including 
h:column, h:outputText and h:outputLink elements) the problem 
seems to have gone away.


I think the element it was choking on was a link that was outside any 
forms.  So only parent it would have had was the f:view element.  That 
should be okay right? JSF elements don't all have to be within h:form 
elements do they?


Rich

Martin Marinschek wrote:


The thing with the duplicate id's is only one possible reason.

you should look at the component path that is indicated - according to 
that, your component would need to be a top-level object - it does not 
have any parent object at all?


regards,

Martin

On 8/8/05, *Richard Wallace* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Ok, a bit of an update.  The issue only comes up when I have both
of the
tables on the same page.  If I comment one out with %-- % tags then
everything works fine when adding.  I can comment out either one
so it's
not a problem specific to just one of the tables, it's something about
having them both that is causing the problem.

Any ideas?

Thanks again,
Rich

Balaji Saranathan wrote:

I'm not sure about the problem at your hand,
But I have found it extremely helpful and clean in assigning the IDs
myself to all the components in a page. It helps in debugging too.

-Original Message-
From: Richard Wallace [mailto: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]]
Sent: Monday, August 08, 2005 2:58 PM
To: MyFaces Discussion
Subject: Tracking down duplicate ids


Hey everybody,

Got a nasty little problem that I'm not sure what the best way to go
about solving it is.  I've got a page with a couple of dataTables
and a
couple of forms on it.  One form and dataTable is for one type of
object

and the other form and dataTable are for another type of object.  The
forms are for adding new instances.

The problem I'm running into is that after adding an instance of
either
type I get these exceptions:

javax.faces.FacesException: cannot add component with id '_id55' and
path : {Component-Path : [Class:
javax.faces.component.html.HtmlOutputText,Id: _id55]} to its parent
component. This might be a problem due to duplicate ids.

On most of the elements I'm just letting myfaces generate the ids, so
I'm not sure how this is happening.  If I just goto the url directly
after doing the add it works fine and the new entries are shown.

What's the best way to track down what is actually causing
this?  Should

I just start giving ids to all my jsf elements or what?

Thanks,
Rich




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] mailto:[EMAIL PROTECTED] immediately
and destroy all copies of this message and any attachments.








Re: Automatically retrying failed transactions

2005-08-08 Thread Richard Wallace
I think the point that he was trying to make was that this isn't 
something that JSF is meant to handle.  The way I would handle something 
like this is to have my backing bean get a reference to some business 
logic object (living in Spring or some other container in the same JVM 
or on another machine) and have the business logic object make the 
multiple attempts to perform the transaction. 

To me, JSF is purely meant to create interfaces for the user.  Any 
business logic should reside in a separate component layer.


Just my 2 cents,
Rich

[EMAIL PROTECTED] wrote:



Just to be clear this is *not *a jdbc/orm issue. I can retry a request 
if I'm not using jsf. For example, I have an xml servlet layer which 
works fine with a filter that retries. Furthermore, there could be 
cases where a non-database issue requires a retry (maybe a network 
issue with a remote resource).


Does anyone have any ideas how to retry a request in jsf?



[EMAIL PROTECTED]

08/08/2005 01:58 PM
Please respond to
MyFaces Discussion users@myfaces.apache.org



To
MyFaces Discussion users@myfaces.apache.org
cc

Subject
Re: Automatically retrying failed transactions










This is more of a JDBC/ORM issue.  

You need a fishing pole to get the fish to your boat, you need a 
skillet to get the fish to the dinner table.  There are tools to catch 
and cook the fish, but not in Java land ;)


Dennis Byrne





Re: Tracking down duplicate ids

2005-08-08 Thread Richard Wallace
Nope, I don't do anything with component bindings.  Pretty simple stuff 
really.  I'll try and track down the problem later when I have a little 
more time cause I don't really want to have to put id's on every single 
JSF element on my pages =P


I'll let you all know what I find.

Rich

Martin Marinschek wrote:


Sorry,

I misunderstood the message - of course your component does not have a 
parent if it can't be added ;)


do you do anything with component bindings? I have had problems with 
that and exactly this error-message, as far as I remember...


If not, try to track it down to exactly one component by taking out 
other stuff from the datatable.


regards,

Martin

On 8/8/05, *Balaji Saranathan* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



One more case to convince myself not to depend on auto-generated ids.
Not necessary that they should be within the form.
Was it a h:commandLink ?. CommandLink I know generates a form and
does a
submit on the click.

-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]]
Sent: Monday, August 08, 2005 5:08 PM
To: MyFaces Discussion
Subject: Re: Tracking down duplicate ids


After putting ids on all the elements in the tables (including
h:column, h:outputText and h:outputLink elements) the problem
seems to have gone away.

I think the element it was choking on was a link that was outside any
forms.  So only parent it would have had was the f:view
element.  That

should be okay right? JSF elements don't all have to be within
h:form
elements do they?

Rich

Martin Marinschek wrote:

 The thing with the duplicate id's is only one possible reason.

 you should look at the component path that is indicated -
according to
 that, your component would need to be a top-level object - it
does not

 have any parent object at all?

 regards,

 Martin

 On 8/8/05, *Richard Wallace* [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:

 Ok, a bit of an update.  The issue only comes up when I have
both
 of the
 tables on the same page.  If I comment one out with %-- %
tags
then
 everything works fine when adding.  I can comment out either one
 so it's
 not a problem specific to just one of the tables, it's something
about
 having them both that is causing the problem.

 Any ideas?

 Thanks again,
 Rich

 Balaji Saranathan wrote:

 I'm not sure about the problem at your hand,
 But I have found it extremely helpful and clean in
assigning the
IDs
 myself to all the components in a page. It helps in debugging
too.
 
 -Original Message-
 From: Richard Wallace [mailto: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]]
 Sent: Monday, August 08, 2005 2:58 PM
 To: MyFaces Discussion
 Subject: Tracking down duplicate ids
 
 
 Hey everybody,
 
 Got a nasty little problem that I'm not sure what the best
way to
go
 about solving it is.  I've got a page with a couple of
dataTables
 and a
 couple of forms on it.  One form and dataTable is for one
type of
 object
 
 and the other form and dataTable are for another type of
object.
The
 forms are for adding new instances.
 
 The problem I'm running into is that after adding an
instance of
 either
 type I get these exceptions:
 
 javax.faces.FacesException: cannot add component with id
'_id55'
and
 path : {Component-Path : [Class:
 javax.faces.component.html.HtmlOutputText,Id: _id55]} to its
parent
 component. This might be a problem due to duplicate ids.
 
 On most of the elements I'm just letting myfaces generate the
ids, so
 I'm not sure how this is happening.  If I just goto the url
directly
 after doing the add it works fine and the new entries are
shown.
 
 What's the best way to track down what is actually causing
 this?  Should
 
 I just start giving ids to all my jsf elements or what?
 
 Thanks,
 Rich
 
 
 
 
 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

Re: Tracking down duplicate ids

2005-08-08 Thread Richard Wallace
No, it's not a h:commandLink.  I think the problem occurred on a 
h:outputText element actually.  Which is why I can't track it down now 
cause there are lots of those on the page =P


Rich

John Fallows wrote:


Hey Martin,

Rich said that the issue was with a h:commandLink that lives outside a form.
Doesn't MyFaces add a dummy form in that case?  
Is it possible that two dummy forms are being implicitly added here,

with the same id, causing the collision?

Thinking out loud in case it might inspire you. :-)

Kind Regards,
John Fallows.

On 8/8/05, Martin Marinschek [EMAIL PROTECTED] wrote:
 


Sorry,

I misunderstood the message - of course your component does not have a
parent if it can't be added ;)

do you do anything with component bindings? I have had problems with that
and exactly this error-message, as far as I remember...

If not, try to track it down to exactly one component by taking out other
stuff from the datatable.

regards,

Martin


On 8/8/05, Balaji Saranathan [EMAIL PROTECTED] wrote:
   


One more case to convince myself not to depend on auto-generated ids.
Not necessary that they should be within the form.
Was it a h:commandLink ?. CommandLink I know generates a form and does a
submit on the click. 


-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED]
Sent: Monday, August 08, 2005 5:08 PM
To: MyFaces Discussion
Subject: Re: Tracking down duplicate ids 



After putting ids on all the elements in the tables (including
h:column, h:outputText and h:outputLink elements) the problem
seems to have gone away.

I think the element it was choking on was a link that was outside any 
forms.  So only parent it would have had was the f:view element.  That


should be okay right? JSF elements don't all have to be within h:form
elements do they?

Rich

Martin Marinschek wrote: 

 


The thing with the duplicate id's is only one possible reason.

you should look at the component path that is indicated - according to
that, your component would need to be a top-level object - it does not 
   


have any parent object at all?

regards,

Martin

On 8/8/05, *Richard Wallace* [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:

   Ok, a bit of an update.  The issue only comes up when I have both
   of the
   tables on the same page.  If I comment one out with %-- % tags 
   


then
 


   everything works fine when adding.  I can comment out either one
   so it's
   not a problem specific to just one of the tables, it's something
   


about
 

   having them both that is causing the problem. 


   Any ideas?

   Thanks again,
   Rich

   Balaji Saranathan wrote:

   I'm not sure about the problem at your hand,
   But I have found it extremely helpful and clean in assigning the 
   


IDs
 


   myself to all the components in a page. It helps in debugging
   


too.
 


   
   -Original Message-
   From: Richard Wallace [mailto: [EMAIL PROTECTED]
   mailto:[EMAIL PROTECTED]]
   Sent: Monday, August 08, 2005 2:58 PM
   To: MyFaces Discussion 
   Subject: Tracking down duplicate ids

   
   
   Hey everybody,
   
   Got a nasty little problem that I'm not sure what the best way to
   


go
 


   about solving it is.  I've got a page with a couple of dataTables
   and a
   couple of forms on it.  One form and dataTable is for one type of
   object
   
   and the other form and dataTable are for another type of object.
   


The
 


   forms are for adding new instances.
   
   The problem I'm running into is that after adding an instance of 
   either

   type I get these exceptions:
   
   javax.faces.FacesException: cannot add component with id '_id55'
   


and
 


   path : {Component-Path : [Class:
   javax.faces.component.html.HtmlOutputText,Id:
   


_id55]} to its
   


parent
 


   component. This might be a problem due to duplicate ids.
   
   On most of the elements I'm just letting myfaces generate the 
   


ids, so
 


   I'm not sure how this is happening.  If I just goto the url
   


directly
 


   after doing the add it works fine and the new entries are shown.
   
   What's the best way to track down what is actually causing 
   this?  Should

   
   I just start giving ids to all my jsf elements or what?
   
   Thanks,
   Rich
   
   

   

   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] mailto: [EMAIL PROTECTED]
   


immediately
 


   and destroy all copies of this message and any attachments.
   
   


   




Confidentiality Notice

The information contained in this electronic message and any attachments
 


to this message are intended

Re: Messages and navigation rule redirects post

2005-08-05 Thread Richard Wallace
Yes, I'm still here but I'm in a different timezone than all of you.  So 
all this was going on at 3am my time and I was getting some much needed 
sleep =P


Anyways, this is an issue that I never quite solved either.  I kind of 
put it on the sidelines because I had other more important things to 
tackle, but I would prefer a solution that uses a PhaseListener to scan 
for global messages after rendering and put them in the session.  Then, 
have them put back into the JSF message queue in the before the first 
phase.  The biggest problem I have with this solution is getting rid of 
the messages.  Ideally, what would happen is that they are removed when 
they are displayed (I can't think of any use-cases where you'd want to 
have the global messages displayed twice on the same page).  So I'm 
thinking of creating a custom message display component some time down 
the road that dequeues messages as they are displayed.


So that's my 2 cents.

Rich

Johannes Hiemer wrote:


Hi,
good to know, that there another ways to do it. 
In my solution the problem with a PhaseListener would be, that I need to get the current instance of a BaseController, or is it possible to save values to a phaseListener, and to dispense with my BaseController completly?


Richard are you still alive? :-)  What do you think?

Regards Johannes 


MyFaces Discussion users@myfaces.apache.org schrieb am 05.08.05 11:24:28:
 


I don't know if this can helps you but there is the way to handle
messages throw redirects, the Matt Raible' way  into appFuse/JSF :


the message filter :
https://appfuse.dev.java.net/source/browse/appfuse/extras/jsf/src/web/org/appfuse/webapp/filter/MessageFilter.java?rev=1.1view=autocontent-type=text/vnd.viewcvs-markup

the BasePage with addMessage method
https://appfuse.dev.java.net/source/browse/appfuse/extras/jsf/src/web/org/appfuse/webapp/action/BasePage.java?rev=1.1view=autocontent-type=text/vnd.viewcvs-markup







2005/8/5, Martin Marinschek [EMAIL PROTECTED]:
   


-- Forwarded message --
From: Martin Marinschek [EMAIL PROTECTED]
Date: Aug 5, 2005 11:05 AM 
Subject: Re: Messages and navigation rule redirects post

To: Johannes Hiemer [EMAIL PROTECTED]

Nice solution,

even though a bit verbose... You might want to try a phase-listener wich
you add before the render response phase and which checks for this bean and
adds the messages to the context instead of doing that in a bean as well.

regards,

Martin


On 8/5/05, Johannes Hiemer  [EMAIL PROTECTED] wrote:
 


Hi Richard, Hi Martin,
perhaps I got something. I took my time this morning and spend it trying
   


some things. In my implementation I got a standard BaseController for all my
handlers. So I thought, why should I use this BaseController to save this
message for a while. After a few minutes I got a working solution.
 


Here is my code:

# BaseController #

private static FacesMessage notification;

   /**
* @return Returns the notification. 
*/

   public FacesMessage getNotification() {
   return notification;
   }

   /**
* @param notification The notification to set.
*/
   public void setNotification(FacesMessage notification) { 
   this.notification = notification;

   }

## faces-config.xml 

managed-bean
  
   


managed-bean-nameBaseController/managed-bean-name
 

   managed-bean-class 
  
   


itecon.web.resource.BaseController
 


   /managed-bean-class
  
   


managed-bean-scopesession/managed-bean-scope
 

   /managed-bean 



This is my BaseController, now we get to the SparepartHandler.java where
   


actually the first stept happens.
 


public String add() {
   message = this.getMessage();
log.info (message);
   String notification =
   


Utils.getMessageResourceBundle(getBundle(), internalDatasetExists, null,
getLocale());
 


   setNotification(new
   


FacesMessage(FacesMessage.SEVERITY_INFO, notification, notification));
 


   return message;
   }

As you can see, I get my notification from my ResourceBundle of the
   


Application. After the I put it through BaseController.setNotification into
my private static FacesMessage notification;
 


Till here - fine.

No I have a second managed bean called: NotificationHandler.

# NotificationHandler.java ###

public class NotificationHandler extends BaseController implements
   

Serializable { 
 


   private String hiddenField = null;

   public void pageLoad() {
   log.info(getNotification());
   facescontext.addMessage(globalMessage,
   


getNotification());
 


   }

   /**
* @return Returns the hiddenField.
*/
   public String getHiddenField() {
   return 

Re: Messages and navigation rule redirects post @ myfaces mailing list

2005-08-03 Thread Richard Wallace
I'm glad to know I'm not the only one running into this.  I have yet to 
solve this.  I had hoped that just putting a 
FacesContext.getCurrentInstance().responseComplete() right after my 
externalContext.redirect() call would solve the problem.  But it looks 
like the NavigationHandler still tries to send its own redirect.  I'm 
stumped at this point.  It seems like the NavigationHandler should be 
checking to see if the responseComplete() method has been called but isn't.


Can any one help us out?

Thanks,
Rich

Johannes Hiemer wrote:


Hi,
I found your posts regarding the above mentioned topic at the mail archive of 
the myfaces mailing list. I was sitting here the whole day long, spending about 
1 hour just to get the information, that my implementation (I had the same 
thoughts you had) doesn't work, because of the design.
What I wanted to ask was, did you manage it to solve the problem?
If you did, how did you manage it?


I would be very grateful, if you could provide some information to me.

Thanks in advance.

Johannes Hiemer
__
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193

 





Re: Variable cell style classes in data table

2005-08-01 Thread Richard Wallace
Just wanted to let you know that I checked out the latest myfaces 
tomahawk, changed my app to use x:dataTable and x:column and it is 
working beautifully.  My report looks much cleaner now, thanks a ton!


Rich

Mathias Broekelmann wrote:

It took some more time but now tomahawk has a new component called 
x:column which can be used instead of h:column.


You can define dir, lang, title, style, styleclass, onclick, 
ondbclick, onmouseover, onmouseout, onmousedown, onmouseup, 
onmousemove, onkeypress, onkeydown and onkeyup for each cell, header 
and footer cells.


It will be available in the next nightly.

Regards,
Mathias

Mathias Broekelmann wrote:


I will commit it into the tomahawk sources.

Richard Wallace schrieb:

Sounds awesome!  Where will you be committing it to?  Sandbox or 
Tomahawk?


Thanks,
Rich

Broekelmann, Mathias wrote:



I´ve create a special column component which allows you to define
different styles and more for the cells.
It just needs some testing. I think I will have commited it tomorrow.

Best Regards,
Mathias





-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED] Sent:
Thursday, July 28, 2005 5:42 PM
To: MyFaces Discussion
Subject: Re: Variable cell style classes in data table


Alright, well my back is sort of up against a wall now.  I had
thought I could figure out an alternative for now but I was wrong.  I
had thought that wrapping the column data in a div and setting the
width and height to fill the cell would allow me to change the
background color on a per cell basis.  And it does, but with a big
but.  Apparently you can't use vertical alignment on block level
elements.  So, rather than the text being centered vertically and
horizontally as it needs to be, it's up at the top of the cell. 
We've tried several workarounds, none of which seem to work quite 
right.


So, I'm back to needing to set table cell style classes based on the
content of the cell.  I looked at maybe modifying the data table so
that the column classes attribute could be a list of EL statements
that get interpreted when each cell is rendered, but they are
interpreted instead when the table itself is created it looks like,
so that's out.  I'm not sure what could be the best way to do it now,
maybe create a new facet type named style or styleClass for the
column component.

This is my first bout at trying to create custom components, so I'm
not sure what that would involve, but I'm more than willing to give
it a shot if someone could maybe give me some advice.

Thanks,
Rich

Richard Wallace wrote:

 




Jesse Alexander (KBSA 21) wrote:

  

I did something similar, but I just needed to render an   




image according
 




the content of a field.

I ended up writing a Lookup-image component. Nothing complicated.

hope this helps
Alexander

PS: I'll be offline for a week!  But after august 2nd i can scetch
up a component that does this trick, if you can wait till then.


 



Sounds good.  I can probably figure something out until 



then.  Thanks  


a ton.

Rich

  


-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED] Sent:
Monday, July 25, 2005 7:52 PM
To: MyFaces Discussion
Subject: Variable cell style classes in data table

Hey everyone,

I've got a report that I'm displaying with h:dataTable.




Depending  

on the value to be displayed the background color of the   




cell should  

be a different shade.  So for low values, it'd be like a   




really light  

yellow, for high values it'd be a much darker yellow, etc.   




Any ideas  


on how I can accomplish this with MyFaces?

I had sort of hoped that something like the following would work:

h:column styleClass=#{reportHandler.styleClass}

But, as I found out, styleClass isn't a valid attribute for the
h:column element.

Any ideas?  Am I stuck rendering this sucker with plain   




old JSP and  


JSTL?

Thanks,
Rich


 




 











ExternalContext.redirect() bug

2005-08-01 Thread Richard Wallace

Hey all,

I think there's a bug in the servlet ExternalContext implementation of 
the redirect() method.  In the api comments it says


Redirect a request to the specified URL, and cause the 
|responseComplete()| method to be called on the |FacesContext| 
http://java.sun.com/j2ee/javaserverfaces/1.1_01/docs/api/javax/faces/context/FacesContext.html 
instance for the current request.


But in the servlet ExternalContext implementation of redirect() it only 
calls the HttpServletResponse.sendRedirect() method and doesn't do 
anything with responseComplete().  Should I file a JIRA issue?


Thanks,
Rich


Re: [XWALL HEURISTIC] Re: Variable cell style classes in data table

2005-07-29 Thread Richard Wallace
I'm curious tho what this actually outputs.  It seems your just setting 
the styleClass on the h:outputText element which you can do with 
h:outputText styleClass=#{datatablevar.attr} /.  The problem I have 
with that is that it uses a span to set the style class and you can't 
tell a span to take up 100% of the cell.  You can tell it to up all the 
width, but not the height.


Martin Marinschek wrote:


I found a solution deep in my magic box ;)

put a value-binding attribute on the outputTexts in your dataTable, 
just like this:


h:outputText value=#{entry.subject} 
binding=#{eventsList.specializedOutputText} /


in eventsList.specializedOutputText,

create a new Instance of SpecializedOutputText and return this.

class SpecializedOutputText should look like the following:

public class SpecializedOutputText extends HtmlOutputText
{
private static Log log = 
LogFactory.getLog(SpecializedOutputText.class);


public void encodeEnd(FacesContext context) throws IOException
{
String username = 
CalendarFactoryFinder.getGUIContextFactory().getGUIContext().getUserName();


if(username!=null)
{
UIComponent grandParent = null;

if(getParent()!=null  
(grandParent=getParent().getParent())!=null

 grandParent instanceof HtmlDataTable)
{
HtmlDataTable table = (HtmlDataTable) grandParent;
Object data = table.getRowData();

if(data instanceof CalendarEntry)
{
CalendarEntry entry = (CalendarEntry) data;

if(entry.contains(username))
{
this.setStyleClass(subject_Column_Private);
}
else
{
this.setStyleClass(subject_Column);
}
}
}
}
else
{
log.error(Could not retrieve username);
}

super.encodeEnd(context);
}
}

HTH!

regards,

Martin

On 7/29/05, [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]* 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


hi, i know this is proably not a solution if richard manages to finish
the component, but is all ropes tear you could allways do it in plain
old javaScript in an onLoad function.
it would probably be the fastest, but if you have time, i would
wait for
the component to do the work for you ;)

greetings jörg


I will commit it into the tomahawk sources.

Richard Wallace schrieb:


Sounds awesome!  Where will you be committing it to?  Sandbox or
Tomahawk?

Thanks,
Rich

Broekelmann, Mathias wrote:



I´ve create a special column component which allows you to define
different styles and more for the cells.
It just needs some testing. I think I will have commited it
tomorrow.

Best Regards,
Mathias





-Original Message-
From: Richard Wallace [mailto: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]] Sent:
Thursday, July 28, 2005 5:42 PM
To: MyFaces Discussion
Subject: Re: Variable cell style classes in data table


Alright, well my back is sort of up against a wall now.  I had
thought I could figure out an alternative for now but I was
wrong.  I
had thought that wrapping the column data in a div and setting
the
width and height to fill the cell would allow me to change the
background color on a per cell basis.  And it does, but with a big
but.  Apparently you can't use vertical alignment on block level
elements.  So, rather than the text being centered vertically and
horizontally as it needs to be, it's up at the top of the cell.
We've tried several workarounds, none of which seem to work
quite right.

So, I'm back to needing to set table cell style classes based
on the
content of the cell.  I looked at maybe modifying the data
table so
that the column classes attribute could be a list of EL
statements
that get interpreted when each cell is rendered, but they are
interpreted instead when the table itself is created it looks
like,
so that's out.  I'm not sure what could be the best way to do
it now,
maybe create a new facet type named style or styleClass
for the
column component.

This is my first bout at trying to create custom components,
so I'm
not sure what that would involve, but I'm more than willing to
give
it a shot if someone could maybe give me some advice.

Thanks,
Rich

Richard Wallace wrote:





Jesse Alexander (KBSA 21) wrote:





I did something similar, but I just needed to render an


image according




the content of a field.

I ended up

Re: [XWALL HEURISTIC] Re: Variable cell style classes in data table

2005-07-29 Thread Richard Wallace
Well, setting the display to block works for having the span take up the 
whole cell if I specify width and height, but it still has the same 
problem that you can't vertically align block level elements.  It puts 
me right back where I was when I was wrapping the cell contents in a div.


Thanks for the suggestion tho,
Rich

PS  Any status on that new column component?

Martin Marinschek wrote:


uhmm... you are right ;)

I obviously did that due to some other reason, basically cause I had 
to call a method and provide the username as a parameter, and this is 
not possible with the JSF EL.


as for the style: use display:block;

in your style description.

regards,

Martin



On 7/29/05, *Richard Wallace* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


I'm curious tho what this actually outputs.  It seems your just
setting
the styleClass on the h:outputText element which you can do with
h:outputText styleClass=#{datatablevar.attr} /.  The problem I
have
with that is that it uses a span to set the style class and you
can't
tell a span to take up 100% of the cell.  You can tell it to up
all the
width, but not the height.

Martin Marinschek wrote:

 I found a solution deep in my magic box ;)

 put a value-binding attribute on the outputTexts in your dataTable,
 just like this:

 h:outputText value=#{entry.subject}
 binding=#{eventsList.specializedOutputText} /

 in eventsList.specializedOutputText,

 create a new Instance of SpecializedOutputText and return this.

 class SpecializedOutputText should look like the following:

 public class SpecializedOutputText extends HtmlOutputText
 {
 private static Log log =
 LogFactory.getLog(SpecializedOutputText.class);

 public void encodeEnd(FacesContext context) throws IOException
 {
 String username =

CalendarFactoryFinder.getGUIContextFactory().getGUIContext().getUserName();

 if(username!=null)
 {
 UIComponent grandParent = null;

 if(getParent()!=null 
 (grandParent=getParent().getParent())!=null
  grandParent instanceof HtmlDataTable)
 {
 HtmlDataTable table = (HtmlDataTable) grandParent;
 Object data = table.getRowData();

 if(data instanceof CalendarEntry)
 {
 CalendarEntry entry = (CalendarEntry) data;

 if(entry.contains(username))
 {

this.setStyleClass(subject_Column_Private);

 }
 else
 {
 this.setStyleClass(subject_Column);
 }
 }
 }
 }
 else
 {
 log.error(Could not retrieve username);
 }

 super.encodeEnd(context);
 }
 }

 HTH!

 regards,

 Martin

 On 7/29/05, * [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]*
 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]  wrote:

 hi, i know this is proably not a solution if richard manages
to finish
 the component, but is all ropes tear you could allways do it
in plain
 old javaScript in an onLoad function.
 it would probably be the fastest, but if you have time, i would
 wait for
 the component to do the work for you ;)

 greetings jörg


 I will commit it into the tomahawk sources.
 
 Richard Wallace schrieb:
 
 
 Sounds awesome!  Where will you be committing it
to?  Sandbox or
 Tomahawk?
 
 Thanks,
 Rich
 
 Broekelmann, Mathias wrote:
 
 
 
 I´ve create a special column component which allows you
to define
 different styles and more for the cells.
 It just needs some testing. I think I will have commited it
 tomorrow.
 
 Best Regards,
 Mathias
 
 
 
 
 
 -Original Message-
 From: Richard Wallace [mailto:
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]] Sent:
 Thursday, July 28, 2005 5:42 PM
 To: MyFaces Discussion
 Subject: Re: Variable cell style classes in data table
 
 
 Alright, well my back is sort of up against a wall
now.  I had
 thought I could figure out an alternative for now but I was
 wrong.  I
 had

Re: Variable cell style classes in data table

2005-07-28 Thread Richard Wallace
Alright, well my back is sort of up against a wall now.  I had thought I 
could figure out an alternative for now but I was wrong.  I had thought 
that wrapping the column data in a div and setting the width and height 
to fill the cell would allow me to change the background color on a per 
cell basis.  And it does, but with a big but.  Apparently you can't use 
vertical alignment on block level elements.  So, rather than the text 
being centered vertically and horizontally as it needs to be, it's up at 
the top of the cell.  We've tried several workarounds, none of which 
seem to work quite right.


So, I'm back to needing to set table cell style classes based on the 
content of the cell.  I looked at maybe modifying the data table so that 
the column classes attribute could be a list of EL statements that get 
interpreted when each cell is rendered, but they are interpreted instead 
when the table itself is created it looks like, so that's out.  I'm not 
sure what could be the best way to do it now, maybe create a new facet 
type named style or styleClass for the column component.


This is my first bout at trying to create custom components, so I'm not 
sure what that would involve, but I'm more than willing to give it a 
shot if someone could maybe give me some advice.


Thanks,
Rich

Richard Wallace wrote:


Jesse Alexander (KBSA 21) wrote:


I did something similar, but I just needed to render an image according
the content of a field.

I ended up writing a Lookup-image component. Nothing complicated.

hope this helps
Alexander

PS: I'll be offline for a week!  But after august 2nd i can scetch
up a component that does this trick, if you can wait till then.
 

Sounds good.  I can probably figure something out until then.  Thanks 
a ton.


Rich


-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED] Sent: 
Monday, July 25, 2005 7:52 PM

To: MyFaces Discussion
Subject: Variable cell style classes in data table

Hey everyone,

I've got a report that I'm displaying with h:dataTable.  Depending 
on the value to be displayed the background color of the cell should 
be a different shade.  So for low values, it'd be like a really light 
yellow, for high values it'd be a much darker yellow, etc.  Any ideas 
on how I can accomplish this with MyFaces?


I had sort of hoped that something like the following would work:

h:column styleClass=#{reportHandler.styleClass}

But, as I found out, styleClass isn't a valid attribute for the 
h:column element.


Any ideas?  Am I stuck rendering this sucker with plain old JSP and 
JSTL?


Thanks,
Rich
 







Re: Variable cell style classes in data table

2005-07-28 Thread Richard Wallace

Sounds awesome!  Where will you be committing it to?  Sandbox or Tomahawk?

Thanks,
Rich

Broekelmann, Mathias wrote:


I´ve create a special column component which allows you to define different 
styles and more for the cells.
It just needs some testing. I think I will have commited it tomorrow.

Best Regards,
Mathias

 


-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 28, 2005 5:42 PM

To: MyFaces Discussion
Subject: Re: Variable cell style classes in data table


Alright, well my back is sort of up against a wall now.  I 
had thought I 
could figure out an alternative for now but I was wrong.  I 
had thought 
that wrapping the column data in a div and setting the width 
and height 
to fill the cell would allow me to change the background 
color on a per 
cell basis.  And it does, but with a big but.  Apparently you 
can't use 
vertical alignment on block level elements.  So, rather than the text 
being centered vertically and horizontally as it needs to be, 
it's up at 
the top of the cell.  We've tried several workarounds, none of which 
seem to work quite right.


So, I'm back to needing to set table cell style classes based on the 
content of the cell.  I looked at maybe modifying the data 
table so that 
the column classes attribute could be a list of EL statements 
that get 
interpreted when each cell is rendered, but they are 
interpreted instead 
when the table itself is created it looks like, so that's 
out.  I'm not 
sure what could be the best way to do it now, maybe create a 
new facet 
type named style or styleClass for the column component.


This is my first bout at trying to create custom components, 
so I'm not 
sure what that would involve, but I'm more than willing to give it a 
shot if someone could maybe give me some advice.


Thanks,
Rich

Richard Wallace wrote:

   


Jesse Alexander (KBSA 21) wrote:

 

I did something similar, but I just needed to render an 
   


image according
   


the content of a field.

I ended up writing a Lookup-image component. Nothing complicated.

hope this helps
Alexander

PS: I'll be offline for a week!  But after august 2nd i can scetch
up a component that does this trick, if you can wait till then.


   

Sounds good.  I can probably figure something out until 
 

then.  Thanks 
   


a ton.

Rich

 


-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED] Sent: 
Monday, July 25, 2005 7:52 PM

To: MyFaces Discussion
Subject: Variable cell style classes in data table

Hey everyone,

I've got a report that I'm displaying with h:dataTable.  
   

Depending 
   

on the value to be displayed the background color of the 
   

cell should 
   

be a different shade.  So for low values, it'd be like a 
   

really light 
   

yellow, for high values it'd be a much darker yellow, etc. 
   

Any ideas 
   


on how I can accomplish this with MyFaces?

I had sort of hoped that something like the following would work:

h:column styleClass=#{reportHandler.styleClass}

But, as I found out, styleClass isn't a valid attribute for the 
h:column element.


Any ideas?  Am I stuck rendering this sucker with plain 
   

old JSP and 
   


JSTL?

Thanks,
Rich


   

   





Re: Calculating image height

2005-07-26 Thread Richard Wallace

Klug, Boris wrote:


Hi!

the problem may be that a your calculation returns an int but the el statement
has to return an String. So do the calculation in your managed bean and return
the result as a String.

 

Thanks for the reply.  I had expected that the value would be coerced 
into the proper type tho, as in other EL statements.  Is this a bug or 
the right thing?  If this implementation is correct, is there anyway to 
convert the calculation to a string?  I really don't like the idea of 
having to do the calculation in the backing bean cause then my page 
designers can't easily vary the size of the image.  I could put it in 
the faces-config.xml, but that would still require them to restart their 
tomcat instance just to make a change to the page layout/display.


Right now I've got a workaround.  It's rather messy but it works.  I 
basically use the plain old img tag and do a couple of h:outputText 
in the attributes to make sure the image path contains the contextPath 
and then one to  perform and output the calculation in the height 
attribute.  Like I said, it's rather messy, but it works and allows the 
page designers to make better control over the page layout and display.


Rich


--
Boris Klug


Zitat von Richard Wallace [EMAIL PROTECTED]:

 


Hello everyone,

I'm working on a report that has a bar chart.  I thought the easiest way
to display it would be to use something like:

h:graphicImage url=/images/visual_bar_1.gif width=46
height=#{reportHandler.score * 18} border=0 /

But that horks with:

java.lang.ClassCastException
   at

   


javax.faces.component.html.HtmlGraphicImage.getHeight(HtmlGraphicImage.java:95)
 


   at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
   at

   


sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 


   at java.lang.reflect.Method.invoke(Method.java:324)
   at
javax.faces.component._ComponentAttributesMap.getComponentProperty(_C

Can I not set the height to some calculated value?

Thanks,
Rich

   



 





Re: Calculating image height

2005-07-26 Thread Richard Wallace

Here's a related question.  The line that is causing me my problems is:

   return vb != null ? (String)vb.getValue(getFacesContext()) : null;

Isn't it better to do vb.getValue(getFacesContext()).toString() for 
performance reasons anyways?  I mean, if it is a String object it will 
just do a return this; which should be cheaper than a cast from an 
Object to a String.  It also causes the value to be coerced into a 
String.  Unless this is strictly forbidden by the standard, it can't see 
a reason not to implement it this way.


Thanks,
Rich

Richard Wallace wrote:


Klug, Boris wrote:


Hi!

the problem may be that a your calculation returns an int but the el 
statement
has to return an String. So do the calculation in your managed bean 
and return

the result as a String.

 

Thanks for the reply.  I had expected that the value would be coerced 
into the proper type tho, as in other EL statements.  Is this a bug or 
the right thing?  If this implementation is correct, is there anyway 
to convert the calculation to a string?  I really don't like the idea 
of having to do the calculation in the backing bean cause then my page 
designers can't easily vary the size of the image.  I could put it in 
the faces-config.xml, but that would still require them to restart 
their tomcat instance just to make a change to the page layout/display.


Right now I've got a workaround.  It's rather messy but it works.  I 
basically use the plain old img tag and do a couple of 
h:outputText in the attributes to make sure the image path contains 
the contextPath and then one to  perform and output the calculation in 
the height attribute.  Like I said, it's rather messy, but it works 
and allows the page designers to make better control over the page 
layout and display.


Rich


--
Boris Klug


Zitat von Richard Wallace [EMAIL PROTECTED]:

 


Hello everyone,

I'm working on a report that has a bar chart.  I thought the easiest 
way

to display it would be to use something like:

h:graphicImage url=/images/visual_bar_1.gif width=46
height=#{reportHandler.score * 18} border=0 /

But that horks with:

java.lang.ClassCastException
   at

  


javax.faces.component.html.HtmlGraphicImage.getHeight(HtmlGraphicImage.java:95) 

 


   at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
   at

  


sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 

 


   at java.lang.reflect.Method.invoke(Method.java:324)
   at
javax.faces.component._ComponentAttributesMap.getComponentProperty(_C

Can I not set the height to some calculated value?

Thanks,
Rich

  



 







Re: Calculating image height

2005-07-26 Thread Richard Wallace

The file is in api/trunk, and here's the svn diff.

Index: src/java/javax/faces/component/html/HtmlGraphicImage.java
===
--- src/java/javax/faces/component/html/HtmlGraphicImage.java   
(revision 225332)
+++ src/java/javax/faces/component/html/HtmlGraphicImage.java   (working 
copy)

@@ -92,7 +92,7 @@
{
if (_height != null) return _height;
ValueBinding vb = getValueBinding(height);
-return vb != null ? (String)vb.getValue(getFacesContext()) : null;
+return vb != null ? vb.getValue(getFacesContext()).toString() : 
null;

}

public void setIsmap(boolean ismap)

Thanks.

Bruno Aranda wrote:


You are right with that Richard, if is better to do .toString() than
the cast to String. Can you submit a patch or tell me Class/line so I
can fix this?

Regards,

Bruno

2005/7/26, Richard Wallace [EMAIL PROTECTED]:
 


Here's a related question.  The line that is causing me my problems is:

   return vb != null ? (String)vb.getValue(getFacesContext()) : null;

Isn't it better to do vb.getValue(getFacesContext()).toString() for
performance reasons anyways?  I mean, if it is a String object it will
just do a return this; which should be cheaper than a cast from an
Object to a String.  It also causes the value to be coerced into a
String.  Unless this is strictly forbidden by the standard, it can't see
a reason not to implement it this way.

Thanks,
Rich

Richard Wallace wrote:

   


Klug, Boris wrote:

 


Hi!

the problem may be that a your calculation returns an int but the el
statement
has to return an String. So do the calculation in your managed bean
and return
the result as a String.



   


Thanks for the reply.  I had expected that the value would be coerced
into the proper type tho, as in other EL statements.  Is this a bug or
the right thing?  If this implementation is correct, is there anyway
to convert the calculation to a string?  I really don't like the idea
of having to do the calculation in the backing bean cause then my page
designers can't easily vary the size of the image.  I could put it in
the faces-config.xml, but that would still require them to restart
their tomcat instance just to make a change to the page layout/display.

Right now I've got a workaround.  It's rather messy but it works.  I
basically use the plain old img tag and do a couple of
h:outputText in the attributes to make sure the image path contains
the contextPath and then one to  perform and output the calculation in
the height attribute.  Like I said, it's rather messy, but it works
and allows the page designers to make better control over the page
layout and display.

Rich

 


--
Boris Klug


Zitat von Richard Wallace [EMAIL PROTECTED]:



   


Hello everyone,

I'm working on a report that has a bar chart.  I thought the easiest
way
to display it would be to use something like:

h:graphicImage url=/images/visual_bar_1.gif width=46
height=#{reportHandler.score * 18} border=0 /

But that horks with:

java.lang.ClassCastException
  at


 


javax.faces.component.html.HtmlGraphicImage.getHeight(HtmlGraphicImage.java:95)



   


  at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
  at


 


sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)



   


  at java.lang.reflect.Method.invoke(Method.java:324)
  at
javax.faces.component._ComponentAttributesMap.getComponentProperty(_C

Can I not set the height to some calculated value?

Thanks,
Rich


 




   

   





Re: MyFaces 1.0.9: how old? how stable? what's next?

2005-07-26 Thread Richard Wallace
MyFaces 1.0.9 jars are available at http://www.bluesunrise.com/maven/.  
Those are what I've been using.  There was a short time where I did put 
jars up on a private server for my dev team because of a couple of 
issues we were having with the released versions.  I was just hoping to 
get something official setup.  If the question is hosting it, I can do 
that.  Hell, I could probably even setup a script to do an svn update 
and push snapshots out.  I'll probably wind up doing that soon anyways 
on a private server.  If there's enough interest I might as well go 
ahead and make it public.


Rich

Sean Schofield wrote:


We should ask James Mitchell.  He is a new committer to MyFaces (he's
a longtime committer on Struts.)  He is constantly jabbering on and on
about Maven so he could probably answer that ;-)

I'm not sure if a nightly build is warranted but I think we should
have jars for the official release builds (starting with the 1.0.9
which has already been released.)

Let see what James has to say ...

sean

On 7/26/05, Richard Wallace [EMAIL PROTECTED] wrote:
 


Any chance of getting a nightly snapshot in some maven repo somewhere
for those of us using maven in our projects?

Thanks,
Rich

Sean Schofield wrote:

   


I would suggest the nightly build as there have been many bug fixes
since the release.  The timing of the next release is still up in the
air but this project is in rapid change mode at the moment so IMO, you
always want to be using the latest release even if its not yet
official.

sean

On 7/26/05, Lindholm, Greg [EMAIL PROTECTED] wrote:


 


I'm going to start a project with MyFaces.
Should I use the 1.0.9 build or grab the latest nightly build?
Have a lot of bugs been fixed since the release?
Are we getting close to a new release?

Is MyFaces on a Release soon Release often strategy?

I don't mind updating often, what I really hate is fighting bugs that
have already been fixed.

What are people using?

Thanks




   

   





Re: Variable cell style classes in data table

2005-07-25 Thread Richard Wallace

Jesse Alexander (KBSA 21) wrote:


I did something similar, but I just needed to render an image according
the content of a field.

I ended up writing a Lookup-image component. Nothing complicated.

hope this helps
Alexander

PS: I'll be offline for a week!  But after august 2nd i can scetch
up a component that does this trick, if you can wait till then. 

 


Sounds good.  I can probably figure something out until then.  Thanks a ton.

Rich


-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 25, 2005 7:52 PM

To: MyFaces Discussion
Subject: Variable cell style classes in data table

Hey everyone,

I've got a report that I'm displaying with h:dataTable.  Depending on 
the value to be displayed the background color of the cell should be a 
different shade.  So for low values, it'd be like a really light yellow, 
for high values it'd be a much darker yellow, etc.  Any ideas on how I 
can accomplish this with MyFaces?


I had sort of hoped that something like the following would work:

h:column styleClass=#{reportHandler.styleClass}

But, as I found out, styleClass isn't a valid attribute for the 
h:column element.


Any ideas?  Am I stuck rendering this sucker with plain old JSP and JSTL?

Thanks,
Rich
 





Calculating image height

2005-07-25 Thread Richard Wallace

Hello everyone,

I'm working on a report that has a bar chart.  I thought the easiest way 
to display it would be to use something like:


h:graphicImage url=/images/visual_bar_1.gif width=46 
height=#{reportHandler.score * 18} border=0 /


But that horks with:

java.lang.ClassCastException
   at 
javax.faces.component.html.HtmlGraphicImage.getHeight(HtmlGraphicImage.java:95)

   at sun.reflect.GeneratedMethodAccessor110.invoke(Unknown Source)
   at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

   at java.lang.reflect.Method.invoke(Method.java:324)
   at 
javax.faces.component._ComponentAttributesMap.getComponentProperty(_C


Can I not set the height to some calculated value?

Thanks,
Rich


Clearing a form after submission

2005-07-12 Thread Richard Wallace

Hello,

I've got a couple of forms that after submission I don't want the values 
that were submitted to be redisplayed in the form.  I tried clearing the 
data model in the action handling method when the form is submitted, but 
the form is still populated when it is displayed.  Any ideas how I can 
clear the form?


Thanks,
Rich


Re: Clearing a form after submission

2005-07-12 Thread Richard Wallace

[EMAIL PROTECTED] wrote:



Use a JSF EL expression in the rendered attributes of any elements 
that you would like to hide.


x:elementThatIWantToShowOrHide rendered=#{some expression that 
eval.s to false or true} / 


I wasn't clear I guess.  What I want is for the form to be cleared, so 
that any text fields will be empty, check boxes and radio buttons will 
all be unselected, etc.  Just as if it was a brand new form.


Rich


Re: dataList with radio buttons

2005-07-12 Thread Richard Wallace
Weird, I changed from x:dataList to x:dataTable and validation and 
updating the data model works as it should.  It's too bad cause I'd 
rather not have to use a table for page layout.  Using the list would 
allow my designer to use div tags.  Is this a bug or something that 
the x:dataList isn't meant to be used for?


Thanks,
Rich

Richard Wallace wrote:


Hello,

I've got a dataList bound to a list of values in the backing bean as 
such:


   x:dataList id=questionList layout=simple 
value=#{assessmentHandler.currentPage.questions} var=question
   h:outputText value=#{question.questionNo}. 
#{question.text} /

   f:verbatimbr //f:verbatim
   h:selectOneRadio id=choices required=true 
value=#{assessmentHandler.responses[question.questionNo - 1].score}
   f:selectItem id=oftenChoice 
itemValue=#{assessmentHandler.oftenScore} 
itemLabel=#{labels.oftenLabel} /
   f:selectItem id=sometimesChoice 
itemValue=#{assessmentHandler.sometimesScore} 
itemLabel=#{labels.sometimesLabel} /
   f:selectItem id=seldomChoice 
itemValue=#{assessmentHandler.seldomScore} 
itemLabel=#{labels.seldomLabel} /

   /h:selectOneRadio
   /x:dataList

The assessmentHandler has the method getResponses() which returns a 
List of Response objects.  The Response objects has a getter/setter 
for the score attribute.  However, when I click the command button to 
advance to the next page or to finish the questioning the Response 
objects score values in the backing list is not updated with the value 
of the select item.  The required=true attribute also seems to be 
ignored, because I can safely advance without any errors.  Is this not 
the right way to do something like this?
I've looked at the list and the only alternative is to use Bruno 
Aranda's valueChangeListener solution from the is it possible to edit 
dynamic Tabular data? thread.  But, as was stated in that thread, it 
seems like the way I'm doing it should work to update the data model.  
I don't need to implement a setResponses() method do I?  The 
setScore() method on the actual Response object should be enough, 
shouldn't it be?  I'm sure I don't need to use the preserveDataModel 
attribute or an x:saveState / element.  So what's missing?


Thanks,
Rich





Re: dataList with radio buttons

2005-07-12 Thread Richard Wallace

[EMAIL PROTECTED] wrote:



Can you please elaborate on The required=true attribute also seems 
to be ignored, because I
can safely advance without any errors.? 


I simply meant that if I clicked on a command button, such as Next or 
Finish that MyFaces happily accepts the input as even if nothing is 
filled in on the form, completely bypassing the validation.  But, it 
doesn't update the data model.  At least, it doesn't update the data 
model if x:dataList is used.  It does if h:dataTable is used.  If 
dataTable is used everything works as it should.


Rich


NavigationHandler ignoring responseComplete()

2005-07-06 Thread Richard Wallace

Hey all,

I'm working on redirecting a user to the page they requested after 
successfully authenticating.  To do this I use the 
ExternalContext.redirect() method to redirect to a URL that is stored in 
the session when they try and access a page but aren't logged in and are 
redirected.  As I understand the JSF specs, this method should call the 
FacesContext.responseComplete() method and JSF shouldn't try and do 
anymore with the response.  I also have a navigation rule defined for 
the case when a user hasn't tried to access something before 
authenticating so they get directed to a default pre-login page.


It seems that when a user has tried to access a restricted page without 
authentication the navigation handler is ignoring the call to 
FacesContext.responseComplete() and trying to do another redirect to the 
default pre-login page.  This results in the following exception 
(somewhat shortened for brevity):


java.lang.IllegalStateException
   at 
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendRedirect(CoyoteResponseFacade.java:352)
   at 
org.apache.myfaces.context.servlet.ServletExternalContextImpl.redirect(ServletExternalContextImpl.java:479)
   at 
org.apache.myfaces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:179)
   at 
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:85)

   at javax.faces.component.UICommand.broadcast(UICommand.java:106)
   at 
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:110)
   at 
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:184)
   at 
org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
   at 
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:102)

   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:109)
   at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
   at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)


Is this a bug in the NavigationHandler implementation?  I'm using 
MyFaces 1.0.9.


I tried returning null from my action handler rather than something 
matching a rule to try and bypass the NavigationHandler, but that 
resulted in the following exception (again, shortened for brevity):


java.lang.IllegalStateException: Cannot forward after response has been 
committed
   at 
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:324)
   at 
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
   at 
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:405)
   at 
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:277)
   at 
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:300)

   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:110)
   at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
   at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)


Any ideas?

Thanks,
Rich


Acegi and JSF integration

2005-06-30 Thread Richard Wallace

Hey everyone,

I'm progressing with our move to Java and JSF and am trying to integrate 
some security.  I've decided on using Acegi Security because I need to 
be able to have domain object level ACLs and it's the most complete open 
source implementation I've seen.  But, I'm having some problems figuring 
how best to integrate it with JSF.


The main issue is that most of the servlet security stuff is implemented 
in Servlet Filters, including the part that authenticates the user.  
Whats worse, IMO, is that the Filters are actually Spring managed beans 
proxied by a delegating Filter.  The main problems I have with this is 
that I can't create a nice JSF form with an 
action=#{authHandler.authenticate} action handler.  I'd also like to 
control the flow of the page and what happens when logins succeed/fail 
from the JSF navigation.  As it stands now that's actually handled by 
one of the Spring managed beans.


To these ends I've created an AuthenticationHandler backing bean, mostly 
just copying the code in the AuthenticationProcessingFilter class which 
listens for requests to a certain URL and tries to login the user with 
the credentials in the request.  The other stuff is a bit more 
complicated and I'm not 100% sure where to begin.  I'm thinking I need 
to create PhaseListener classes for the other Filters and copying the 
code from the corresponding filters.


Has anyone worked on integrating Acegi  and JSF more seemlessly before?  
I'd appreciate any advice anyone can give.


Thanks,
Rich


Re: Read this?: 'Oracle to release JDeveloper / Oracle will join MyFaces project as core contributor.

2005-06-24 Thread Richard Wallace

Christian Daszenies wrote:


http://www.theserverside.com/news/thread.tss?thread_id=34781
 

Wow, this is really cool.  I was also just looking through the ADF Faces 
components and they look really cool.  I hope they contribute these to 
MyFaces or at least make them freely usable.


Rich


Re: Dynamically adding form elements client-side

2005-06-21 Thread Richard Wallace

Werner Punz wrote:


Richard Wallace wrote:

Actually, on reflection, I can't really think of a good way to get 
everything I want for free anyways.  I think I will need to develop a 
custom component, probably something that is composed of other 
existing UI elements.  The three primary use cases I'm looking at 
currently are a dynamic, editable table with at least 2 text fields 
where rows can be added/removed without the need to roundtrip to the 
server, an editable, dynamic table with a drop down list and a text 
field in a row where rows can be added/removed without roundtripping 
and an element where a user can add multiple file upload elements 
without having to roundtrip.  i don't really see a way this can all 
be done in JSF without using custom elements.


Of course, I'm open to suggestions.



Not really suggestions, I see it as you, there is no real free lunch 
in this case, but hard work.


But there is a small project on sourceforge which already has an ajax 
component in place, not something as sophisticated as what you want to 
do, but you can check it out it might give you a headstart with your 
things (and also a small push towards donating code yourself if you 
want :-), your components sound interesting )



I have looked at those components.  Very neat.  I'm a little curious why 
you didn't use the DWR library 
(http://www.getahead.ltd.uk/dwr/index.html) for doing the AJAX stuff.  
I'll definitely consider donating the code and it shouldn't be a 
problem, just have to clear it with the higher ups.


the project is http://sourceforge.net/projects/jsf-comp the only ajax 
component currently is an autocomplete field, which basically does 
some element tinkering (blends in a filled div on demand which 
simulates a drop down box), also there is an excellent OO javascript 
library which is under MIT license, which delivers some effects and 
good ajax classes.


The ajax component however does not use the Prototype OO lib yet, it 
still uses a somewhat hackish messy code which was taken from the Sun 
blueprints catalog and hacked in no time to IE compatibility.


Also there is the Sun blueprints catalog which has some ajax stuff in 
there already, on java.net.






Re: Dynamically adding form elements client-side

2005-06-20 Thread Richard Wallace

Werner Punz wrote:


Richard Wallace wrote:


Hello again,

I'm trying to figure out how, if it's possible to add form elements, 
like text fields, when a user clicks an add button without having to 
have the page resubmit. 


Only by using javascript, but without javascript no.
That is a limit caused by the beast which is called html.
With javascript you can do it by altering the dom
tree.


I understand that, but how do you have JSF pickup the new element(s) 
when restoring state when the form is submitted?



With server side roundtripping, JSF has special api hooks
to do that (component bindings, child element trees)


I'm not even sure it's 100% possible unless the STATE_SAVING_METHOD 
is client.  And then the javascript would have to manipulate that 
hidden field.  Or do some kind of AJAX operation to modify the state 
when it's being stored server side.  At this point, I think if 
anything prevents us from adopting JSF at work it would be 
dynamically adding form elements.  Any suggestions?


Well depends on what you want to do with it, if you need additional 
data from the server, either use ajax, or go the roundtripping way.
But if you want to stay on the client side, there is no way you can 
avoid javascript and if you dont want javascript, there is no way you

can avoid roundtripping.





Re: Dynamically adding form elements client-side

2005-06-20 Thread Richard Wallace

Werner Punz wrote:


Richard Wallace wrote:


Werner Punz wrote:


Richard Wallace wrote:


Hello again,

I'm trying to figure out how, if it's possible to add form 
elements, like text fields, when a user clicks an add button 
without having to have the page resubmit. 




Only by using javascript, but without javascript no.
That is a limit caused by the beast which is called html.
With javascript you can do it by altering the dom
tree.




I understand that, but how do you have JSF pickup the new element(s) 
when restoring state when the form is submitted?



To my knowledge by adding child elements to an element binding in
the backend bean.
JSF basically builds an element tree internally, and you basically can 
access this tree over various methods. - One being the element bindind 
mechanism.
During the rendering phase, the elements then are rendered into the 
target (mostly html)


Thus you cann add and remove those elements by tinkering with the 
element tree in your backend bean.


Ok, but how should I tinker with the element tree?  I'm guessing AJAX 
will need to come into play.  But how do I get access to the element 
tree?  And exactly how should I manipulate it?  I'm guessing there's no 
ready to go methods already in the JSF APIs to accomplish this, are there?


Rich


Re: Dynamically adding form elements client-side

2005-06-20 Thread Richard Wallace

Martin Marinschek wrote:


You need to explicitly add these new elements, this is entirely your
responsibility...

 


I understand that, my question is How do I add the new elements?

Rich


regards,

Martin

On 6/20/05, Richard Wallace [EMAIL PROTECTED] wrote:
 


Werner Punz wrote:

   


Richard Wallace wrote:

 


Hello again,

I'm trying to figure out how, if it's possible to add form elements,
like text fields, when a user clicks an add button without having to
have the page resubmit.
   


Only by using javascript, but without javascript no.
That is a limit caused by the beast which is called html.
With javascript you can do it by altering the dom
tree.
 


I understand that, but how do you have JSF pickup the new element(s)
when restoring state when the form is submitted?

   


With server side roundtripping, JSF has special api hooks
to do that (component bindings, child element trees)


 


I'm not even sure it's 100% possible unless the STATE_SAVING_METHOD
is client.  And then the javascript would have to manipulate that
hidden field.  Or do some kind of AJAX operation to modify the state
when it's being stored server side.  At this point, I think if
anything prevents us from adopting JSF at work it would be
dynamically adding form elements.  Any suggestions?

   


Well depends on what you want to do with it, if you need additional
data from the server, either use ajax, or go the roundtripping way.
But if you want to stay on the client side, there is no way you can
avoid javascript and if you dont want javascript, there is no way you
can avoid roundtripping.

 

   





Re: Dynamically adding form elements client-side

2005-06-20 Thread Richard Wallace

Werner Punz wrote:


Richard Wallace wrote:

Ok, but how should I tinker with the element tree?  I'm guessing 
AJAX will need to come into play.  But how do I get access to the 
element tree?  And exactly how should I manipulate it?  I'm guessing 
there's no ready to go methods already in the JSF APIs to accomplish 
this, are there?


I think you have a small misunderstanding here what JSF is and what 
you can do.


I completely understand that.

You cannot alter the backend element tree without any refresh, so you 
have to force a refresh to do that in the backend.


That's why I was wondering if AJAX could be used when a new form element 
is being created to modify the backend element tree without having to 
refresh the whole page.


If you want to alter the displayed form controls without refresh you 
only can do it with javascript (and ajax if it is dependend on data)


JSF is a plain and pure server side UI api, while javascript a pure 
client side one is. Thus you cannot really change the form rendering 
from pure JSF without any refresh or going the javascript route.


Here's an example of the sort of thing that I want to do: 
http://tacos.mine.nu:8080/tacos-demo/app?service=page/PartialForms.


If it's impossible to accomplish something like this in JSF right now, 
that's fine.  I'll just use Tapestry and hope that JSF will be able to 
support this idea of partial forms in the future.  Then again, it's 
just a component in Tapestry so I don't see why it can't be a component 
in JSF.  Unless there really is no way to modify that component tree 
without having to resubmit the whole form.


Re: Dynamically adding form elements client-side

2005-06-20 Thread Richard Wallace

Werner Punz wrote:


Richard Wallace wrote:


Martin Marinschek wrote:


You need to explicitly add these new elements, this is entirely your
responsibility...

 


I understand that, my question is How do I add the new elements?



If you can do a refresh, you simple do a binding to the backend bean, 
and there you can access the elements via a getChildElements (or 
something similarily named control)


If you cannot do a refresh, you have to revert to javascript and dom
(and possibly) ajax to alter the form elements.

For explanation of bindings and backendbeans, lookup the JSF docs, or
http://www.jsftutorials.net/

Werner

I think you're completely missing the idea behind what I want to do.  I 
know you have to use javascript to add the form elements.  I have 
already done that in webapps in the past.  The question I'm asking here 
is how to get those new form elements, created on the client side, to be 
bound to my backing bean.  The reason I mention ajax is to possibly 
modify the form state if it is being stored on the server side so that 
JSF will handle the value bindings.


Re: Dynamically adding form elements client-side

2005-06-20 Thread Richard Wallace

Werner Punz wrote:


Richard Wallace wrote:


Werner Punz wrote:


Richard Wallace wrote:

Ok, but how should I tinker with the element tree?  I'm guessing 
AJAX will need to come into play.  But how do I get access to the 
element tree?  And exactly how should I manipulate it?  I'm 
guessing there's no ready to go methods already in the JSF APIs to 
accomplish this, are there?


I think you have a small misunderstanding here what JSF is and what 
you can do.




I completely understand that.

You cannot alter the backend element tree without any refresh, so 
you have to force a refresh to do that in the backend.




That's why I was wondering if AJAX could be used when a new form 
element is being created to modify the backend element tree without 
having to refresh the whole page.


Ok a misunderstanding from my part, to my knowlege, you cannot really 
do that, because the element tree is rebuilt at each subsequent request.
The safest bet is to stay on the ajax/client side only for what you 
want to achieve, and once you hit a refresh, fetch the ajaxed part 
directly from the request object if you need to do further processing 
on it.


What you also could do is to componentize the ajaxed part of your 
form, that way you could establish a connection between the element 
tree and your ajaxed part of your form.



Then the flow would look like that...
pure client side... do anything with the ajax elements

submit or something else which causes a refresh:
the value binding and binding mechanisms transfers the values from the 
ajaxed components to the backend beans for further processing.



The third way could be to have the form parameters parsed at request 
level and then the component subtree rebuilt at the subsequent refresh.

But that approach is probably the messiest of all three.


Actually, on reflection, I can't really think of a good way to get 
everything I want for free anyways.  I think I will need to develop a 
custom component, probably something that is composed of other existing 
UI elements.  The three primary use cases I'm looking at currently are a 
dynamic, editable table with at least 2 text fields where rows can be 
added/removed without the need to roundtrip to the server, an editable, 
dynamic table with a drop down list and a text field in a row where rows 
can be added/removed without roundtripping and an element where a user 
can add multiple file upload elements without having to roundtrip.  i 
don't really see a way this can all be done in JSF without using custom 
elements.


Of course, I'm open to suggestions.

Rich


Dynamically adding form elements client-side

2005-06-18 Thread Richard Wallace

Hello again,

I'm trying to figure out how, if it's possible to add form elements, 
like text fields, when a user clicks an add button without having to 
have the page resubmit.  I'm not even sure it's 100% possible unless the 
STATE_SAVING_METHOD is client.  And then the javascript would have to 
manipulate that hidden field.  Or do some kind of AJAX operation to 
modify the state when it's being stored server side.  At this point, I 
think if anything prevents us from adopting JSF at work it would be 
dynamically adding form elements.  Any suggestions?


Thanks,
Rich


Re: Dynamically adding form elements client-side

2005-06-18 Thread Richard Wallace

David G. Friedman wrote:


Richard,

Are you talking about hiding/showing the fields (such as using a CSS style)
or completely adding to the page without a resubmit?

 


Completely adding a new element to the form.


Regards,
David

-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED]
Sent: Saturday, June 18, 2005 11:04 PM
To: MyFaces Discussion
Subject: Dynamically adding form elements client-side


Hello again,

I'm trying to figure out how, if it's possible to add form elements,
like text fields, when a user clicks an add button without having to
have the page resubmit.  I'm not even sure it's 100% possible unless the
STATE_SAVING_METHOD is client.  And then the javascript would have to
manipulate that hidden field.  Or do some kind of AJAX operation to
modify the state when it's being stored server side.  At this point, I
think if anything prevents us from adopting JSF at work it would be
dynamically adding form elements.  Any suggestions?

Thanks,
Rich

 





Re: Dynamically adding form elements client-side

2005-06-18 Thread Richard Wallace
Thanks, I understand how to do it on the javascript side.  I'm just not 
sure how to translate it into something the JavaServer Faces will be 
able to understand.  Optimally, of course, the values of the new 
elements would be bound to the backing bean in the same way as any other 
values.  The difficulty is, of course, changing the state on either the 
client or the server side so it is restored in the restore view phase.  
If someone can tell me how to do that, I will be forever grateful.


Rich

David G. Friedman wrote:


Richard,

I am still learning about MyFaces so I can only give you the JavaScript/DOM
portion of the solution.  I can't yet give you information on how to name
your fields to work with a map/list/set backed Managed bean.  I'm hoping
this will get you far enough along so your MyFaces skills can fill in the
gaps past my own light DOM/JavaScript knowledge.

A good reference link (for me) was:
http://www.mozilla.org/docs/dom/technote/tn-dom-table/#quick

My test file used an input button on my form with an onClick like so:

javascript:addFieldPlusLineBr(this);return false;

To invoke a JavaScript example method of my own making to add a text field
and line break to the form:

script language=javascript
function addFieldPlusLineBr(input) {
var form = input.form;
alert(hello);
var inputNode = document.createElement(input);
form.appendChild(document.createElement(br));
inputNode.setAttribute(name,fred);
inputNode.setAttribute(value,fredValue);
form.appendChild(inputNode);
}
/script

Your trick will be figuring out how to place it exactly WHERE you want it in
your form.  The link I mentioned should include various methods you could
invoke to add it after the element, or elements, of your choice.

Good luck!

Regards,
David

-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED]
Sent: Saturday, June 18, 2005 11:10 PM
To: MyFaces Discussion
Subject: Re: Dynamically adding form elements client-side


David G. Friedman wrote:

 


Richard,

Are you talking about hiding/showing the fields (such as using a CSS style)
or completely adding to the page without a resubmit?



   


Completely adding a new element to the form.

 


Regards,
David

-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED]
Sent: Saturday, June 18, 2005 11:04 PM
To: MyFaces Discussion
Subject: Dynamically adding form elements client-side


Hello again,

I'm trying to figure out how, if it's possible to add form elements,
like text fields, when a user clicks an add button without having to
have the page resubmit.  I'm not even sure it's 100% possible unless the
STATE_SAVING_METHOD is client.  And then the javascript would have to
manipulate that hidden field.  Or do some kind of AJAX operation to
modify the state when it's being stored server side.  At this point, I
think if anything prevents us from adopting JSF at work it would be
dynamically adding form elements.  Any suggestions?

Thanks,
Rich



   



 





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 h:messages / 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 h:messages / 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 
http://people.apache.org/%7Ecraigmcc/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] 
mailto:[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]
mailto:[EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]
mailto:[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:

 navigation-rule
 from-view-id/contact/add.jsp/from-view-id
 navigation-case
 from-action#{contactHandler.saveContact
}/from-action
 from-outcomesuccess/from-outcome
 to-view-id/contact/list.jsp/to-view-id
 redirect/
 /navigation-case
 /navigation-rule

 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
 h:view followed immediately by h:messages

Messages and navigation rule redirects

2005-06-14 Thread Richard Wallace

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:


   navigation-rule
   from-view-id/contact/add.jsp/from-view-id
   navigation-case
   from-action#{contactHandler.saveContact}/from-action
   from-outcomesuccess/from-outcome
   to-view-id/contact/list.jsp/to-view-id
   redirect/
   /navigation-case
   /navigation-rule

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 
h:view followed immediately by h:messages /.  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 h:messages / tag in there in case there is some validation 
error or some other problem.  But that's just a guess.


The other possibility to me is that the messages are somehow page 
specific, so a message generated on one page won't show up on another.  
In which case my question is how do I get around this?


Could it maybe have something to do with the backing bean that generates 
the message being request scoped rather than session scoped?


Once again, thanks for the help
Rich


Re: Filling in select lists

2005-06-13 Thread Richard Wallace

Korhonen, Kalle wrote:


Looks to me that you should use x:saveState to extend the lifetime of
the request scoped bean and/or to save the specific properties of the
bean - unless there is some specific reason why you are avoiding the use
of x:saveState?

 

I didn't know it existed.  I've looked at some of the examples on its 
use and I'm still not sure exactly what it does.  It's not very well 
documented from what I've been able to find.  Care to fill me in on the 
details of how to use it and what it does?


Thanks
Rich

Kalle 

 


-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED] 
Sent: Sunday, June 12, 2005 12:33 PM

To: MyFaces Discussion
Subject: Re: Filling in select lists

Martin Marinschek wrote:

   

have you tried to set the immediate attribute on the 
 


ui-input component?
   




 

Yes.  I have immediate=true set for the h:selectOneMenu 
elements and in the event handler I have it updating the 
selected value and then jumping to the renderResponse() phase 
to bypass validation.  The problem is that the backing bean 
is request scoped and the previously set value for the first 
h:selectOneMenu does not get set again in the backing bean. 
So the only way I can think to get that value is to use the 
getExternalContext().getRequestParameterMap().  Here's the 
JSF tags so you can get a better idea of what is going on 
cause I don't think I'm getting my thoughts across very clearly.


   h:panelGroup
   h:outputLabel for=organization 
value=Organization /
   h:selectOneMenu id=organization 
value=#{courseHandler.selectedOrganization} 
valueChangeListener=#{courseHandler.handleOrganizationChanged} 
onchange=submit() immediate=true

   f:selectItem itemValue= /
   f:selectItems
value=#{organizationHandler.organizationChoices} /
   /h:selectOneMenu
   /h:panelGroup
   br /
   h:panelGroup
   h:outputLabel for=department 
value=Department /
   h:selectOneMenu id=department 
value=#{courseHandler.selectedDepartment} 
valueChangeListener=#{courseHandler.handleDepartmentChanged} 
onchange=submit() immediate=true

   f:selectItem itemValue= /
   f:selectItems
value=#{courseHandler.departmentChoices} /
   /h:selectOneMenu
   /h:panelGroup
   br /
   h:panelGroup
   h:outputLabel for=instructors 
value=Instructors /
   h:selectManyListbox id=instructors 
value=#{courseHandler.selectedInstructors}

   f:selectItems
value=#{courseHandler.contactChoices} /
   /h:selectManyListbox
   /h:panelGroup

Now the selectItems for the department depend on the selected 
value of the organization and the selectItems for the 
instructors list depends on the selected value for the 
departments.  What's happening is that when a user selects 
the organization the department list gets populated just 
fine.  When they select the department, the instructors list 
gets populated fine, but the departments list comes up empty 
because the value for the organization is never set in the 
backing bean because the update model phase is also bypassed. 
The only ways I can think to fix this is to make the backing 
bean session scoped so that the selected organization is 
persisted across requests.  But that makes me nervous cause 
it seems error prone.  The only other way to do it is to use the
getExternalContext().getRequestParameterMap() and lookup the 
value for the selected organization in the 
handleDepartmentChanged() event handler.  But that seems like 
a bad idea because it means I have to know the id of the 
element ahead of time, which I think is just sloppy design.


I'll probably wind up switching to a session scoped backing 
bean if I have to.  But that raises all sort of other 
problems in other areas that I'm not entirely sure how to 
work around.  I guess I could move stuff that needs to be 
request based like the dynamic choice elements to be request 
scoped and keep the current working object session scoped or 
something like that.


Does that sound like a decent approach or is there a better way?

Thanks again,
Rich

   


regards,

Martin

On 6/12/05, Richard Wallace [EMAIL PROTECTED] wrote:


 

I understand all that you've said and am using some 
   

application scoped 
   

beans for global select items that don't change.  The 
   

problem is that 
   

the list of items that I'm working with now are database backed and 
are likely to change often.  I can maybe cache the top level select 
list items, the organizations and update it when an organization is 
added or updated.  But the others, the list items for 
   

departments and 
   

personnel are dependent on the selected organization so 
   

there's no way

Re: Filling in select lists

2005-06-13 Thread Richard Wallace

Korhonen, Kalle wrote:


-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED] 
Subject: Re: Filling in select lists

Korhonen, Kalle wrote:
   

Looks to me that you should use x:saveState to extend the 
 

lifetime of 
   

the request scoped bean and/or to save the specific 
 

properties of the 
   

bean - unless there is some specific reason why you are avoiding the 
use of x:saveState?
 

I didn't know it existed.  I've looked at some of the 
examples on its use and I'm still not sure exactly what it 
does.  It's not very well documented from what I've been able 
to find.  Care to fill me in on the details of how to use it 
and what it does?
   



With x:saveState you can store a value an object/property and restore it
using the same id, i.e. on edit user page you have x:saveState
id=editedUser value=currentUser (if currentUser is the name of your
user bean). Then on confirm user changes page you use the same tag to
restore the changed bean. The same goes for saving bean properties. Play
with it and see how it works.

Kalle

 

That worked perfectly!  It was exactly the right magic I needed. Thanks 
a ton!

Rich


-Original Message-
From: Richard Wallace [mailto:[EMAIL PROTECTED]
Sent: Sunday, June 12, 2005 12:33 PM
To: MyFaces Discussion
Subject: Re: Filling in select lists

Martin Marinschek wrote:

  

   


have you tried to set the immediate attribute on the


 


ui-input component?
  

   



 

Yes.  I have immediate=true set for the h:selectOneMenu 
   

elements 
   

and in the event handler I have it updating the selected value and 
then jumping to the renderResponse() phase to bypass 
   

validation.  The 
   

problem is that the backing bean is request scoped and the 
   

previously 
   

set value for the first h:selectOneMenu does not get set again in 
the backing bean.
So the only way I can think to get that value is to use the 
getExternalContext().getRequestParameterMap().  Here's the 
   

JSF tags so 
   

you can get a better idea of what is going on cause I don't 
   

think I'm 
   


getting my thoughts across very clearly.

  h:panelGroup
  h:outputLabel for=organization 
value=Organization /
  h:selectOneMenu id=organization 
value=#{courseHandler.selectedOrganization} 
valueChangeListener=#{courseHandler.handleOrganizationChanged} 
onchange=submit() immediate=true

  f:selectItem itemValue= /
  f:selectItems 
value=#{organizationHandler.organizationChoices} /

  /h:selectOneMenu
  /h:panelGroup
  br /
  h:panelGroup
  h:outputLabel for=department 
value=Department /
  h:selectOneMenu id=department 
value=#{courseHandler.selectedDepartment} 
valueChangeListener=#{courseHandler.handleDepartmentChanged} 
onchange=submit() immediate=true

  f:selectItem itemValue= /
  f:selectItems 
value=#{courseHandler.departmentChoices} /

  /h:selectOneMenu
  /h:panelGroup
  br /
  h:panelGroup
  h:outputLabel for=instructors 
value=Instructors /
  h:selectManyListbox id=instructors 
value=#{courseHandler.selectedInstructors}
  f:selectItems 
value=#{courseHandler.contactChoices} /

  /h:selectManyListbox
  /h:panelGroup

Now the selectItems for the department depend on the 
   

selected value of 
   

the organization and the selectItems for the instructors 
   

list depends 
   

on the selected value for the departments.  What's 
   

happening is that 
   

when a user selects the organization the department list gets 
populated just fine.  When they select the department, the 
   

instructors 
   

list gets populated fine, but the departments list comes up empty 
because the value for the organization is never set in the backing 
bean because the update model phase is also bypassed.
The only ways I can think to fix this is to make the backing bean 
session scoped so that the selected organization is 
   

persisted across 
   

requests.  But that makes me nervous cause it seems error 
   

prone.  The 
   


only other way to do it is to use the
getExternalContext().getRequestParameterMap() and lookup 
   

the value for 
   


the selected organization in the
handleDepartmentChanged() event handler.  But that seems like a bad 
idea because it means I have to know the id of the element ahead of 
time, which I think is just sloppy design.


I'll probably wind up switching to a session scoped backing 
   

bean if I 
   

have to.  But that raises all sort of other problems in other areas 
that I'm not entirely sure how to work around.  I guess I 
   

could move 
   

stuff that needs to be request based like

Errant event firing

2005-06-13 Thread Richard Wallace

Hello,

I'm having another problem with my select list and the value changed 
event listener.  I have the following tag:


h:selectManyListbox id=organizations 
value=#{contactHandler.selectedOrganizations} 
valueChangeListener=#{contactHandler.handleOrganizationChanged} 
onchange=submit() immediate=true


This is for an Edit Contact page so when the page is initially loaded 
there is an organization selected.  The problem that I'm having is that 
when I click the update button to invoke the appropriate action handler 
it is never called.  The page just reloads.  If I click the update 
button a second time it does call the action handler.


I did a trace of the phases with a PhaseListener and found that it is 
jumping from the apply request values phase to the render response 
phase.  So I added some logging in the places I call the 
FacesContext.renderReponse() method and lo and behold the 
handleOrganizationChanged() event handler is being called in spite of 
nothing on the page having been changed.  To investigate further I 
logged the events old value and the new value and found that the old 
value was empty when it shouldn't have been.


Is this a side effect of the event handling being declared as being 
immediate?  What can I do to fix this?


Thanks again for all the help,
Rich


Re: Errant event firing

2005-06-13 Thread Richard Wallace

Richard Wallace wrote:


Hello,

I'm having another problem with my select list and the value changed 
event listener.  I have the following tag:


h:selectManyListbox id=organizations 
value=#{contactHandler.selectedOrganizations} 
valueChangeListener=#{contactHandler.handleOrganizationChanged} 
onchange=submit() immediate=true


This is for an Edit Contact page so when the page is initially 
loaded there is an organization selected.  The problem that I'm having 
is that when I click the update button to invoke the appropriate 
action handler it is never called.  The page just reloads.  If I click 
the update button a second time it does call the action handler.


I did a trace of the phases with a PhaseListener and found that it is 
jumping from the apply request values phase to the render response 
phase.  So I added some logging in the places I call the 
FacesContext.renderReponse() method and lo and behold the 
handleOrganizationChanged() event handler is being called in spite of 
nothing on the page having been changed.  To investigate further I 
logged the events old value and the new value and found that the old 
value was empty when it shouldn't have been.


Is this a side effect of the event handling being declared as being 
immediate?  What can I do to fix this?


Ok, I found the problem and it's entirely my fault.  But it brings up 
another question.  Basically all my page backing beans are request 
scoped and this is an edit page so I need to pass in the id of the 
contact to edit.  I did this in the getContact() accessor method which 
checks if the contact is null and if it is gets the contact id from the 
external context parameter map.  This is all well and good when I 
initially go into the edit page with the url 
http://localhost:8080/contact/edit.jsf?contactId=11.


In the form I try and carry this through with a hidden form element 
called contactId thinking that I should still be able to lookup the 
external context parameter value for contactId and get the right 
thing.  That is, of course, wrong because the actual form element name 
is like _id1:contactId.  So the reason it comes up with the empty list 
of selected organizations is because it's using a newly constructed 
object and not one loaded from the backend.


So now my question is what is the best way to carry the id across page 
reloads like this?  I've seen the method where you would have the 
currentContactId be a JSF managed bean property and then pass in 
param.contactId.  But that runs into the same kind of problem.  The 
other method I've seen for doing this sort of thing is to make the 
actual link the user clicks on to get to the page a h:commandLink 
element bound to an option that sets the current contact in a session 
scoped backing bean and then does a redirect to the actual edit page.  I 
don't like this for a number of reasons, one being the session scoped 
backing bean and the other being that users can't bookmark the URL.  
I'll have to discuss this with some people here to see if the latter 
really is an issue or not, but I'd like to get the feedback of people on 
the mailing list that have done this before.  So, what's the most 
commonly accepted practice on how to handle this?  The session scoped 
backing bean which wraps the actual data model object?  Or is there a 
better way?


Thanks
Rich


Re: Filling in select lists

2005-06-11 Thread Richard Wallace

Richard Wallace wrote:

So what do I need to do to fix this?  One idea is to try and find the 
value that JSF will use in the form and use that if there is one and 
then otherwise use the backing beans value when I'm generating the 
department choices.  Seems kind of hacky since that's one of the 
things that JSF is supposed to do for you is provide the form values.  
I'm also not certain how to get the values that JSF is going to use in 
the forms without having it update the model values.


Well, I figured this part out at least.  I can use the 
FacesContext.getExternalContext ().getRequestParameterMap(), but then 
I'd need to know the key of the form and form element to be able to 
lookup the value.  Obviously, not an ideal solution.


Another idea is if I can somehow avoid doing the validation some other 
way.  That's really the only reason I need to do the event processing 
right away and then skip to the rendering phase.  But I've looked and 
there doesn't seem to be another way of bypassing validation. 


Well, I've looked around and this doesn't seem possible.  Unless I can 
do something with PhaseListeners, but I don't see how.


Please help!

Thanks,
Rich


Re: Filling in select lists

2005-06-11 Thread Richard Wallace
I just thought that I should also mention that my backing bean is a 
request scoped object.  So another solution is to switch this to a 
session based backing bean, but my backing bean is where the select 
items for organizations, departments and contacts for the list boxes and 
drop-down menus are generated.  I would like to be able to cache those 
for the life of the request but they shouldn't be cached across requests 
since they could change at any time.


What's the best practice for these backing beans?  My design is pretty 
much following the design ideas in a couple of articles I've read where 
the backing bean contains the current selected object and the JSF pages 
bind with value=#{contactHandler.currentContact.firstName} for 
example.  Is it better to have this backing bean be session scoped or 
request scoped?


Richard Wallace wrote:


Richard Wallace wrote:

So what do I need to do to fix this?  One idea is to try and find the 
value that JSF will use in the form and use that if there is one and 
then otherwise use the backing beans value when I'm generating the 
department choices.  Seems kind of hacky since that's one of the 
things that JSF is supposed to do for you is provide the form 
values.  I'm also not certain how to get the values that JSF is going 
to use in the forms without having it update the model values.



Well, I figured this part out at least.  I can use the 
FacesContext.getExternalContext ().getRequestParameterMap(), but then 
I'd need to know the key of the form and form element to be able to 
lookup the value.  Obviously, not an ideal solution.


Another idea is if I can somehow avoid doing the validation some 
other way.  That's really the only reason I need to do the event 
processing right away and then skip to the rendering phase.  But I've 
looked and there doesn't seem to be another way of bypassing validation. 



Well, I've looked around and this doesn't seem possible.  Unless I can 
do something with PhaseListeners, but I don't see how.


Please help!

Thanks,
Rich





Filling in select lists

2005-06-10 Thread Richard Wallace

Hello,

I'm working on writing my first webapp with JavaServer Faces and I'm 
using a compiled libraries that I checked out earlier today.  I'm having 
a problem with filling in a bunch of select menu and select boxes 
dynamically.


Here's the situation.  I have a h:selectOneMenu element for a person 
to select a company.  When they change the selected company the form is 
submitted and the next h:selectOneMenu is populated with the 
departments in the company.  When the department selected is changed a 
h:selectManyListbox is supposed to be populated with the personnel in 
that department.


Optimally, in the future, I'll change this to be an ajax interface.  But 
for now, because time is limited, I'm doing it all with regular old page 
requests (I know, yuck, but you gotta do what you gotta do).


The problem is when the department selection changes, it seems as tho 
the value for the selected organization is not being carried tho to the 
backing bean.  The proper organization is still selected in the form, 
but because the department select items are populated with a method in 
the backing bean that tries to use the beans value for the selected 
organization the department menu shows up empty but the personnel list 
box is populated.


The company and department h:selectOneMenu elements both use the 
immediate=true attribute to bypass any validations and then the event 
handler doesn't do anything other than take the new value and call 
setSelectedCompany/setSelectedDepartment and then jump to the rendering 
phase with FacesContext.getCurrentInstance ().renderResponse ().  I'm 
guessing this completely bypasses setting any of the backing beans 
values and just carries the form across as is cause all the other form 
values are also maintained.


So what do I need to do to fix this?  One idea is to try and find the 
value that JSF will use in the form and use that if there is one and 
then otherwise use the backing beans value when I'm generating the 
department choices.  Seems kind of hacky since that's one of the things 
that JSF is supposed to do for you is provide the form values.  I'm also 
not certain how to get the values that JSF is going to use in the forms 
without having it update the model values.  Another idea is if I can 
somehow avoid doing the validation some other way.  That's really the 
only reason I need to do the event processing right away and then skip 
to the rendering phase.  But I've looked and there doesn't seem to be 
another way of bypassing validation.


Any other ideas?  Suggestions?

Thanks,
Rich

P.S. Is there anyway I can get you guys to start pushing SNAPSHOT builds 
to the maven repos?  I've been getting bitten by the null pointer 
exception bug when forms with list boxes are submitted but nothing in 
them is selected.  I saw it was fixed in svn so checked out, built and 
tested that and it worked beautifully.  But it would be much easier for 
me if there was a SNAPSHOT build in the maven repos.  Thanks.