aspose file tools*
The moose likes JSF and the fly likes Getting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Getting "Base is null" error" Watch "Getting "Base is null" error" New topic
Author

Getting "Base is null" error

Carlo Malones
Greenhorn

Joined: Jul 17, 2012
Posts: 5
hi. i am a beginner in jsp
i have some problems here that i cannot solve,.. i am getting this

javax.servlet.ServletException: Base is null: ViewAuditTrailReports
javax.faces.webapp.FacesServlet.service(FacesServlet.java:154)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

root cause

javax.faces.el.PropertyNotFoundException: Base is null: ViewAuditTrailReports
org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:463)
org.apache.myfaces.el.ValueBindingImpl.getType(ValueBindingImpl.java:175)
org.apache.myfaces.shared_impl.renderkit._SharedRendererUtils.findUIOutputConverter(_SharedRendererUtils.java:58)
org.apache.myfaces.shared_impl.renderkit.RendererUtils.findUIOutputConverter(RendererUtils.java:310)
org.apache.myfaces.shared_impl.renderkit.RendererUtils.getConvertedUIOutputValue(RendererUtils.java:604)
org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.getConvertedValue(HtmlTextRendererBase.java:191)
javax.faces.component.UIInput.getConvertedValue(UIInput.java:396)
javax.faces.component.UIInput.validate(UIInput.java:350)
javax.faces.component.UIInput.processValidators(UIInput.java:184)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:627)
javax.faces.component.UIForm.processValidators(UIForm.java:73)
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:627)
javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:149)
org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:32)
org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

I already declared ViewAuditTrailReports in faces-config.xml

<managed-bean>
<managed-bean-name>ViewAuditTrailReport</managed-bean-name>
<managed-bean-class>ph.com.aeds.web.ui.ViewAuditTrailReports</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

This is my page ViewAuditTrailReports.jsp

<h:panelGrid id="detailsGrid" columns="2" align="center">
<center>
<h:message for="hid_date_from" id="hid_date_from" errorClass="error"/>


<h:message for="hid_date_to" id="hid_date_to" errorClass="error"/>


<h:message for="noexpsel" id="noexpsel" errorClass="error"/>


</center>
<h:selectOneRadio onclick="enableThat(this.value);" id="type" value="ViewAuditTrailReports.sel">
<f:selectItem itemValue="ALL" itemLabel="List ALL:"/><f:selectItem itemValue="Date" itemLabel="Date From:"/><f:selectItem itemValue="User" itemLabel="User Login:"/>

</h:selectOneRadio>
<h:inputText id="date_from" value="#{ViewAuditTrailReports.date_from}" onfocus="showCalendar(this);" onselect="showCalendar(this);" onclick="showCalendar(this);" onmousedown="showCalendar(this);" required="false"/>
<hutputLabel value="Date To:"/>
<h:inputText id="date_to" value="#{ViewAuditTrailReports.date_to}" onfocus="showCalendar(this);" onselect="showCalendar(this);" onclick="showCalendar(this);" onmousedown="showCalendar(this);" required="false"/>
<h:inputText id="User" value="#{ViewAuditTrailReports.log_user_name}"/>
</h:panelGrid>
<center>
<h:commandButton action="report" value="Cancel" styleClass="buttons2" />
<h:commandButton action="#{ViewAuditTrailReport.valid}" value="Retrieve" styleClass="buttons2"/>
</center>

My Bean is ViewAuditTrailReports.java

package ph.com.aeds.web.ui;



import java.util.Calendar;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.swing.JOptionPane;

/**
*
* @author Carlo
*/

public class ViewAuditTrailReports
{
private String date_from;
private String date_to;
private String log_user_name;
private String sel;
private boolean showResults;
public FacesContext ctx = FacesContext.getCurrentInstance();
private Calendar cal_from;
private Calendar cal_to;

public ViewAuditTrailReports()
{
}

{
if (ctx.getExternalContext().getRequestParameterValuesMap().containsKey("cid"))
{
sel = "ALL";
}
}
private String valid()
{
String valid = "d";
ctx = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

date_from = request.getParameter("date_from");
date_to = request.getParameter("date_to");
log_user_name = request.getParameter("User");

JOptionPane.showMessageDialog(null, date_from);
JOptionPane.showMessageDialog(null, date_to);
JOptionPane.showMessageDialog(null, log_user_name);

return "Retrieve";
}


public String getDate_from() {
return date_from;
}

public void setDate_from(String date_from) {
this.date_from = date_from;
}

public String getDate_to() {
return date_to;
}

public void setDate_to(String date_to) {
this.date_to = date_to;
}

public String getLog_user_name() {
return log_user_name;
}

public void setLog_user_name(String log_user_name) {
this.log_user_name = log_user_name;
}

public String getSel() {
return sel;
}

public void setSel(String sel) {
this.sel = sel;
}
}


First I want to know if i can Get the values i need from the page...

Thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

Welcome to the JavaRanch, Carlo! You can make your code and XML samples easier to read using this one simple trick: http://www.coderanch.com/how-to/java/UseCodeTags

You have 2 issues that I can see at a glance.

First, you're not adhering the the JavaBean standard that states that class names start with an upper-case letter, but instance and property names start with a lower-case letter. In other words, your backing bean name should be more like "viewAuditTrailReports ".

Although JSF can deal with that, some functions won't work properly, such as the annotation mechanism, so it's better to follow the standard.

Secondly - and much more importantly - you have defined the bean under one name (ViewAuditTrailReport) and are referring to it under a different name (ViewAuditTrailReports). That extra letter at the end makes all the difference.


Customer surveys are for companies who didn't pay proper attention to begin with.
Carlo Malones
Greenhorn

Joined: Jul 17, 2012
Posts: 5
Thank you for the info.

But after i have done the changes you have said.

like this





and



Then i got This error..
exception

javax.servlet.ServletException: Error calling action method of component with id auditTrailReportForm:_idJsp15
javax.faces.webapp.FacesServlet.service(FacesServlet.java:154)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

root cause

javax.faces.FacesException: Error calling action method of component with id auditTrailReportForm:_idJsp15
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
javax.faces.component.UICommand.broadcast(UICommand.java:109)
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

root cause

javax.faces.el.EvaluationException: Exception while invoking expression #{viewAuditTrailReports.valid}
org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:168)
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
javax.faces.component.UICommand.broadcast(UICommand.java:109)
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

root cause

java.lang.NoSuchMethodException: ph.com.aeds.web.ui.ViewAuditTrailReports.valid()
java.lang.Class.getMethod(Class.java:1605)
org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:121)
org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
javax.faces.component.UICommand.broadcast(UICommand.java:109)
javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

Action methods must be public, not private.

Also, JSF is based on the principle of Inversion of Control. You don't go out and grab the form control values, you define them as properties in the backing bean with public set/get accessor methods which JSF will use to set the values for you.

Finally, you cannot use Swing in any J2EE server-based application.
Carlo Malones
Greenhorn

Joined: Jul 17, 2012
Posts: 5
Thank you.. all the things you are correct...

I am only using the swing for checking out if i got the correct values that i need
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

Instead of Swing, use a logger like the java.util.logging facility or Log4j. In a pinch you can use System.out, but I only recommend that for quick hack jobs, since there's no telling where a given system will route stdio.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting "Base is null" error