Re: Tomcat6 Validation
Hi, I doubt the way you use the validator is correct. You can use a "validator" attribute inside the tag or use as a nested tag. i.e., or, you'll need to create a validator class and register the validator in the face-config, if going with the second way. HTH, Saul - Original Message - From: Elisa Budelli To: users@myfaces.apache.org Sent: Friday, March 16, 2007 8:28 AM Subject: Tomcat6 Validation Hello, I am using MyFaces version 1.1.5 and Tomcat 6. Everything seems to work fine except for Validation. In a Backing bean i have the following method: public void validateLogin(FacesContext context, UIComponent toValidate, Object value) throws ValidatorException{ .. } int the newUser.xhtml page: But when invoking the method that triggers validation i receive always the following exception: javax.servlet.ServletException : /pages/newUser.xhtml @17,137 validator="#{UserBean.validateLogin}": Method not found: [EMAIL PROTECTED](javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object ) javax.faces.webapp.FacesServlet.service(FacesServlet.java:154) javax.faces.el.MethodNotFoundException: /pages/newUser.xhtml @17,137 validator="#{UserBean.validateLogin}": Method not found: [EMAIL PROTECTED](javax.faces.context.FacesContext, javax.faces.component.UIComponent , java.lang.Object) com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:71) javax.faces.component._ComponentUtils.callValidators(_ComponentUtils.java:181) javax.faces.component.UIInput.validateValue(UIInput.java:313) javax.faces.component.UIInput.validate(UIInput.java:354) javax.faces.component.UIInput.processValidators (UIInput.java:184) javax.faces.component.UIForm.processValidators(UIForm.java:73) javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:627) javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java :149) de.mindmatters.faces.lifecycle.ProcessValidationsPhase.executePhase(ProcessValidationsPhase.java:43) de.mindmatters.faces.lifecycle.AbstractPhase.execute(AbstractPhase.java:37) de.mindmatters.faces.lifecycle.LifecycleImpl.executePhase (LifecycleImpl.java:166) de.mindmatters.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:211) javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)Any kind of help will be very welcomed. Thanks Spam/Virus scanning by CanIt Pro For more information see http://www.kgbinternet.com/SpamFilter.htm To control your spam filter, log in at http://filter.kgbinternet.com
How to call a method in the backing bean from a JSF page
Hi, I'm wondering what's the correct way to call a method in the backing bean from a JSF page. What I tried is to use , the backing bean method returns an empty string, so nothing gets printed out in the page. Which works, but I am not sure this is the correct way to do it. thanks, Saul
Re: How to call a method in the backing bean from a JSF page
Thanks for your reply, that makes sense. But won't h:commandLink render a link and h:commandButton render a button in the page? I don't want to display anything on the screen. My purpose is to initiate a call from the JSF page to a method in the backing bean when the JSF page loads. I'm returning an empty string from the method so nothing gets printed out from . - Original Message - From: "Ken" <[EMAIL PROTECTED]> To: "MyFaces Discussion" Sent: Wednesday, August 24, 2005 9:53 PM Subject: Re: How to call a method in the backing bean from a JSF page Try h:commandLink or h:commandButton. If your method returns a string that doesn't match any navigation-rule in your faces-confix.xml then the same page you came from will be rendered again. On 8/24/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: Hi, I'm wondering what's the correct way to call a method in the backing bean from a JSF page. What I tried is to use value="#{theBackingBean.theMethod}" />, the backing bean method returns an empty string, so nothing gets printed out in the page. Which works, but I am not sure this is the correct way to do it. thanks, Saul
Re: How to call a method in the backing bean from a JSF page
I see. The outputText way is actually what I did. So, is there a way to call a method in the backing bean when/before loading a JSF page? Something like a pre-render method before loading a JSF page? I can do that in the backing bean methods that forward to the JSF page, but there are many places that could forward to that JSF page. That's why I trying to do it in the JSF page itself. thanks - Original Message - From: "Ken" <[EMAIL PROTECTED]> To: "MyFaces Discussion" Sent: Wednesday, August 24, 2005 10:17 PM Subject: Re: How to call a method in the backing bean from a JSF page Yes, commandLink and commandButton will render an anchor tag. If you don't want to do this you can do work in your properies getter method when it gets called by outputText value and return an empty string. However, I don't believe there is any guarante as to call order. Putting your target outputText in the first line of your jsp file doesn't mean it will get called before other getter methods further down in the jsp file get called. On 8/24/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: Thanks for your reply, that makes sense. But won't h:commandLink render a link and h:commandButton render a button in the page? I don't want to display anything on the screen. My purpose is to initiate a call from the JSF page to a method in the backing bean when the JSF page loads. I'm returning an empty string from the method so nothing gets printed out from . - Original Message - From: "Ken" <[EMAIL PROTECTED]> To: "MyFaces Discussion" Sent: Wednesday, August 24, 2005 9:53 PM Subject: Re: How to call a method in the backing bean from a JSF page > Try h:commandLink or h:commandButton. > If your method returns a string that doesn't match any navigation-rule > in your faces-confix.xml then the same page you came from will be > rendered again. > > > On 8/24/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: >> >> Hi, >> >> I'm wondering what's the correct way to call a method in the backing >> bean >> from a JSF page. What I tried is to use >> value="#{theBackingBean.theMethod}" />, the backing bean method >> returns >> an >> empty string, so nothing gets printed out in the page. Which works, >> but I >> am >> not sure this is the correct way to do it. >> >> thanks, >> Saul
Re: How to call a method in the backing bean from a JSF page
Thanks for your response. I guess I didn't make me clear here. My question is how to call a method in the backing bean from a JSF page without rendering out anything to the screen. - Original Message - From: "Sean Schofield" <[EMAIL PROTECTED]> To: "MyFaces Discussion" Sent: Wednesday, August 24, 2005 10:04 PM Subject: Re: How to call a method in the backing bean from a JSF page The value attribute should be a *value* binding expression. It must bind to a *property*. So you do something like this ... value=#{theBackingBean.foo}" and in your backing bean you have public String getFoo() { ... } public void setFoo(String fooValue) { ... } sean On 8/24/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: Hi, I'm wondering what's the correct way to call a method in the backing bean from a JSF page. What I tried is to use value="#{theBackingBean.theMethod}" />, the backing bean method returns an empty string, so nothing gets printed out in the page. Which works, but I am not sure this is the correct way to do it. thanks, Saul
Re: How to call a method in the backing bean from a JSF page
This sounds like it may work for me. I never used Shale, so how do I map the backingbean from "fooBar" to "fooBar.jsp" as you mentioned below? in face-config.xml? thanks. > On 8/24/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: >> >> Thanks for your response. I guess I didn't make me clear here. My >> question >> is how to call a method in the backing bean from a JSF page without >> rendering out anything to the screen. > > > > I would suggest using Shale with JSF. Use the Shale jars and then have > your > backing bean implement a ViewController (I just extend > AbstractViewController), and then you'll have several nice methods you can > override. One is called prerender(). So if you map this backingbean to the > correct path, for example "fooBar", when "fooBar.jsp" is called the > prerender method is invoked. That's the ultra simplified explanation and > since I'm new to this, others (Craig) will probably elaborate more. It's > really useful though for exactly what you want. > > > > > -- > Rick >
Why afterPhase(PhaseEvent event) gets called twice
Hi, I implemented a phaseListener to catch phase event. However, every time a jsp page rendered from a backing bean, the afterPhase(PhaseEvent event) method gets called twice, and I get the same viewId by calling facesContext.getViewRoot().getViewId(). Any ideas what the problem is? thanks, Saul
Re: Why afterPhase(PhaseEvent event) gets called twice
Thanks for your response. Yes, I have javax.faces.CONFIG_FILES and faces-config.xml defined in web.xml, I removed that part from web.xml, but still get the same problem. Any ideas? thanks. - Original Message - From: "Jan Bols" <[EMAIL PROTECTED]> To: "MyFaces Discussion" Sent: Thursday, September 08, 2005 2:32 AM Subject: Re: Why afterPhase(PhaseEvent event) gets called twice Perhaps, this comes from the fact that you specify javax.faces.CONFIG_FILES /WEB-INF/faces-config.xml in your web.xml file. The javax.faces.CONFIG_FILES variable is set to /WEB-INF/faces-config.xml by default and specifying it again in web.xml makes the faces-config.xml file to be processed twice (for some raeson I don't know). This results in your registered phaseListener to actually be registered twice as well. The solution is to delete this part in your web.xml or to rename faces_config.xml to something else. Jan On Thu, 08 Sep 2005 03:25:38 +0200, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: Hi, I implemented a phaseListener to catch phase event. However, every time a jsp page rendered from a backing bean, the afterPhase(PhaseEvent event) method gets called twice, and I get the same viewId by calling facesContext.getViewRoot().getViewId(). Any ideas what the problem is? thanks, Saul
Re: Why afterPhase(PhaseEvent event) gets called twice
Yes, I rebuilt my application and cleaned out the work-directory. When I start tomcat, I see phase listener registered only once: DEBUG com.sun.faces.lifecycle.LifecycleImpl - addPhaseListener(RENDER_RESPONSE(6),[EMAIL PROTECTED] thanks, Saul - Original Message - From: "Martin Marinschek" <[EMAIL PROTECTED]> To: "MyFaces Discussion" Sent: Friday, September 09, 2005 5:13 AM Subject: Re: Why afterPhase(PhaseEvent event) gets called twice Sure you cleaned out your application, work-directory, etc.? this clearly is the problem if the PhaseListener is called twice! regards, Martin On 9/9/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: Thanks for your response. Yes, I have javax.faces.CONFIG_FILES and faces-config.xml defined in web.xml, I removed that part from web.xml, but still get the same problem. Any ideas? thanks. - Original Message - From: "Jan Bols" <[EMAIL PROTECTED]> To: "MyFaces Discussion" Sent: Thursday, September 08, 2005 2:32 AM Subject: Re: Why afterPhase(PhaseEvent event) gets called twice > Perhaps, this comes from the fact that you specify > > > javax.faces.CONFIG_FILES > /WEB-INF/faces-config.xml > > > in your web.xml file. The javax.faces.CONFIG_FILES variable is set to > /WEB-INF/faces-config.xml by default and specifying it again in web.xml > makes the faces-config.xml file to be processed twice (for some raeson > I > don't know). This results in your registered phaseListener to actually > be > registered twice as well. > > The solution is to delete this part in your web.xml or to rename > faces_config.xml to something else. > > Jan > > On Thu, 08 Sep 2005 03:25:38 +0200, Saul Qunming Yuan > <[EMAIL PROTECTED]> > wrote: > >> Hi, >> >> I implemented a phaseListener to catch phase event. However, every >> time >> a jsp page rendered from a backing bean, the afterPhase(PhaseEvent >> event) method gets called twice, and I get the same viewId by calling >> facesContext.getViewRoot().getViewId(). Any ideas what the problem is? >> >> thanks, >> Saul >> >> -- http://www.irian.at Your JSF powerhouse - JSF Trainings in English and German
Re: Why afterPhase(PhaseEvent event) gets called twice
Yes, I have a getPhaseId() which returns PhaseId.RENDER_RESPONSE, and the log info prints out twice in my afterPhase method. - Original Message - From: "hicham abassi" <[EMAIL PROTECTED]> To: "MyFaces Discussion" Sent: Sunday, September 11, 2005 3:10 AM Subject: Re: Why afterPhase(PhaseEvent event) gets called twice Try to return a PhaseID constant value into getPhaseId() of your Listener. Do that for each Phase, and check if you have twice call into afterPhase. A simple logger into beforePhase and afterPhase can do the job. 2005/9/10, Saul Qunming Yuan <[EMAIL PROTECTED]>: Yes, I rebuilt my application and cleaned out the work-directory. When I start tomcat, I see phase listener registered only once: DEBUG com.sun.faces.lifecycle.LifecycleImpl - addPhaseListener(RENDER_RESPONSE(6),[EMAIL PROTECTED] thanks, Saul - Original Message - From: "Martin Marinschek" <[EMAIL PROTECTED]> To: "MyFaces Discussion" Sent: Friday, September 09, 2005 5:13 AM Subject: Re: Why afterPhase(PhaseEvent event) gets called twice > Sure you cleaned out your application, work-directory, etc.? > > this clearly is the problem if the PhaseListener is called twice! > > regards, > > Martin > > On 9/9/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: >> Thanks for your response. Yes, I have javax.faces.CONFIG_FILES and >> faces-config.xml defined in web.xml, I removed that part from web.xml, >> but >> still get the same problem. Any ideas? >> >> thanks. >> >> - Original Message - >> From: "Jan Bols" <[EMAIL PROTECTED]> >> To: "MyFaces Discussion" >> Sent: Thursday, September 08, 2005 2:32 AM >> Subject: Re: Why afterPhase(PhaseEvent event) gets called twice >> >> >> > Perhaps, this comes from the fact that you specify >> > >> > >> > javax.faces.CONFIG_FILES >> > /WEB-INF/faces-config.xml >> > >> > >> > in your web.xml file. The javax.faces.CONFIG_FILES variable is set >> > to >> > /WEB-INF/faces-config.xml by default and specifying it again in >> > web.xml >> > makes the faces-config.xml file to be processed twice (for some >> > raeson >> > I >> > don't know). This results in your registered phaseListener to >> > actually >> > be >> > registered twice as well. >> > >> > The solution is to delete this part in your web.xml or to rename >> > faces_config.xml to something else. >> > >> > Jan >> > >> > On Thu, 08 Sep 2005 03:25:38 +0200, Saul Qunming Yuan >> > <[EMAIL PROTECTED]> >> > wrote: >> > >> >> Hi, >> >> >> >> I implemented a phaseListener to catch phase event. However, every >> >> time >> >> a jsp page rendered from a backing bean, the afterPhase(PhaseEvent >> >> event) method gets called twice, and I get the same viewId by >> >> calling >> >> facesContext.getViewRoot().getViewId(). Any ideas what the problem >> >> is? >> >> >> >> thanks, >> >> Saul >> >> >> >> >> >> > > > -- > > http://www.irian.at > Your JSF powerhouse - > JSF Trainings in English and German -- hicham ABASSI [EMAIL PROTECTED]
Which Jar files to use for the nightly build
Hi, I ran into a possible bug with the 1.0.9 build of Myface, the valueChangeListener not gets fired from SelectOneMenu. I wonder if this is a bug. I am now trying to use the nightly build, but what jar files should I use? I used MyFace-all.jar and got the error saying my backing bean is not found when running the application. thanks, Saul
Problem upgrading from MyFaces 1.0.9 to 1.1.0
Hi, I upgraded my application from 1.0.9 to the very latest 1.1.0. I'm getting the following error which I didn't have before. Any idea what the problem could be? thanks, Saul -- exception javax.servlet.ServletException: Base is null: LoginBean javax.faces.webapp.FacesServlet.service(FacesServlet.java:109) root cause javax.faces.el.PropertyNotFoundException: Base is null: LoginBean org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:457) org.apache.myfaces.el.ValueBindingImpl.getType(ValueBindingImpl.java:169) com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:111) javax.faces.component.UIInput.getConvertedValue(UIInput.java:289) javax.faces.component.UIInput.validate(UIInput.java:265) javax.faces.component.UIInput.processValidators(UIInput.java:144) javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:417) javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:417) javax.faces.component.UIForm.processValidators(UIForm.java:68) javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:417) javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:142) org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(LifecycleImpl.java:208) org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76) javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
Possible bug with MyFaces 1.1.0 ?
Hi, I upgraded my app from 1.0.9 to 1.1.0, and my app no longer works. I got a blank screen. I got the following error: java.lang.IllegalStateException: Cannot create a session after the response has been committed at org.apache.catalina.connector.Request.doGetSession(Request.java:2195) at org.apache.catalina.connector.Request.getSession(Request.java:2017) at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:822) at org.apache.myfaces.context.servlet.SessionMap.setAttribute(SessionMap.java:50) at org.apache.myfaces.context.servlet.AbstractAttributeMap.put(AbstractAttributeMap.java:104) at org.apache.myfaces.application.jsp.JspStateManagerImpl.saveSerializedViewInServletSession(JspStateManagerImpl.java:321) at org.apache.myfaces.application.jsp.JspStateManagerImpl.saveSerializedView(JspStateManagerImpl.java:228) at org.apache.myfaces.taglib.core.ViewTag.doEndTag(ViewTag.java:122) at org.apache.jsp.common.headerBodyFooterLayout_jsp._jspx_meth_f_view_0 After a few days tweaking & debugging, I changed the value of the following setting in my web.xml: javax.faces.STATE_SAVING_METHOD from "server" to "client", now my app starts working again. Could this be a bug? thanks, Saul
commandLink not working inside
Hi, I ran into a strange problem with the commandLink inside . It doesn't go to the method in the backing bean when the link is clicked. This had been working well a week ago when my app was on 1.0.9 version. But I run into all kinds of problems including this one ever since I upgraded to 1.1.0. Now I decided to roll back my app to 1.0.9 version. What's strange now, not ALL commandLink links work inside , it works in some pages, but it doesn't in some other pages. This is really frustrating. Any ideas, folks? thanks, Saul
Re: commandLink not working inside
To answer my own question, after adding the following line inside : The commandLink works again. This is on 1.0.9, I didn't try on 1.1.0. I'm still confused though, I didn't have the above code, but commandLink worked as well before I started the upgrading thing. - Original Message ----- From: Saul Qunming Yuan To: MyFaces Discussion Sent: Saturday, September 24, 2005 10:09 AM Subject: commandLink not working inside Hi, I ran into a strange problem with the commandLink inside . It doesn't go to the method in the backing bean when the link is clicked. This had been working well a week ago when my app was on 1.0.9 version. But I run into all kinds of problems including this one ever since I upgraded to 1.1.0. Now I decided to roll back my app to 1.0.9 version. What's strange now, not ALL commandLink links work inside , it works in some pages, but it doesn't in some other pages. This is really frustrating. Any ideas, folks? thanks, Saul
Re: Question
I think that's addressed in the release note, for 1.1.0, it's: http://myfaces.apache.org/RELEASE-NOTES-1.1.0.txt - Original Message - From: "Tali Garsiel" <[EMAIL PROTECTED]> To: "'MyFaces Discussion'" Sent: Sunday, September 25, 2005 8:45 AM Subject: RE: Question Hi, Is there a list of changes made in each revision? Tali -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Werner Punz Sent: Sunday, September 25, 2005 4:06 PM To: users@myfaces.apache.org Subject: Re: Question Best practice probably is, to donate the components so that api changes in tomahawk will be adjusted within your components as well. If that is no option probably trying to program against pure JSF is the safest to keep your codebase stable. But feel free to program against tomahwak, but be prepared to do some adjustment of your codebase from revision to revision. Werner Tali Garsiel wrote: Thanks Werner, So what do you think is the best practice when extending tomahawk ? If you needed to extend - would you use current API and fix in case of change , or avoid extending altogether or some other option? Tali -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Werner Punz Sent: Sunday, September 25, 2005 3:24 PM To: users@myfaces.apache.org Subject: Re: Question You can expect that the JSF 1.1 API wont be changed in the long run however the suite will move towards JSF 1.2 ;-), but the core always has to adobt the standard given from sun. as for the tomahawk components, you cannot really expect a full api stability there some internals can change from one rev to the other, mostly due to bugfixes... (I had such an issue yesterday when I was prepping a component for the sandbox which was originally programmed against 1.0.9) for the sandbox components, there is no api stability whatsoever, those components are alpha or beta if at all, therefore they are called sandbox... Werner Tali Garsiel wrote: Hi, I'm extending some of myfaces components. Can I use the public and protected functions? Can I be sure they will still be there next version? Thanks , Tali __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __ __ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email __
Re: commandLink not working inside
I have been using the request scope all the time. I don't want to use session scope. - Original Message - From: Navid Vahdat To: MyFaces Discussion Sent: Sunday, September 25, 2005 9:59 AM Subject: Re: commandLink not working inside Did you move your CampusSearchBean from session to request scope in the transition from 1.0.9 to 1.1.0? This gave me a lot of headache...Saul Qunming Yuan wrote: To answer my own question, after adding the following line inside : The commandLink works again. This is on 1.0.9, I didn't try on 1.1.0. I'm still confused though, I didn't have the above code, but commandLink worked as well before I started the upgrading thing. - Original Message - From: Saul Qunming Yuan To: MyFaces Discussion Sent: Saturday, September 24, 2005 10:09 AM Subject: commandLink not working inside Hi, I ran into a strange problem with the commandLink inside . It doesn't go to the method in the backing bean when the link is clicked. This had been working well a week ago when my app was on 1.0.9 version. But I run into all kinds of problems including this one ever since I upgraded to 1.1.0. Now I decided to roll back my app to 1.0.9 version. What's strange now, not ALL commandLink links work inside , it works in some pages, but it doesn't in some other pages. This is really frustrating. Any ideas, folks? thanks, Saul
Re: commandLink not working inside
But before I tried upgrading to 1.1.0, commandLink worked for months WITHOUT the following: * put the bean in session scope, * carry around the bean, using t:saveState, * set preserveDataModel to true or I'm not sure what you mean by the 4th codition. My getter to the list just calls a service method to get a collection of data to be presented in the dable. After upgrading to 1.1.0 and then rolled back to 1.0.9, I had to use to make commandLink to work. That's why I'm confused. - Original Message - From: Navid Vahdat To: MyFaces Discussion Cc: [EMAIL PROTECTED] Sent: Sunday, September 25, 2005 10:25 AM Subject: Re: commandLink not working inside CommandLinks are not supposed to work in DataTables with their beans in pure request scope, AFAIK. You either have to * put the bean in session scope, * carry around the bean, using t:saveState, * set preserveDataModel to true or * make the getter to the list you present in the table have direct access to your data source. Otherwise, the datatable can't find it's data in the Apply Request Values Phase and no event is queued.Can anyone correct me, if my understanding is wrong, please?Saul Qunming Yuan wrote: I have been using the request scope all the time. I don't want to use session scope. - Original Message - From: Navid Vahdat To: MyFaces Discussion Sent: Sunday, September 25, 2005 9:59 AM Subject: Re: commandLink not working inside Did you move your CampusSearchBean from session to request scope in the transition from 1.0.9 to 1.1.0? This gave me a lot of headache...Saul Qunming Yuan wrote: To answer my own question, after adding the following line inside : The commandLink works again. This is on 1.0.9, I didn't try on 1.1.0. I'm still confused though, I didn't have the above code, but commandLink worked as well before I started the upgrading thing. - Original Message - From: Saul Qunming Yuan To: MyFaces Discussion Sent: Saturday, September 24, 2005 10:09 AM Subject: commandLink not working inside Hi, I ran into a strange problem with the commandLink inside . It doesn't go to the method in the backing bean when the link is clicked. This had been working well a week ago when my app was on 1.0.9 version. But I run into all kinds of problems including this one ever since I upgraded to 1.1.0. Now I decided to roll back my app to 1.0.9 version. What's strange now, not ALL commandLink links work inside , it works in some pages, but it doesn't in some other pages. This is really frustrating. Any ideas, folks? thanks, Saul
Re: commandLink not working inside
The getter method (let's say method A) to get the data to populate the table is not the method (let's say B) that the commandLink would call. This is the traditional master - detail senario. So when the commandLink is clicked to call method B, it shouldn't care about method A, should it? Are you saying that when I click the commandLink, the getter method A will be called (to re-construct the table, i guess)? or getter method A should return the same data as the first time? - Original Message - From: Navid Vahdat To: MyFaces Discussion Sent: Sunday, September 25, 2005 10:49 AM Subject: Re: commandLink not working inside Saul Qunming Yuan wrote: But before I tried upgrading to 1.1.0, commandLink worked for months WITHOUT the following: * put the bean in session scope, * carry around the bean, using t:saveState, * set preserveDataModel to true or I'm not sure what you mean by the 4th codition. My getter to the list just calls a service method to get a collection of data to be presented in the dable.Actually that's just what i mean. Your getter returns the llist without having to process search/filter criteria first. Thus it is nothing but a facade to the your service. There might be a problem of your data changing in between two requests, though, but in my understanding the commandLink should still work most of the time. After upgrading to 1.1.0 and then rolled back to 1.0.9, I had to use to make commandLink to work. That's why I'm confused.In that case, I'm confused, too.
Re: commandLink not working inside
Thanks Nebojsa & Navid for your reponses, that help a lot. It makes a lot sense now. What's puzzling me is, this is a such a common use case, why it's so complicated to make it to work in JSF. It takes minutes in JSP. I'm now starting another task, ie, opening a popup in JSF. Another few minutes job in JSP, looks like another can of worm in JSF. Well, that's for later. Saul - Original Message - From: Nebojsa Vasiljevic To: MyFaces Discussion Sent: Sunday, September 25, 2005 11:30 AM Subject: Re: commandLink not working inside You are right. If you want to use request scope beans, then you have to restore table model BEFORE action is triggered (before Apply Request Values Phase). If there is attribute var="item" in a dataTable tag, then you can evaluate #{item} in your action: FacesContext.getCurrentInstance().getApplication().createValueBinding("#{item}"). JSF implementation have to initialize "item" variable for the row where you have clicked before it call action method. If the corresponding item does not exists then the action will not be called. There is issue in MyFaces: "This error condition is not reported". If MyFaces reported (at least in log) error or warning like "row 3 not exists in table model", you would be able to track the problem yourself. I suggest Saul Qunming Yuan to consider t:saveState, but to save only minimal values he need to restore a model (like master primary key), not model itself. t:saveState is like a hidden filed, but applied earlier. Also suggest to use session beans sometimes. It is trickily to develop in JSF only with request beans. Nebojsa - Original Message - From: Navid Vahdat To: MyFaces Discussion Cc: [EMAIL PROTECTED] Sent: Sunday, September 25, 2005 5:25 PM Subject: Re: commandLink not working inside CommandLinks are not supposed to work in DataTables with their beans in pure request scope, AFAIK. You either have to * put the bean in session scope, * carry around the bean, using t:saveState, * set preserveDataModel to true or * make the getter to the list you present in the table have direct access to your data source. Otherwise, the datatable can't find it's data in the Apply Request Values Phase and no event is queued.Can anyone correct me, if my understanding is wrong, please?Saul Qunming Yuan wrote: I have been using the request scope all the time. I don't want to use session scope. - Original Message - From: Navid Vahdat To: MyFaces Discussion Sent: Sunday, September 25, 2005 9:59 AM Subject: Re: commandLink not working inside Did you move your CampusSearchBean from session to request scope in the transition from 1.0.9 to 1.1.0? This gave me a lot of headache...Saul Qunming Yuan wrote: To answer my own question, after adding the following line inside : The commandLink works again. This is on 1.0.9, I didn't try on 1.1.0. I'm still confused though, I didn't have the above code, but commandLink worked as well before I started the upgrading thing. - Original Message - From: Saul Qunming Yuan To: MyFaces Discussion Sent: Saturday, September 24, 2005 10:09 AM Subject: commandLink not working inside Hi, I ran into a strange problem with the commandLink inside . It doesn't go to the method in the backing bean when the link is clicked. This had been working well a week ago when my app was on 1.0.9 version. But I run into all kinds of problems including this one ever since I upgraded to 1.1.0. Now I decided to roll back my app to 1.0.9 version. What's strange now, not ALL commandLink links work inside , it works in some pages, but it doesn't in some other pages. This is really frustrating. Any ideas, folks? thanks, Saul
Re: commandLink not working inside
Werner, I think you're right, I guess it'll take some time to get used to thinking in the JSF way. I'll check out the popup library. thanks, Saul - Original Message - From: "Werner Punz" <[EMAIL PROTECTED]> To: Sent: Sunday, September 25, 2005 1:38 PM Subject: Re: commandLink not working inside Well, Saul, golden rule is unfortunately, what you can cover with components usually is very easy in jsf, what you cannot cover with components is rather hard to solve, due to the higher abstraction, there however if you cannot encapsule that stuff in a component for reuse (there is an excellent popup component set on the net btw... link will follow) you always can manually fall back to jsp, which I had to do in any of my projects so far to a small degree, that eases things a lot. The problem is that you ofte are on a higher level and things feel so natural like a real ui in many cases that you instantly thing you have to solve problems the jsf way, which probably cannot be solved in a short time jsf like if you run into them. And then forget that there still is the possibiltiy of a simple jsp fallback) Btw. here is the link to the popup library: http://www.jenia.org/ that should resolve your popup problems in a better way than with jsp. Werner Saul Qunming Yuan wrote: Thanks Nebojsa & Navid for your reponses, that help a lot. It makes a lot sense now. What's puzzling me is, this is a such a common use case, why it's so complicated to make it to work in JSF. It takes minutes in JSP. I'm now starting another task, ie, opening a popup in JSF. Another few minutes job in JSP, looks like another can of worm in JSF. Well, that's for later. Saul
Using Javascript to submit a form doesn't work
Hi all, I'm trying to use _javascript_ to submit a form, the page does refresh, however, it doesn't appear to be a post action, the form inputs don't update the value in the backing bean, none of the setter methods get called. It's like a get action. Any ideas what the problem could be? thanks, Saul
Re: Using Javascript to submit a form doesn't work
Thanks Matt, that's a very good point. But what do I need to do in the Onsubmit handler? I have already set the values to the input fields using Javascript. Just to be clear, here is my use case: 1. The parent window has a "Search" button; 2. When the "Search" button is clicked, it opens a popup window; 3. The user does the search in the popup window, find a list of results; 4. The user clicks a link from the search result which calls a Javascript function to populate some value to the parent window; 5. The Javascript function then calls the parent window's form object to submit (like parentWinForm.submit()) the parent form; 6. Close the Popup window. The issue is: The search did got populated in the parent window, and the parent window did refresh, but the parent window didn't do a post using the populated value from the search. The backing bean's setter methods not called. > Does the form have an onsubmit handler that needs to be called to set any > of > its values? Onsubmit handlers aren't called when you invoke the submit > method on the form object, so you will need to call whatever function it > is > explicitly before the invocation. > > If that's not what it is, then I don't know what to suggest. > > -Matt > > On 9/26/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: >> >> Hi all, >> I'm trying to use Javascript to submit a form, the page does refresh, >> however, it doesn't appear to be a post action, the form inputs don't >> update >> the value in the backing bean, none of the setter methods get called. >> It's >> like a get action. Any ideas what the problem could be? >> thanks, >> Saul >> >
Re: Using Javascript to submit a form doesn't work
Yes, I do have two commandButton there in the parent window. I just populate one id value to the parent window and I see it showing up in the input box before the parent window refreshes. Once the parent window refreshes though, it clears out the value populated in the input box. I'm sure JSF generate a bunch of Javascript code, may be I need to call the onsubmit before calling submit, something like this: parentWinForm.onsubmit(); parentWinForm.submit(); thanks. > (accidentally just replied to the sender, so re-sending to the discussion > group) > > Does the form in the parent window have a submit button? Zhong Li was > right > that you may need at least one submit button in order for it to work > (there's no logical reason why you should, but sometimes the browser gets > testy if you don't). > > If you don't have an onsubmit handler already, you don't need to create > one. > I just thought you might've had one that, due to the way you were > submitting > the form, was not being called. > > Are you sure the search got populated everywhere it needed to be? Is there > any Javascript behind the scenes that isn't being invoked due to the fact > that you're populating the search field via code instead of by typing in > it? > If you're not sure, look at the rendered HTML source for the page, and > check > for hidden fields and Javascript code that you didn't write (i.e., that > must've been rendered by MyFaces). > > -Matt > > On 9/27/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: >> >> Thanks Matt, that's a very good point. But what do I need to do in the >> Onsubmit handler? I have already set the values to the input fields >> using >> Javascript. >> >> Just to be clear, here is my use case: >> >> 1. The parent window has a "Search" button; >> 2. When the "Search" button is clicked, it opens a popup window; >> 3. The user does the search in the popup window, find a list of results; >> 4. The user clicks a link from the search result which calls a >> Javascript >> function to populate some value to the parent window; >> 5. The Javascript function then calls the parent window's form object to >> submit (like parentWinForm.submit()) the parent form; >> 6. Close the Popup window. >> >> The issue is: >> >> The search did got populated in the parent window, and the parent window >> did refresh, but the parent window didn't do a post using the populated >> value from the search. The backing bean's setter methods not called. >> >> >> >> >> > Does the form have an onsubmit handler that needs to be called to set >> any >> > of >> > its values? Onsubmit handlers aren't called when you invoke the submit >> > method on the form object, so you will need to call whatever function >> it >> > is >> > explicitly before the invocation. >> > >> > If that's not what it is, then I don't know what to suggest. >> > >> > -Matt >> > >> > On 9/26/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: >> >> >> >> Hi all, >> >> I'm trying to use Javascript to submit a form, the page does refresh, >> >> however, it doesn't appear to be a post action, the form inputs don't >> >> update >> >> the value in the backing bean, none of the setter methods get called. >> >> It's >> >> like a get action. Any ideas what the problem could be? >> >> thanks, >> >> Saul >> >> >> > >> >> >> >
Re: Using Javascript to submit a form doesn't work [Problem Solved]
Matt, Based on your onsubmit suggestion, I changed my code to submit the form from: document.forms['body:theForm'].submit(); to if(document.forms['body:theForm'].onsubmit) { if(document.forms['body:theForm'].onsubmit()) document.forms['body:theForm'].submit(); } else { document.forms['body:theForm'].submit(); } Now it works! the parent page refreshes with the populated value retained. One strange thing though, I don't see JSF rendering a onsubmit() function inside the form tag. Anyway, it's working. thanks a lot for the help, Matt & whoever responed to the question Saul. - Original Message - From: Matt Blum To: [EMAIL PROTECTED] Cc: MyFaces Discussion Sent: Tuesday, September 27, 2005 12:46 PM Subject: Re: Using _javascript_ to submit a form doesn't work You can see for yourself what the _javascript_ code that's being generated is, just by running the page and using your browser's View Source functionality.If there's an onsubmit handler, the code you list will do exactly what needs to be done. It's possible, though, that there's an onchange handler on the input box (say, that populates a hidden field) that may not be called when the value changes programmatically.-Matt On 9/27/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: Yes, I do have two commandButton there in the parent window. I justpopulate one id value to the parent window and I see it showing up in theinput box before the parent window refreshes. Once the parent windowrefreshes though, it clears out the value populated in the input box. I'm sure JSF generate a bunch of _javascript_ code, may be I need to call theonsubmit before calling submit, something like this:parentWinForm.onsubmit();parentWinForm.submit();thanks.> (accidentally just replied to the sender, so re-sending to the discussion > group)>> Does the form in the parent window have a submit button? Zhong Li was> right> that you may need at least one submit button in order for it to work> (there's no logical reason why you should, but sometimes the browser gets > testy if you don't).>> If you don't have an onsubmit handler already, you don't need to create> one.> I just thought you might've had one that, due to the way you were> submitting > the form, was not being called.>> Are you sure the search got populated everywhere it needed to be? Is there> any _javascript_ behind the scenes that isn't being invoked due to the fact> that you're populating the search field via code instead of by typing in > it?> If you're not sure, look at the rendered HTML source for the page, and> check> for hidden fields and _javascript_ code that you didn't write (i.e., that> must've been rendered by MyFaces). >> -Matt>> On 9/27/05, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote:>>>> Thanks Matt, that's a very good point. But what do I need to do in the >> Onsubmit handler? I have already set the values to the input fields>> using>> _javascript_.>>>> Just to be clear, here is my use case:>>>> 1. The parent window has a "Search" button; >> 2. When the "Search" button is clicked, it opens a popup window;>> 3. The user does the search in the popup window, find a list of results;>> 4. The user clicks a link from the search result which calls a >> _javascript_>> function to populate some value to the parent window;>> 5. The _javascript_ function then calls the parent window's form object to>> submit (like parentWinForm.submit()) the parent form; >> 6. Close the Popup window.>>>> The issue is:>>>> The search did got populated in the parent window, and the parent window>> did refresh, but the parent window didn't do a post using the populated >> value from the search. The backing bean's setter methods not called.>>>>>>>>>> > Does the form have an onsubmit handler that needs to be called to set>> any >> > of>> > its values? Onsubmit handlers aren't called when you invoke the submit>> > method on the form object, so you will need to call whatever function>> it>> > is >> > explicitly before the invocation.>> >>> > If that's not what it is, then I don't know what to suggest.>> >>> > -Matt>> >>> > On 9/26/05, Saul Qunming Yuan < [EMAIL PROTECTED]> wrote:>> >>>> >> Hi all,>> >> I'm trying to use _javascript_ to submit a form, the page does refresh,>> >> however, it doesn't appear to be a post action, the form inputs don't >> >> update>> >> the value in the backing bean, none of the setter methods get called.>> >> It's>> >> like a get action. Any ideas what the problem could be? >> >> thanks,>> >> Saul>> >>>> >>>>>>>>
Re: NotSerializableException
This may not be related, but are you using client to save the state as the following: javax.faces.STATE_SAVING_METHOD client I had to use to use "client" and then ran into a few NotSerializableExceptions in my app, I then had to make my Backing beans and it's member classes all serializable. So, try either changing "client" to "server" for the above setting, or make all you Backing beans and it's member classes serializable. Saul - Original Message - From: Navid Vahdat To: MyFaces Discussion Sent: Thursday, September 29, 2005 2:20 PM Subject: Re: NotSerializableException Just bringing this subject up once more. Somebody able to say something about it?Navid Vahdat wrote: Hi Luca,the relevant JSP code is *: please find the whole JSP attached.editListBean is a session scope bean that holds a dataobject -- a detail of a master/detail relationship. This data object has a type, which can be the below metamodel.ListType it has a name, a description and a couple of other fields. The type is set in the selectDataType Dialog, which is opened with the small looking glass to the right of the output text.Thanks!NavidLuca Conte wrote: Can U post the jsp code? Navid Vahdat ha scritto: Can somebody give me a hand on this? The Exception seems to be connected to using a h:inputhidden with a custom converter. When the value is null, everithing is fine. When the value is set to an object (in this case metamodel.ListType), rendering the page is fine, but triggering a UICommand that is not immediate causes the Exception. I'm stuck. Is this a known bug? Navid Navid Vahdat wrote: Guys, I get this not serializable exception. The exception is correct, because metamodel.ListType, a value in a hidden field with a working converter, definitely is not serializable. Why is myFaces (ver. 1.1.0) trying to serialize it? Thanks, Navid 28.09.2005 10:26:51 org.apache.myfaces.util.StateUtils encode64 SCHWERWIEGEND: Cannot encode Object with Base64 _java.io.NotSerializableException_: metamodel.ListType at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1054_) at java.io.ObjectOutputStream.writeArray(_ObjectOutputStream.java:1224_) at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1050_) at java.io.ObjectOutputStream.writeArray(_ObjectOutputStream.java:1224_) at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1050_) at java.io.ObjectOutputStream.writeArray(_ObjectOutputStream.java:1224_) at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1050_) at java.io.ObjectOutputStream.writeObject(_ObjectOutputStream.java:278_) at java.util.ArrayList.writeObject(_ArrayList.java:529_) at sun.reflect.GeneratedMethodAccessor294.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(_DelegatingMethodAccessorImpl.java:25_) at java.lang.reflect.Method.invoke(_Method.java:324_) at java.io.ObjectStreamClass.invokeWriteObject(_ObjectStreamClass.java:809_) at java.io.ObjectOutputStream.writeSerialData(_ObjectOutputStream.java:1296_) at java.io.ObjectOutputStream.writeOrdinaryObject(_ObjectOutputStream.java:1247_) at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1052_) at java.io.ObjectOutputStream.writeArray(_ObjectOutputStream.java:1224_) at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1050_) at java.io.ObjectOutputStream.writeObject(_ObjectOutputStream.java:278_) at java.util.ArrayList.writeObject(_ArrayList.java:529_) at sun.reflect.GeneratedMethodAccessor294.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(_DelegatingMethodAccessorImpl.java:25_) at java.lang.reflect.Method.invoke(_Method.java:324_) at java.io.ObjectStreamClass.invokeWriteObject(_ObjectStreamClass.java:809_) at java.io.ObjectOutputStream.writeSerialData(_ObjectOutputStream.java:1296_) at java.io.ObjectOutputStream.writeOrdinaryObject(_ObjectOutputStream.java:1247_) at java.io.ObjectOutputStream.
Re: NotSerializableException
Never mind, I didn't go through the followup emails when sending my email out. - Original Message - From: Saul Qunming Yuan To: MyFaces Discussion Sent: Thursday, September 29, 2005 8:07 PM Subject: Re: NotSerializableException This may not be related, but are you using client to save the state as the following: javax.faces.STATE_SAVING_METHOD client I had to use to use "client" and then ran into a few NotSerializableExceptions in my app, I then had to make my Backing beans and it's member classes all serializable. So, try either changing "client" to "server" for the above setting, or make all you Backing beans and it's member classes serializable. Saul - Original Message - From: Navid Vahdat To: MyFaces Discussion Sent: Thursday, September 29, 2005 2:20 PM Subject: Re: NotSerializableException Just bringing this subject up once more. Somebody able to say something about it?Navid Vahdat wrote: Hi Luca,the relevant JSP code is *: please find the whole JSP attached.editListBean is a session scope bean that holds a dataobject -- a detail of a master/detail relationship. This data object has a type, which can be the below metamodel.ListType it has a name, a description and a couple of other fields. The type is set in the selectDataType Dialog, which is opened with the small looking glass to the right of the output text.Thanks!NavidLuca Conte wrote: Can U post the jsp code? Navid Vahdat ha scritto: Can somebody give me a hand on this? The Exception seems to be connected to using a h:inputhidden with a custom converter. When the value is null, everithing is fine. When the value is set to an object (in this case metamodel.ListType), rendering the page is fine, but triggering a UICommand that is not immediate causes the Exception. I'm stuck. Is this a known bug? Navid Navid Vahdat wrote: Guys, I get this not serializable exception. The exception is correct, because metamodel.ListType, a value in a hidden field with a working converter, definitely is not serializable. Why is myFaces (ver. 1.1.0) trying to serialize it? Thanks, Navid 28.09.2005 10:26:51 org.apache.myfaces.util.StateUtils encode64 SCHWERWIEGEND: Cannot encode Object with Base64 _java.io.NotSerializableException_: metamodel.ListType at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1054_) at java.io.ObjectOutputStream.writeArray(_ObjectOutputStream.java:1224_) at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1050_) at java.io.ObjectOutputStream.writeArray(_ObjectOutputStream.java:1224_) at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1050_) at java.io.ObjectOutputStream.writeArray(_ObjectOutputStream.java:1224_) at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1050_) at java.io.ObjectOutputStream.writeObject(_ObjectOutputStream.java:278_) at java.util.ArrayList.writeObject(_ArrayList.java:529_) at sun.reflect.GeneratedMethodAccessor294.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(_DelegatingMethodAccessorImpl.java:25_) at java.lang.reflect.Method.invoke(_Method.java:324_) at java.io.ObjectStreamClass.invokeWriteObject(_ObjectStreamClass.java:809_) at java.io.ObjectOutputStream.writeSerialData(_ObjectOutputStream.java:1296_) at java.io.ObjectOutputStream.writeOrdinaryObject(_ObjectOutputStream.java:1247_) at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1052_) at java.io.ObjectOutputStream.writeArray(_ObjectOutputStream.java:1224_) at java.io.ObjectOutputStream.writeObject0(_ObjectOutputStream.java:1050_) at java.io.ObjectOutputStream.writeObject(_ObjectOutputStream.java:278_) at java.util.ArrayList.writeObject(_ArrayList.java:529_)