[JBoss Seam] - What did I make wrong with s:link????
by german.delacruz
Hi people
I've fighting for a couple of days with a page. In a few words, I've a page that has a datatable, and 2 more sections that are rendered each one depending of the selected action
This is my 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: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"
| template="/WEB-INF/templates/template.xhtml">
|
| <!-- content -->
|
| <ui:define name="content">
| <div class="section">
| <h:form id="searchForm">
| <span class="errors"><h:messages globalOnly="true"/></span>
| <h1>Buscar Padron</h1>
| <fieldset>
| <h:inputText value="#{personController.searchString}" style="width: 165px;"/>
| <h:commandButton value="Buscar Padron" action="personCRUD" styleClass="button"/>
| </fieldset>
| </h:form>
| </div>
|
|
| <div class="section">
| <h:form id="dataTableForm">
| <h:outputText value="No se encontraron datos" rendered="#{model != null and model.rowCount==0}"/>
| <br/>
| <s:link value="Crear nuevo" action="#{personEditor.createEntity}" buttonClass="button" linkStyle="button"/>
| <br/>
| <h:dataTable value="#{model}" var="e" rendered="#{model.rowCount>0}">
| <h:column>
| <f:facet name="header">Razon social</f:facet>
| #{e.razonSocial}
| </h:column>
| <h:column>
| <f:facet name="header">CUIT/CUIL</f:facet>
| #{e.fiscalID}
| </h:column>
| <h:column>
| <f:facet name="header">Action</f:facet>
|
| <h:commandButton action="#{personEditor.displayEntity}" styleClass="button" value="ver"/>
| <h:commandButton action="#{personEditor.updateEntity}" styleClass="button" value="modificar"/>
| <h:commandButton action="#{personEditor.removeEntity}" styleClass="button" value="eliminar"/>
| </h:column>
| </h:dataTable>
| </h:form>
| </div>
|
| <f:subview rendered="#{personEditor.entity!=null and (personEditor.currentOperation=='DISPLAY' or personEditor.currentOperation=='REMOVE') }">
| <div class="section">
| <h1>View Hotel</h1>
| </div>
| <div class="section">
| <div class="entry">
| <div class="label">CUIT/CUIL</div>
| <div class="output">#{personEditor.entity.fiscalID}</div>
| </div>
| <div class="entry">
| <div class="label">Razon Social:</div>
| <div class="output">#{personEditor.entity.razonSocial}</div>
| </div>
| <div class="entry">
| <div class="label">Nombre Completo:</div>
| <div class="output">#{personEditor.entity.completeName}</div>
| </div>
| </div>
| <h:form id="staticForm">
| <div class="entry">
| <div class="label"><f:verbatim> </f:verbatim></div>
| <div class="input">
| <h:commandButton value="Eliminar" action="#{personEditor.perform}" styleClass="button" rendered="#{personEditor.currentOperation=='REMOVE'}"/>
| <s:link value="Volver" action="#{personEditor.cleanState}" buttonClass="button" linkStyle="button"/>
| </div>
| </div>
| </h:form>
| </f:subview>
|
|
| <f:subview rendered="#{personEditor.entity!=null and (personEditor.currentOperation=='UPDATE' or personEditor.currentOperation=='CREATE')}">
| <div class="section">
| <h1>View Hotel</h1>
| </div>
| <h:form id="dynamicForm">
| <s:validateAll>
| <div class="entry">
| <div class="label"><h:outputLabel for="fiscalID">CUIT/CUIL:</h:outputLabel></div>
| <div class="input">
| <h:inputText id="fiscalID" value="#{personEditor.entity.fiscalID}" required="true">
|
| </h:inputText>
| <br/><span class="errors"><h:message for="fiscalID"/></span>
| </div>
| </div>
| <div class="entry">
| <div class="label"><h:outputLabel for="razonSocial">Razon Social</h:outputLabel></div>
| <div class="input">
| <h:inputText id="razonSocial" value="#{personEditor.entity.razonSocial}" required="true">
| </h:inputText>
| <br/><span class="errors"><h:message for="razonSocial"/></span>
| </div>
| </div>
| <div class="entry">
| <div class="label"><h:outputLabel for="completeName">Nombre Completo</h:outputLabel></div>
| <div class="input">
| <h:inputText id="completeName" value="#{personEditor.entity.completeName}" required="true">
| </h:inputText>
| <br/><span class="errors"><h:message for="completeName"/></span>
| </div>
| </div>
| <div class="entry">
| <div class="label"><h:outputLabel for="password">Password:</h:outputLabel></div>
| <div class="input">
| <h:inputSecret id="password" value="#{personEditor.entity.password}" required="true"/><br/>
| <span class="errors"><h:message for="password"/></span>
| </div>
| </div>
| </s:validateAll>
| <div class="entry errors"><h:messages globalOnly="true"/></div>
| <div class="entry">
| <div class="label"><f:verbatim> </f:verbatim></div>
| <div class="input">
| <h:commandButton value="Modificar" action="#{personEditor.perform}" styleClass="button" rendered="#{personEditor.currentOperation=='UPDATE'}"/>
| <h:commandButton value="Crear" action="#{personEditor.perform}" styleClass="button" rendered="#{personEditor.currentOperation=='CREATE'}"/>
|
| <s:link value="Volver" action="#{personEditor.cleanState}" buttonClass="button" linkStyle="button"/>
| </div>
| </div>
| </h:form>
| </f:subview>
|
| </ui:define>
| </ui:composition>
|
As you can see, I've this in my datatable...
| <h:column>
| <f:facet name="header">Action</f:facet>
|
| <h:commandButton action="#{personEditor.displayEntity}" styleClass="button" value="ver"/>
| <h:commandButton action="#{personEditor.updateEntity}" styleClass="button" value="modificar"/>
| <h:commandButton action="#{personEditor.removeEntity}" styleClass="button" value="eliminar"/>
| </h:column>
|
If I use a commandButton, everything works like a charm, but, If I change it with...
| <h:column>
| <f:facet name="header">Action</f:facet>
| [<s:link value="ver" action="#{personEditor.displayEntity}"/>]
| [<s:link value="modificar" action="#{personEditor.updateEntity}"/>]
| [<s:link value="eliminar" action="#{personEditor.removeEntity}"/>]
| </h:column>
|
|
My dataTableSelection in my PersonFinder never loads (It's null always) then, I can't edit, view or update.
I don't know If you need any more information, I think it's a problem in my page! Anyway, I'll show you my actions anyway
| package manchot.actions;
|
| import java.util.List;
|
| import javax.ejb.EJB;
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
|
| import manchot.model.Person;
| import manchot.services.PersonService;
|
| import org.jboss.seam.ScopeType;
| import org.jboss.seam.annotations.Destroy;
| import org.jboss.seam.annotations.Factory;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.annotations.Scope;
| import org.jboss.seam.annotations.datamodel.DataModel;
| import org.jboss.seam.annotations.datamodel.DataModelSelection;
|
| @Name("personFinder")
| @Stateful
| @Scope(ScopeType.EVENT)
| @LoggedIn
| public class PersonFinderBean implements PersonFinder {
|
| @EJB
| private PersonService personService;
|
| @DataModel(scope=ScopeType.PAGE)
| private List<Person> model;
|
| @DataModelSelection
| private Person selected;
|
| @In(create=true)
| private PersonController personController;
|
| @Factory("model")
| public void findModel() {
| model = (personService.findByNameLike(personController.getSearchString()));
| }
|
| public void refresh(){
| findModel();
| }
|
| @Destroy
| @Remove
| public void destroy() {
| }
|
| public Person getSelected() {
| return selected;
| }
| }
|
| package manchot.actions;
|
| import javax.ejb.EJB;
| import javax.ejb.Remove;
| import javax.ejb.Stateful;
| import javax.ejb.TransactionAttribute;
| import javax.ejb.TransactionAttributeType;
|
| import manchot.actions.util.Operations;
| import manchot.model.Person;
| import manchot.services.PersonService;
|
| import org.hibernate.validator.Valid;
| import org.jboss.seam.annotations.Begin;
| import org.jboss.seam.annotations.Destroy;
| import org.jboss.seam.annotations.End;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Name;
|
| @Name("personEditor")
| @Stateful
| @LoggedIn
| public class PersonEditorBean implements PersonEditor {
|
| private Operations currentOperation;
|
| @EJB
| private PersonService personService;
|
| @In(create=true)
| private PersonFinder personFinder;
|
| @Valid
| private Person person;
|
|
| public Operations getCurrentOperation() {
| return currentOperation;
| }
|
| public void setCurrentOperation(Operations currentOperation) {
| this.currentOperation = currentOperation;
| }
|
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public Person getEntity() {
| return person;
| }
|
| public void setEntity(Person entity) {
| this.person = entity;
| }
| @Begin(join=true)
| public String displayEntity() {
| setEntity(personFinder.getSelected());
| currentOperation=Operations.DISPLAY;
| return "personCRUD";
| }
| @Begin(join=true)
| public String updateEntity() {
| setEntity(personFinder.getSelected());
| currentOperation=Operations.UPDATE;
| return "personCRUD";
| }
| @Begin(join=true)
| public String createEntity() {
| setEntity(new Person());
| currentOperation=Operations.CREATE;
| return "personCRUD";
| }
|
| @Begin(join=true)
| public String removeEntity() {
| setEntity(personFinder.getSelected());
| currentOperation=Operations.REMOVE;
| return "personCRUD";
| }
| @End
| public String cleanState() {
| setEntity(null);
| setCurrentOperation(null);
| return "personCRUD";
| }
| @End
| public String perform() {
| if(currentOperation==Operations.REMOVE){
| personService.remove(person);
| }else{
| personService.save(person);
| }
| return cleanState();
| }
|
| @Destroy
| @Remove
| public void destroy() {
| }
| }
|
|
| package manchot.actions;
|
| import javax.ejb.Remove;
|
| @Name("personController")
| @Stateful
| @Scope(ScopeType.SESSION)
| @LoggedIn
| public class PersonControllerBean implements PersonController {
|
| private String searchString="";
|
| public String getSearchString() {
| return searchString;
| }
|
| public void setSearchString(String searchString) {
| this.searchString = searchString;
| }
|
| @Destroy
| @Remove
| public void destroy() {
| }
| }
|
Thanks!!!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963070#3963070
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963070
19 years, 9 months
[JBossCache] - Re: Running POJOCache error
by confuz
"ben.wang(a)jboss.com" wrote : 1. PojoCache does not support pure eviction. That is, it will support pure cache loader (persistency) or passivation (eviction + cacheloading).
|
| 2. Yes.
For point 1 , i wrote following test code
| package org.jboss.cache.passivation;
|
| import java.io.Serializable;
| import java.util.Properties;
|
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.transaction.UserTransaction;
|
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
| import org.jboss.cache.CacheException;
| import org.jboss.cache.Fqn;
| import org.jboss.cache.PropertyConfigurator;
| import org.jboss.cache.aop.PojoCache;
| import org.jboss.cache.data.Address;
| import org.jboss.cache.data.Person;
| import org.jboss.cache.loader.CacheLoader;
| import org.jboss.cache.loader.SamplePojo;
|
| public class AOPTestPassivation1 {
|
| PojoCache cache = null;
| CacheLoader loader = null;
|
| /**
| * @param args
| */
| public static void main(String[] args) throws Exception {
| AOPTestPassivation1 tester = new AOPTestPassivation1();
| tester.start();
| Log log = LogFactory.getLog(AOPTestPassivation1.class);
| long start = System.currentTimeMillis();
| tester.test1();
| System.out.println("/test/1:" + tester.cache.getObject(Fqn.fromString("/test/1")));
| System.out.println("/test/2:" + tester.cache.getObject(Fqn.fromString("/test/2")));
| Thread.sleep(6000);
|
| System.out.println("/test/3:" + tester.cache.getObject(Fqn.fromString("/test/3")));
|
| long end = System.currentTimeMillis();
| System.out.println(end - start);
|
| tester.stop();
| }
|
|
|
| private void test1() throws Exception{
| String key = "key";
| String obj = "obj";
| long start = System.currentTimeMillis();
| long end = System.currentTimeMillis();
| for(int i = 0; i < 1; i ++){
| end = System.currentTimeMillis();
| System.out.println("PPP:" + i + " Time:" + (end-start));
| start = end;
| for(int j = 0; j < 15; j ++){
|
| cache.putObject("/test/"+(i*1000+j), "Object" + i);
| }
| }
| }
|
|
| private void start() throws Exception{
| cache = new PojoCache();
| PropertyConfigurator pc = new PropertyConfigurator();
| pc.configure(cache, "META-INF/aop-tree-service1.xml");
|
| cache.createService();
| cache.startService();
| loader = cache.getCacheLoader();
|
| }
|
|
| private void stop() throws Exception{
| cache.remove("/");
| //loader.remove(Fqn.fromString("/"));
| cache.stopService();
| cache.destroyService();
| }
|
| }
|
| <?xml version="1.0" encoding="UTF-8"?>
|
| <!-- ===================================================================== -->
| <!-- -->
| <!-- Sample TreeCache Service Configuration -->
| <!-- -->
| <!-- ===================================================================== -->
|
| <server>
|
| <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/>
|
|
| <!-- ==================================================================== -->
| <!-- Defines TreeCache configuration -->
| <!-- ==================================================================== -->
|
| <mbean code="org.jboss.cache.aop.PojoCache"
| name="jboss.cache:service=testTreeCache">
|
| <depends>jboss:service=Naming</depends>
| <depends>jboss:service=TransactionManager</depends>
|
| <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute>
|
| <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
|
| <attribute name="CacheMode">REPL_SYNC</attribute>
|
| <attribute name="ClusterName">TreeCache-Cluster</attribute>
|
| <attribute name="InitialStateRetrievalTimeout">20000</attribute>
|
| <attribute name="SyncReplTimeout">15000</attribute>
|
| <attribute name="LockAcquisitionTimeout">10000</attribute>
|
| <attribute name="EvictionPolicyClass">org.jboss.cache.aop.eviction.AopLRUPolicy</attribute>
|
| <attribute name="EvictionPolicyConfig">
| <config>
| <attribute name="wakeUpIntervalSeconds">5</attribute>
| <!-- Cache wide default -->
| <region name="/_default_">
| <attribute name="maxNodes">5000</attribute>
| <attribute name="timeToLiveSeconds">1000</attribute>
| </region>
| <region name="/aop">
| <attribute name="maxNodes">5</attribute>
| <attribute name="timeToLiveSeconds">4</attribute>
| </region>
| <region name="/pojo">
| <attribute name="maxNodes">100</attribute>
| <attribute name="timeToLiveSeconds">4</attribute>
| </region>
| <region name="/test">
| <attribute name="maxNodes">10</attribute>
| <attribute name="timeToLiveSeconds">0</attribute>
| </region>
| </config>
| </attribute>
|
|
| <attribute name="CacheLoaderConfiguration">
| <config>
| <passivation>true</passivation>
|
| <shared>false</shared>
|
| <cacheloader>
| <class>org.jboss.cache.loader.bdbje.BdbjeCacheLoader</class>
| <properties>
| location=c:/tmp/filetore1
| </properties>
| <async>false</async>
|
| <fetchPersistentState>false</fetchPersistentState>
| <ignoreModifications>false</ignoreModifications>
| <purgeOnStartup>false</purgeOnStartup>
| </cacheloader>
|
| </config>
| </attribute>
|
| </mbean>
|
|
| </server>
|
The result is different base on passivation element configureation
1. true output
| /test/1:Object0
| /test/2:Object0
| /test/3:null
|
false output
| /test/1:Object0
| /test/2:Object0
| /test/3:Object0
|
It seems the eviction + cacheloading works base on the passivation configuration value
I check the document for passivation
1. <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
false
2.To enable cache passivation/activation, you can set passivation to true. The default is false. You set it via the XML cache configuration file. The XML above shows the passivation element when configuring a cache loader. When passivation is used, only the first cache loader configured is used. All others are ignored.
how to explain the test result, thanks..
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963068#3963068
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963068
19 years, 9 months