[JBoss Seam] - Re: generating forms programatically
by steshaw
Thanks J! That sounds similar to what I am thinking except that I prefer avoid custom XML and would more than likely build up the configuration (for the Facelets templates to forward to) in code.
Your framework classes are what I am thinking of as my "FormBuilder". They use whatever metadata they can get their hands on but can be overridden where necessary. The "custom facelets resolver" was the missing piece for me. Thanks so much for your post.
If you have time I'd love to hear more about your ideas. Still not sure about the c: logic tags in the "generic renders" - why do you need it? Why do you need to build a renderer?
Have you been able to separate layout from the component tree construction? i.e. can you build a form with metadata and then lay it out in the Facelets template specifying different parts of the form in separate fieldsets for instance? This is the approach taken for the tail end of the article Improving JSF by dumping JSP.
Cheers,
Steve.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109118#4109118
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109118
18 years, 4 months
[JBossCache] - org.jboss.cache.lock.TimeoutException: write lock for / coul
by bmozaffa@redhat.com
Hi all,
I'm trying to use JBoss Cache with optimistic locking as 2nd level cache for hibernate. I have a test case where a multi-threaded client inserts new objects into the database, with a database auto-sequence primary key. My test case passes with no issues when using pessimistic locking, but as soon as I switch to optimistic locking, I get the following:
17:47:25,831 WARN [TreeCache] replication failure with method_call optimisticPrepare; id:18(GlobalTransaction:<172.31.100.1:34099>:14, [_put; id:38(GlobalTransaction:<172.31.100.1:34099>:14, /EntityBean_jar,SimpleEntityBean/com/intuit/spc/bhp/entity/SimpleEntityBean/com.intuit.spc.bhp.entity.SimpleEntityBean#3144, item, CacheEntry(com.intuit.spc.bhp.entity.SimpleEntityBean)[Thu Nov 29 17:47:10 PST 2007,1234567890], true, org.jboss.ejb3.entity.OptimisticJBCCache$DataVersionAdapter@1e3e4c5 [current=Thu Nov 29 17:47:10 PST 2007, previous=null, src=SingleTableEntityPersister(com.intuit.spc.bhp.entity.SimpleEntityBean)])], null, 172.31.100.1:34099, false) exception
org.jboss.cache.lock.TimeoutException: failure acquiring lock: fqn=/, caller=GlobalTransaction:<172.31.100.1:34099>:14, lock=write owner=GlobalTransaction:<172.31.100.1:34101>:14 (activeReaders=0, activeWriter=WorkerThread#3[127.0.0.1:38225], waitingReaders=0, waitingWriters=1, waitingUpgrader=0)
Please note that I have 4 client threads (JMeter) sending requests in through a JSP that calls an SLSB, but there should be no concurrency issue, given that all request amount to database inserts and it's the same entity bean for all of them, thereby making the cache objects peers (one is not the parent of another). The error message implies that the cache is writing or updating something at the root, but I don't know why that would be.
My SLSB code looks like this:
SimpleEntityBean entityBean = new SimpleEntityBean();
entityBean.setTimestamp(Calendar.getInstance().getTime());
em.persist(entityBean);
return entityBean.getId();
Your thoughts / suggestions would be greatly appreciated!
Thanks, Babak
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109116#4109116
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109116
18 years, 4 months
[JBoss Seam] - s:decorate looses form values on validation error
by utiba_davidr
Hey All,
I have been trying to get this to work for the last two days, a little disconcerting. I am sure its something I have done wrong but im not sure what it is. When I use the s:decorate component to display an inline error message, upon displaying the inline error message correctly the forms value is suddenly cleared. Standard input components not wrapped inside a s:decorate do not exhibit this problem so I don't believe its related to page flow or scope, but im not certain what the issue is.
The xhtml page is as follows:
(NB: This isn't the desired form layout, this is an example to prove that s:decorate was the issue and that standard inputText / outputText in a panel worked fine)
| <h:form id="registerAgentForm">
|
| <rich:panel>
| <f:facet name="header">Register Agent</f:facet>
|
| <h:panelGrid columns="2" rowClasses="prop" columnClasses="name,value">
|
| <h:column>
| <h:outputText value="Agent Reference:"/>
| </h:column>
| <h:column>
| <h:inputText id="agentref" value="#{agent.agentReference}" required="true"/>
| <s:decorate for="agentref" template="/WEB-INF/templates/layout/edit.xhtml"/>
| </h:column>
|
| <h:column>
| <h:outputText value="Name:"/>
| </h:column>
| <h:column>
| <h:inputText id="agentname" value="#{agent.name}" required="true"/>
| <s:decorate for="agentname" template="/WEB-INF/templates/layout/edit.xhtml"/>
| </h:column>
|
| </h:panelGrid>
|
| <s:decorate id="nicDecoration" template="/WEB-INF/templates/fragment/edit.xhtml">
| <ui:define name="label">NIC:</ui:define>
| <h:inputText id="nic" value="#{agent.nic}" required="true"/>
| </s:decorate>
|
| <div style="clear:both"/>
| </rich:panel>
|
| <h:commandButton type="submit" value="Register" action="#{manageAgentAction.register}"/>
|
| </h:form>
|
The contents of edit.xhtml (pretty standard implementation) are as follows:
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:s="http://jboss.com/products/seam/taglib">
|
| <div class="prop">
|
| <s:label styleClass="name #{invalid?'errors':''}">
| <ui:insert name="label"/>
| <s:span styleClass="required" rendered="#{required}">*</s:span>
| </s:label>
|
| <span class="value #{invalid?'errors':''}">
| <s:validateAll>
| <ui:insert/>
| </s:validateAll>
| </span>
|
| <s:message styleClass="error errors"/>
|
| </div>
|
| </ui:composition>
|
Thanks in advance!
David
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109114#4109114
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109114
18 years, 4 months
[JBoss Seam] - Handling dynamic data in RDBMS (i.e. no direct column mappin
by tailor
Hi all,
I'm actually a bloody beginner in Seam but somehow managed to succesfully develop my first web app in Seam. Right now I'm trying to solve a problem where I need some further advice.
I have chosen a somewhat dynamic approach to save additional data of a user in the RDBMS. There are four main tables.
user (id, name)
| record (id, user_id)
| data_value (id, record_id, data_type_id, value)
| data_type (id, name, description)
|
| The data_type table is a simple table that holds a list of possible fields so to say where you can save values for. Those values should be saved for a user. Each user has its own record which consists of defined data_types. The relation data_value brings it all together, this is where the actual values for the defined data_values are stored.
|
| According SQL Create-Statements (MySQL): http://pastebin.com/f5883f89d
| According Entity Beans: http://pastebin.com/m501ed44e
|
| I created a SLSB to retrieve a list of "DataValue" objects from the db.
|
| @Stateless
| | @Name("recordList")
| | public class RecordListAction implements RecordList, Serializable {
| |
| | private static final long serialVersionUID = 1L;
| |
| | @PersistenceContext
| | private EntityManager em;
| |
| | @In
| | private User user;
| |
| | @DataModel
| | private List<DataValue> dataValues;
| |
| | // needed to prevent spurious warning
| | // getResultList() returns a non generic version of List
| | @SuppressWarnings("unchecked")
| | @Factory("dataValues")
| | public void getDataValues() {
| | dataValues = em.createQuery(
| | "select dv from DataValue dv "
| | + "inner join dv.record as record "
| | + "inner join dv.dataType as dataType "
| | + "where record.user.id = :userId")
| | .setParameter("userId", user.getId())
| | .getResultList();
| | }
| |
| | @Remove
| | public void destroy() {
| | }
| | }
|
| I am able to output this list in a facelet.
|
| <h:dataTable id="dataValues" var="dataValue" value="#{dataValues}" rendered="#{dataValues.rowCount gt 0}">
| | <h:column>
| | <f:facet name="header">Name</f:facet>
| | <h:outputText value="#{dataValue.dataType.name}" />
| | </h:column>
| | <h:column>
| | <f:facet name="header">Value</f:facet>
| | <h:outputText value="#{dataValue.value}" />
| | </h:column>
| | </h:dataTable>
| And now it comes to the interesting part (finally!). I want to be able to modify (for now; creating and deleting should be integrated later) the "DataValue" objects. Everything I did before was straightforward, i.e. retrieve one row of a table and edit its columns. But now I retrieve one or more rows with two columns (one with the data_type.name and one with the data_value.value) and want to edit them.
|
| I currently do not know where to start solving this problem. Maybe anyone of you can give me some hints to start?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4109113#4109113
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4109113
18 years, 4 months