When submitting form: Target Unreachable, identifier 'client' resolved to null
jonfre Jun 30, 2011 4:20 PMI haven't been able to find a solution to this for the last two days, and the deadline is fast approaching. It's a simple page... a Add Client form. When loading it, everything is fine. (I also have a Edit Client form that uses the same JSF but different method, and it loads fine too... with all fields populated.) But when I try to submit the form, I get the Target Unreachable, identifier 'client' resolved to null
error.
Here is the action class:
@Stateful @Name("manageClient") public class ManageClientAction implements ManageClient { @Logger Log log; @In(required=false) @Out private Client client; @Out private boolean editing; @DataModel List<SubClient> subClients; @DataModel List<User> users; public String create() { log.debug("create()"); client = new Client(); client.setStatus(getDefaultStatus()); return "/admin/clients/edit.xhtml"; } public String edit(Client selectedClient) { ... } public String view(Client selectedClient) { ... } public String save() { log.debug("save() invoked!"); if(editing) { ClientDB.save(client); } else { ClientDB.add(client); } return "/admin/clients/view.xhtml"; } public String delete(Client selectedClient) { ... } public String toggleActivation(Client selectedClient) { ... } public String cancel() { log.debug("cancel()"); return ((client != null) && (client.getGuid() != null)) ? "/admin/clients/view.xhtml" : returnToList(); } public String returnToList() { log.debug("returnToList()"); return "/admin/clients/index.xhtml"; } /** * Factory method that finds and returns a {@link List} of possible {@link Status}es to populate the "Status" select box. */ @Factory("validClientStatuses") public List<Status> getValidStatuses() { ... } /** * Utility method that figures and returns the opposite {@link Status} of a given status. * @param status The {@link Status} whose opposite to find and return * @return The opposite status of the one specified */ private Status getOppositeStatus(Status status) { ... } /** * Helper method used to get a default {@link Status} object for the add client screen. * @return A {@link Status} appropriate for being the default */ private Status getDefaultStatus() { ... } @Remove public void remove() {} }
Here is the RichFaces file:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" template="../../layout/template.xhtml"> <ui:define name="body"> <rich:panel> <f:facet name="header">#{editing ? 'Edit' : 'Add'} Client</f:facet> <s:validateAll> <rich:messages layout="table" tooltip="true" showDetail="false" showSummary="true"/> <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value"> <h:outputLabel for="id">Client ID</h:outputLabel> <h:inputText id="id" value="#{client.clientId}" required="true"/> <h:outputLabel for="name">Client Name</h:outputLabel> <h:inputText id="name" value="#{client.name}" required="true"/> <h:outputLabel for="status">Status</h:outputLabel> <h:selectOneMenu id="status" value="#{client.status}" required="true" converter="client.StatusConverter"> <s:selectItems var="_status" value="#{validClientStatuses}" label="#{_status.status}"/> </h:selectOneMenu> </h:panelGrid> <h:outputLabel for="readOnly"> <h:selectBooleanCheckbox id="readOnly" value="#{client.readOnly}"/> Read-only access to all data </h:outputLabel> </s:validateAll> <div> <h:commandButton id="save" value="Save" action="#{manageClient.save}"/> <s:button id="cance" value="Cancel" view="/admin/clients/index.xhtml"/> </div> </rich:panel> </ui:define> </ui:composition>