I have a SFSB that has a save method linked to a save button on my page. I have
@NotNull validation annotations on the entity bean. When I submit the form I
see the error messages appear from the the decorator tags, but the "save" event
handler is still called and the page is reloaded with its original values. My
understanding is that if validation fails on a form, the event handler does not
get called and the invalid values in the form remain, so either I am doing
something wrong, or I misundertand the form validation in SEAM. I believe it
works this way because seam-gen'ed applicaitions do not appear to invoke the
EntityHome.persist() if the form validation fails. When form validation fails
does/should the SFSB method (Event handler) still get called?
Here is the code in question:
Entity Object:
@Entity
| @Table(name = "FBCLIENTTRANS")
| @Name("clientTransmittal")
| public class ClientTransmittalVO {
|
| private int id;
| private Date transdate;
| private String countycode;
| private Integer agentno;
| private String clientfirstname;
| private String clientlastname;
| private String receiptnumber;
| private Integer clientid;
| private ClientVO client;
|
| private Set<ClientTransmittalLineItemVO> clientTransmittalLineItemVOs =
new HashSet<ClientTransmittalLineItemVO>(
| 0);
|
| public ClientTransmittalVO() {
| }
|
| @Id
| @Column(name = "ID", unique = true, nullable = false)
| @NotNull @GeneratedValue
| public int getId() {
| return this.id;
| }
|
| public void setId(int id) {
| this.id = id;
| }
|
| @Temporal(TemporalType.DATE)
| @Basic @Column(name = "TRANSDATE")
| @NotNull
| public Date getTransdate() {
| return this.transdate;
| }
|
| @Column(name = "COUNTYCODE", nullable = false, length = 5)
| @NotNull
| @Length(max = 5)
| public String getCountycode() {
| return this.countycode;
| }
|
| @Column(name = "AGENTNO")
| public Integer getAgentno() {
| return this.agentno;
| }
|
| @Column(name = "CLIENTFIRSTNAME", length = 50)
| @Length(max = 50)
| public String getClientfirstname() {
| return this.clientfirstname;
| }
|
|
| @Column(name = "CLIENTLASTNAME", length = 50)
| @Length(max = 50)
| public String getClientlastname() {
| return this.clientlastname;
| }
|
| @Column(name = "RECEIPTNUMBER", length = 10)
| @Length(max = 10)
| public String getReceiptnumber() {
| return this.receiptnumber;
| }
|
| @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy
= "clientTransmittal")
| public Set<ClientTransmittalLineItemVO> getClientTransmittalLineItems()
{
| return this.clientTransmittalLineItemVOs;
| }
|
| @ManyToOne(cascade = CascadeType.ALL)
| @JoinColumn(name = "CLIENTID", nullable = false)
| @NotNull
| public ClientVO getClient() {
| return client;
| }
|
|
| @Transient
| public void addLineItem(ClientTransmittalLineItemVO lineItem)
| {
| clientTransmittalLineItemVOs.add(lineItem);
| lineItem.setClientTransmittal(this);
| }
|
| @Transient
| public List<ClientTransmittalLineItemVO> getLineItemsList()
| {
| List<ClientTransmittalLineItemVO> list = new
ArrayList<ClientTransmittalLineItemVO>(getClientTransmittalLineItems());
| return list;
|
| }
| }
SFSB:
@Stateful
| @Name("clientTransmittalLineItemAction")
| @Scope(ScopeType.SESSION)
| public class ClientTransmittalLineItemActionImpl implements
| ClientTransmittalLineItemAction {
|
| @In(required=false) @Out(required=false) ClientVO client;
| @In(create=true) private ClientService clientService;
| @In(required=false) @Out(required=false) ClientTransmittalVO
clientTransmittal;
|
| @Out(value="emptyLineItems")
| boolean emptyLineItems=true;
|
| @DataModelSelection
| @Out(required=false, value="lineItem")
| private ClientTransmittalLineItemVO clientTransmittalLineItemx;
|
| @DataModel
| List<ClientTransmittalLineItemVO> lineItems;
|
| @Factory("lineItems")
| public void findLineItems()
| {
|
| long clientId=client.getId();
| ClientVO
client=clientService.findClientByIdFetchGraph(clientId);
| for (ClientTransmittalVO transmittal :
client.getTransmittalsList()) {
| if (transmittal.getId()==clientTransmittal.getId()){
| clientTransmittal=transmittal;
| }
| }
|
| lineItems=clientTransmittal.getLineItemsList();
| emptyLineItems=lineItems.isEmpty();
| }
|
| public String saveClientTransmittal()
| {
|
| ClientVO
clientSave=clientService.findClientByIdFetchGraph(client.getId());
|
| clientSave.addTransmittal(clientTransmittal);
| if (clientTransmittal.getId()>0)
| {
| clientService.saveClient(clientSave);
| client=clientSave;
| return "transUpdated";
| }
| else
| {
| clientService.saveNewClient(clientSave);
| client=clientSave;
| clientTransmittalLineItemx=new
ClientTransmittalLineItemVO();
|
clientTransmittalLineItemx.setClientTransmittal(clientTransmittal);
| //technically a client can have more than one agent. So
this could
| //be a list box, but 99% only have one agent, so
default to the agent number
| //on the first policy.
| Integer agentNumber;
| if (client.getPoliciesList().get(0)!=null)
| {
|
agentNumber=(client.getPoliciesList().get(0).getAgent().getAgentNumber().intValue());
|
clientTransmittalLineItemx.setAgentnumber(agentNumber);
| }
|
|
clientTransmittalLineItemx.setAgentpersonid(client.getId().intValue());
| return "transCreated";
| }
|
| //transmittals=client.getTransmittalsList();
| }
|
| @Remove @Destroy
| public void destroy() {}
|
| }
jsf page:
<!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:a="https://ajax4jsf.dev.java.net/ajax"
| xmlns:rich="http://richfaces.ajax4jsf.org/rich"
| template="layout/frametemplate.xhtml">
|
| <ui:define name="body">
|
| <h:messages globalOnly="true" styleClass="message"
id="globalMessages" />
|
| <h:form id="countytrans" styleClass="edit">
| <s:validateAll>
| <rich:panel>
| <f:facet name="header">Edit
Countytrans</f:facet>
|
| <s:decorate id="idDecoration"
template="layout/edit.xhtml">
| <ui:define
name="label">id</ui:define>
| <h:inputText id="id"
required="true"
|
value="#{clientTransmittal.id}">
| <a:support
event="onblur" reRender="idDecoration" />
| </h:inputText>
| </s:decorate>
|
| <s:decorate id="transdateDecoration"
template="layout/edit.xhtml">
| <ui:define
name="label">transdat</ui:define>
| <h:inputText id="transdate"
size="16"
|
value="#{clientTransmittal.transdate}">
| <s:convertDateTime
pattern="MM/dd/yyyy" />
|
| <a:support
event="onchange" reRender="transdateDecoration"
|
ajaxSingle="true" />
| </h:inputText>
| <s:selectDate for="transdate"
format="MM/dd/yyyy">
| <img
src="images/dtpick.gif" />
| <a:support
event="onclick" reRender="transdateDecoration"
|
ajaxSingle="true" />
| </s:selectDate>
|
| </s:decorate>
|
| <s:decorate id="countycodeDecoration"
template="layout/edit.xhtml">
| <ui:define
name="label">countycode</ui:define>
| <h:inputText id="countycode"
required="true" size="5"
| maxlength="5"
value="#{clientTransmittal.countycode}">
| <a:support
event="onblur" reRender="countycodeDecoration" />
| </h:inputText>
| </s:decorate>
|
| <s:decorate id="agentnoDecoration"
template="layout/edit.xhtml">
| <ui:define
name="label">agentno</ui:define>
| <h:inputText id="agentno"
value="#{clientTransmittal.agentno}">
| <a:support
event="onblur" reRender="agentnoDecoration" />
| </h:inputText>
| </s:decorate>
|
| <s:decorate
id="clientfirstnameDecoration"
| template="layout/edit.xhtml">
| <ui:define
name="label">clientfirstname</ui:define>
| <h:inputText
id="clientfirstname" size="50" maxlength="50"
|
value="#{clientTransmittal.clientfirstname}">
| <a:support
event="onblur" reRender="clientfirstnameDecoration" />
| </h:inputText>
| </s:decorate>
|
| <s:decorate
id="clientlastnameDecoration"
| template="layout/edit.xhtml">
| <ui:define
name="label">clientlastname</ui:define>
| <h:inputText
id="clientlastname" size="50" maxlength="50"
|
value="#{clientTransmittal.clientlastname}">
| <a:support
event="onblur" reRender="clientlastnameDecoration" />
| </h:inputText>
| </s:decorate>
|
| <s:decorate id="receiptnumberDecoration"
| template="layout/edit.xhtml">
| <ui:define
name="label">receiptnumber</ui:define>
| <h:inputText id="receiptnumber"
size="10" maxlength="10"
|
value="#{clientTransmittal.receiptnumber}">
| <a:support
event="onblur" reRender="receiptnumberDecoration" />
| </h:inputText>
| </s:decorate>
|
|
| <div style="clear:both">
| <span class="required">*</span>
required fields
| </div>
|
| </rich:panel>
|
| <div class="actionButtons1">
| <s:button
|
action="#{clientTransmittalLineItemAction.saveClientTransmittal}"
| id="saveTransButton"
value="Save Transmittal">
| </s:button>
| </div>
| </s:validateAll>
| </h:form>
| </ui:define>
|
| </ui:composition>
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4092116#4092116
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4092116
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user