This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Here, userBean and trip are java beans used in the page. Trip.getDetails is the method in the bean.
But to my surprise even the user id is same as createdBy, the control always goes in the second if condition.
Can anyone let me know what could be the problem in this code?
I tried adding a method in the trip bean called compareValues which takes user id and createdBy and returns a Boolean value after comparing them if they are same.
To call this method form the page I tried adding the following code:
I honestly can't tell where your logic is in error. However, I can make a recommendation.
Stop using JSTL. I have to smile when I see people still trying to think of JSP/Servlet programming when dealing with JSF. You really need to shift your mindset. Logic like you are trying to achieve should all be done in Java code.
What you need to do is determine if all that data needs to be shown. Then add a boolean method in your backing bean to support this. Then your JSF code gets real simple:
See how much better that looks?
Dhananjay Inamdar
Ranch Hand
Joined: Jan 27, 2003
Posts: 130
posted
0
Hi Greg,
Thanks for reply and honest recommendation. I tried it out. I have added the following method in TripMBean.java
Here it is the problem that page is giving me error that I can't call method without prefix.
Will you please guide me how to proceed next?>
Thanks in advance!
Varun Khanna
Ranch Hand
Joined: May 30, 2002
Posts: 1400
posted
0
As Gregg said, avoid using JSTL along with JSF. Things will look cleaner. JSTL and JSF both write to response stream and it does generates dramatic effect at times. "rendered" attribute is good enough to replace c:if tag and even if my code contains html tag along with jsf tag -- i prefer using <div> to show conditional display (i.e. accordian functionality) rather than JSTL for reasons mentioned above.
Ok, let's try this one more time with a bit more code:
JSTL AND JSF ARE A NO NO [ May 15, 2005: Message edited by: Gregg Bolinger ]
Dhananjay Inamdar
Ranch Hand
Joined: Jan 27, 2003
Posts: 130
posted
0
I solved this problem on the second day only. I will like to update you all with my solution. (If anybody interested)
As I mentioned in my problem, I am using one transfer object to display data in table. I wanted to provide hyperlink for all records of logged in user and remaining records I wanted to display read only.
I have a 'logged in username' stored in session and I am getting other user's name from database for every record. I added one more boolean attribute in this transfer object. I am setting this boolean variable true if 'logged in user = user' condition satisfies and else I am setting this value as false. So from back-end to the transfer object my records was setted with proper true/false values.
So if condition stisfies then code execution will render first 2 lines as commandlink and if condition is not satisfaying then code will display only output text.
This satisfied my requirement. I hope it will help somebody in future.
So basically you did what I suggested and called it your solution. Hmm. Well, glad it's working none-the-less. :roll: [ May 31, 2005: Message edited by: Gregg Bolinger ]
Julia Roberts
Greenhorn
Joined: Dec 21, 2005
Posts: 3
posted
0
Hi there, I am trying something similar but it is not working out. I have a datatable in which i need to display a colum conditionally as a commandlink and as a read-only. Here is my code:
But i get the error: 11:49:19,728 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception javax.faces.el.PropertyNotFoundException: Bean: com.daiwausa.cashweb.jsf.mbeans.SIBean, property: isDefault at org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyResolverImpl.java:445) at org.apache.myfaces.el.PropertyResolverImpl.getPropertyDescriptor(PropertyResolverImpl.java:416) at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:379) at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:71) at org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:532) at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145) at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:378) at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:822) at org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:436) at org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427) at org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:448) at org.apache.myfaces.renderkit.html.HtmlTableRendererBase.renderColumnBody(HtmlTableRendererBase.java:195) at org.apache.myfaces.renderkit.html.ext.HtmlTableRenderer.renderColumnBody(HtmlTableRenderer.java:211) at org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeColumnChild(HtmlTableRendererBase.java:168) at org.apache.myfaces.renderkit.html.ext.HtmlTableRenderer.encodeColumnChild(HtmlTableRenderer.java:161) at org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeInnerHtml(HtmlTableRendererBase.java:154) at org.apache.myfaces.renderkit.html.HtmlTableRendererBase.encodeChildren(HtmlTableRendererBase.java:94) at org.apache.myfaces.renderkit.html.ext.HtmlTableRenderer.encodeChildren(HtmlTableRenderer.java:57) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:319) at org.apache.myfaces.renderkit.RendererUtils.renderChild(RendererUtils.java:444) at org.apache.myfaces.renderkit.RendererUtils.renderChildren(RendererUtils.java:427) at org.apache.myfaces.renderkit.html.HtmlGroupRendererBase.encodeEnd(HtmlGroupRendererBase.java:62) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:331) at javax.faces.webapp.UIComponentTag.encodeEnd(UIComponentTag.java:349) at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:253) at org.apache.myfaces.taglib.UIComponentBodyTagBase.doEndTag(UIComponentBodyTagBase.java:55) at org.apache.jsp.defaultmanagement_jsp._jspx_meth_h_panelGroup_0(org.apache.jsp.defaultmanagement_jsp:285) at org.apache.jsp.defaultmanagement_jsp._jspx_meth_h_form_0(org.apache.jsp.defaultmanagement_jsp:235) at org.apache.jsp.defaultmanagement_jsp._jspx_meth_f_view_0(org.apache.jsp.defaultmanagement_jsp:187) at org.apache.jsp.defaultmanagement_jsp._jspService(org.apache.jsp.defaultmanagement_jsp:129) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:810) 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:810) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301) at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:415) at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234) 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)
Please help me
Thanks in advance, Julia
Eddy Lee Sin Ti
Ranch Hand
Joined: Oct 06, 2005
Posts: 135
posted
0
To add some spice, JSF 1.1 or below and JSP are definitely not going well together. Things changed with the arrival of JSF 1.2 and JSP 2.1 where a lot of improvements in place to make the collaboration between JSF and JSP more harmony.
SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
Sushant Bodke
Greenhorn
Joined: Oct 29, 2009
Posts: 1
posted
0
Thanks a lot for the solution, Gregg, I am new to JSF and this really helped!