[JBoss Seam] - Re: @IfInvalid is out, so?
by SmokingAPipe
What's happening is that the action is being called even though the input is not valid. My thought was that if the object is not valid, the page should re-display, without calling the action, right?
Here's some code:
In test.jsp:
<h:form id="createTestBean">
| <s:validateAll>
| <h:panelGrid columns="3" border="3" >
|
| <h:outputLabel for="foo">
| <h:outputText value="Foo:"/>
| </h:outputLabel>
| <h:inputText id="foo" value="#{testBean.foo}"/>
| <h:message for="foo"/>
|
|
| <h:outputLabel for="bar">
| <h:outputText value="Bar:"/>
| </h:outputLabel>
| <h:inputText id="bar" value="#{testBean.bar}"/>
| <h:message for="bar"/>
|
| </h:panelGrid>
|
| <h:messages globalOnly="false"/>
|
| <h:commandButton value="Create new test bean" action="#{testManager.persist}"/>
| <h:commandButton value="Reset" type="reset"/>
| </s:validateAll>
| </h:form>
And the action:
@Stateful
| @Name("testManager")
| public class TestManagerAction implements TestManager {
| private static final Logger logger =
| Logger.getLogger("TESTMANAGER");
|
|
| /** Creates a new instance of TestAction */
| public TestManagerAction() {
| }
|
| /** This thing is just injected, not created! */
| @In(create=true) EntityManager smpc;
|
| /** This is one to persist */
| @In(create=true) @Out TestBean testBean;
|
| @DataModel
| List<TestBean> testBeans;
|
| @DataModelSelection
| TestBean selectedTestBean;
|
| @Factory("testBeans")
| public void testBeansFactory() {
| if(smpc == null) {
| logger.severe("OH NO! there was no entity manager");
| return;
| }
|
| final Query query = smpc.createQuery("from TestBean t " +
| "order by foo");
| testBeans = query.getResultList();
|
| }
|
| public String persist() {
| if(smpc == null) {
| logger.severe("OH NO! there was no entity manager");
| return null;
| }
|
| smpc.persist(testBean);
| testBean = new TestBean();
|
| return null;
| }
|
| @In(create=true)
| private transient FacesMessages facesMessages;
|
| @Remove @Destroy
| public void destroy() { }
|
| }
|
and the bean itself, boilerplate removed:
@Entity
| @Name("testBean")
| public class TestBean {
|
| private int id;
| @Id @GeneratedValue public int getId() { return id; }
| public void setId(int id) { this.id = id; }
|
| private String foo;
| private String bar;
|
| @Length(min=5,max=8,message="Length must be from 5 to 8 chars bozo")
| public String getFoo() {
| return foo;
| }
|
| public void setFoo(String foo) {
| this.foo = foo;
| }
|
| public String getBar() {
| return bar;
| }
|
| public void setBar(String bar) {
| this.bar = bar;
| }
|
| public String toString() {
| return "TestBean " + id + "; foo= " + foo + ", bar = " + bar;
| }
|
| }
|
Whenever I use the form, if I enter an invalid field, it attempts to do the persist and then throws an exception. What it should do is redisplay the page with the validation message, and not even attempt to persist it. I don't get it.
This is all with Seam 1.1.0 GA and JBoss 4.0.5 GA.
Any ideas on this? It must be something simple I'm missing.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994046#3994046
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994046
19 years, 5 months
[EJB/JBoss] - java.lang.ClassCastException in EJB-Proxy
by tonioc
Hi,
I'm usign 4.0.5/EJB3 and an independent Tomcat 5.5
Ububntu 5-10 java 1.5.08.
Using StatelessSessionBean with a BusinessDelegate as a facade.
The application is a web-service front end to EJB methods, it is
working ok, but:
Every now an then, sometimes after re-deploying, sometimes after
restarting jboss, a call to Business-Method (isUserAuthorized) from
my tomcat application (web-service) gives this error
Caused by: java.lang.ClassCastException: isoa.users.bean.UserContext
| at $Proxy15.isUserAuthorized(Unknown Source)
| at isoa.users.bean.UsersServiceBd$3.run(UsersServiceBd.java:91)
| at isoa.commons.bean.AbstractBizDelegate$EjbRun.runWithRetries(AbstractBizDelegate.java:150)
|
| ... 37 more
| package isoa.users.bean;
|
| // Value-Object for returning multiple values
| public class UserContext implements java.io.Serializable
| {
| public int contractId = -1;
| public int userId = -1;
| public int beingId = -1;
| public int methodId = -1;
| public int serviceId = -1;
| public int implementationId = -1;
| public int hits = -1;
| public Integer pendingHits;
|
| }
|
| // Bean Method
| // It does not return null.
| public UserContext isUserAuthorized(
| String ticket
| ,InetAddress ipAddr
| ,int serviceId
| ,int implementationId
| ,int methodId
| ) throws IsoaException;
|
UserContext class is in the class-path, I checked the version is
always the same in my client and in my server, etc., etc..., all
seems pretty ok.
WebApplication include jars with all the interfaces and implementation
of EJB3 session.
Sometimes after calling the method a second time or just re-deploying begins to work OK again.
Any Idea where to look for, or what is happening
Thanks in advance
tonio
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994041#3994041
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994041
19 years, 5 months
[JBoss Seam] - Re: Can't get Seam managed persistance working in an app sco
by lle
Sorry, forgot to mention that in my jboss-beans.xml, i got this:
| <bean name="gaDatasourceFactory" class="org.jboss.seam.microcontainer.DataSourceFactory">
| <property name="driverClass">com.mysql.jdbc.Driver</property>
| <property name="connectionUrl">jdbc:mysql://localhost:3306/ga_db</property>
| <property name="userName">root</property>
| <property name="password">sadmin</property>
| <property name="jndiName">java:/hibernateDatasource-mysql</property>
| <property name="minSize">0</property>
| <property name="maxSize">10</property>
| <property name="blockingTimeout">1000</property>
| <property name="idleTimeout">100000</property>
| <property name="transactionManager"><inject bean="TransactionManager"/></property>
| </bean>
| <bean name="gaDatasource" class="java.lang.Object">
| <constructor factoryMethod="getDataSource">
| <factory bean="gaDatasourceFactory"/>
| </constructor>
| </bean>
|
and hibernate.cfg.xml:
| <session-factory name="java:/gadb">
| <property name="show_sql">false</property>
| <property name="connection.datasource">java:/hibernateDatasource-mysql</property>
| <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
| <property name="transaction.flush_before_completion">true</property>
| <property name="connection.release_mode">after_statement</property>
| <property name="transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
| <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
| ...
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994040#3994040
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994040
19 years, 5 months