Re: 5.4 Upload / Long Response Issue?

2014-08-29 Thread Lance Java
Put a
try {...} catch (Throwable t)
Around the processing of this large file. Perhaps maven isn't giving jetty
enough memory and it's throwing OutOfMemoryError or something?


How to get current element in mixin

2014-08-29 Thread Michael
I need a mixin which can be attached to different elements (with and
without body). The mixin wraps original element with another and adds some
classes to the original. How I can get current element while render? I'd
use writer.getElement() in render body but its not triggered in components
with empty body. In begin render phase writer returns container instead of
current element.


Re: How to get current element in mixin

2014-08-29 Thread Lance Java
@MixinAfter
public class MyMixin {
   void afterRender(MarkupWriter writer) {
  ListNode children = writer.getElement().getChildren();
  if (!children.isEmpty()) {
 Element lastChild = (Element) children.get(children.size() - 1);
 doStuff(lastChild);
  }
   }
}


[5.4-beta-6] Strange behavior with JSR 303 client-side validation and nested beans

2014-08-29 Thread Christian Dutaret
Hi list,

I'm using JSR-303 annotations. When validating a field from the page class,
it works as expected, and client-side validation is correctly triggered.

Page.java:

   @NotNull
   @Property
   private String firstName;

Page.tml:

  t:form t:id=fill
fieldset
  t:label for=firstName /
  t:textfield t:id=firstName value=firstName/
/fieldset

fieldset
  t:submit /
/fieldset
  /t:form

If I submit the form, client-side validation tells me that first name
should not be empty.

If I try the same, but from a field of a nested bean, then only server-side
validation occurs, not client-side.

Page.java:

   @Property
   private Person person = new Person();

Page.tml:

  t:form t:id=fill validate=person
fieldset
  t:label for=firstName /
  t:textfield t:id=firstName value=person.firstName/
/fieldset

fieldset
  t:submit /
/fieldset
  /t:form

Person.java:

   @NotNull
   private String firstName;

I don' know if this was working with earlier versions.

Christian


Tapestry in distributed environment

2014-08-29 Thread Mugat Gurkowsky
hello,

i am currently using tapestry for a web-project which i am developing. the
project is meant to work with a lot of data, and requires a lot of
processing power.

in order to overcome the problems of so much data and processing-power, i
intend to use distributed calculations, which will be running on
drone-clients which distribute the data as well as the processing.

i would like to be able to use tapestry IoC (especially injections) in the
drone-clients, but i have run into problems with that. in the
documentations i have not seen any way which would make use of Tapestry IoC
from a java-main without the ise of a web-server, so i wanted to ask you
how i could do that best.

thanks in advance for help
zenpunk


RE: Tapestry in distributed environment

2014-08-29 Thread Tony Nelson
All you need to do is build the registry.  This is the shell of a main class 
(in groovy).

@Slf4j
class Main {

static void main(String[] args) {

   // this is the module you wish to load, you may of course add several
RegistryBuilder registryBuilder = new RegistryBuilder();
registryBuilder.add(AtlasImporterModule);

// I keep configs in modules, DevMode, DemoMode, etc
Class clz = Class.forName(com.starpoint.instihire.api.services. +
StringUtils.capitalize(config.env) + Mode);
registryBuilder.add(clz);

Registry registry = registryBuilder.build();
registry.performRegistryStartup();

// registry is up
SomeService svc = registry.getService(SomeService)
   svc.doSomething();

   // shut down the registry when you are done
registry.shutdown();
}
}


Hope that helps

Tony
ps.  I apologize in advance if the formatting gets messed up, I am sending this 
from a web based mail.

From: Mugat Gurkowsky [zenpunk...@gmail.com]
Sent: Friday, August 29, 2014 7:39 AM
To: users@tapestry.apache.org
Subject: Tapestry in distributed environment

hello,

i am currently using tapestry for a web-project which i am developing. the
project is meant to work with a lot of data, and requires a lot of
processing power.

in order to overcome the problems of so much data and processing-power, i
intend to use distributed calculations, which will be running on
drone-clients which distribute the data as well as the processing.

i would like to be able to use tapestry IoC (especially injections) in the
drone-clients, but i have run into problems with that. in the
documentations i have not seen any way which would make use of Tapestry IoC
from a java-main without the ise of a web-server, so i wanted to ask you
how i could do that best.

thanks in advance for help
zenpunk

Since 1982, Starpoint Solutions has been a trusted source of human capital and 
solutions. We are committed to our clients, employees, environment, community 
and social concerns.  We foster an inclusive culture based on trust, respect, 
honesty and solid performance. Learn more about Starpoint and our social 
responsibility at http://www.starpoint.com/social_responsibility

This email message from Starpoint Solutions LLC is for the sole use of  the 
intended recipient(s) and may contain confidential and privileged  information. 
 Any unauthorized review, use, disclosure or distribution is prohibited.  If 
you are not the intended recipient, please contact the sender by reply email 
and destroy all copies of the original message.  Opinions, conclusions and 
other information in this message that do not relate to the official business 
of Starpoint Solutions shall be understood as neither given nor endorsed by it.

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: 5.4 Upload / Long Response Issue?

2014-08-29 Thread Michael Gentry
H Lance,

There were no exceptions and I was using VisualVM to monitor the
heap/GCs/etc and there was plenty of memory available, even when processing
both threads.  (About 150-200MB used out of 1GB allocated.)

mrg



On Fri, Aug 29, 2014 at 3:17 AM, Lance Java lance.j...@googlemail.com
wrote:

 Put a
 try {...} catch (Throwable t)
 Around the processing of this large file. Perhaps maven isn't giving jetty
 enough memory and it's throwing OutOfMemoryError or something?



Re: How to get current element in mixin

2014-08-29 Thread Thiago H de Paula Figueiredo
There's another solution, but it just works when the component is a  
ClientElement:


@MixinAfter
public class MyMixin {

@InjectContainer
private ClientElement clientElement;

void afterRender(MarkupWriter writer) {
Element element = 
writer.getElementById(clientElement.getClientId());
}

}

I have not tested the code above.

On Fri, 29 Aug 2014 06:04:18 -0300, Lance Java lance.j...@googlemail.com  
wrote:



@MixinAfter
public class MyMixin {
   void afterRender(MarkupWriter writer) {
  ListNode children = writer.getElement().getChildren();
  if (!children.isEmpty()) {
 Element lastChild = (Element) children.get(children.size() - 1);
 doStuff(lastChild);
  }
   }
}



--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: [5.4-beta-6] Strange behavior with JSR 303 client-side validation and nested beans

2014-08-29 Thread Thiago H de Paula Figueiredo
On Fri, 29 Aug 2014 06:41:26 -0300, Christian Dutaret  
cdtapes...@gmail.com wrote:



Hi list,


Hi!

Have you tried one of the latest betas, available in the Apache Maven  
staging repository? I recall fixing something like that.


I'm using JSR-303 annotations. When validating a field from the page  
class,

it works as expected, and client-side validation is correctly triggered.

Page.java:

   @NotNull
   @Property
   private String firstName;

Page.tml:

  t:form t:id=fill
fieldset
  t:label for=firstName /
  t:textfield t:id=firstName value=firstName/
/fieldset

fieldset
  t:submit /
/fieldset
  /t:form

If I submit the form, client-side validation tells me that first name
should not be empty.

If I try the same, but from a field of a nested bean, then only  
server-side

validation occurs, not client-side.

Page.java:

   @Property
   private Person person = new Person();

Page.tml:

  t:form t:id=fill validate=person
fieldset
  t:label for=firstName /
  t:textfield t:id=firstName value=person.firstName/
/fieldset

fieldset
  t:submit /
/fieldset
  /t:form

Person.java:

   @NotNull
   private String firstName;

I don' know if this was working with earlier versions.

Christian



--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Setup integration test with testng and tapestry services.

2014-08-29 Thread George Christman
Hi everyone, I'm trying to setup integration test with testng and tapestry
services. Lance kindly helped me get some of this up and running on my
personal project, but my day job is requiring a little bit more. So far I
have the following code. but experiencing the following two issues.

Issue 1. (SerializationSupport.java:38) - Setting a new service proxy
provider when there's already an existing provider. This may indicate that
you have multiple IoC Registries. (I'm aware of the cause, I just don't
know how to fix it)
Issue 2. The h2 in mem database doesn't clear between test, is there a way
to clear the data without having to session.delete() the content manually?

public class AppModuleTest {

public static void bind(ServiceBinder binder) {
binder.bind(SearchService.class, SearchServiceImpl.class);
binder.bind(UserInfoService.class, UserInfoServiceImpl.class);
}

public static Messages buildMessages() {
return Mockito.mock(Messages.class);
}

public static Request buildRequest() {
Request request = Mockito.mock(Request.class);
when(request.isXHR()).thenReturn(false);
return request;
}

public static void
contributeHibernateSessionSource(OrderedConfigurationHibernateConfigurer
configuration) {
configuration.add(test, new TestHibernateConfigurer());
configuration.addInstance(test, ETSSHibernateConfigurer.class);
}

public static void
contributeHibernateEntityPackageManager(org.apache.tapestry5.ioc.ConfigurationString
config) {
config.add(org.healthresearch.etss.entities);
}

@Scope(ScopeConstants.PERTHREAD)
public static FullTextSession
buildFullTextSession(HibernateSessionManager sessionManager) {
return Search.getFullTextSession(sessionManager.getSession());
}

public static void
contributeApplicationDefaults(MappedConfigurationString, Object config) {
config.add(HibernateSymbols.DEFAULT_CONFIGURATION, false);
}

}


public class TestHibernateConfigurer implements HibernateConfigurer {

@Override
public void configure(Configuration config) {
config.setProperty(hibernate.dialect,
org.hibernate.dialect.H2Dialect);
config.setProperty(hibernate.connection.driver_class,
org.h2.Driver);
config.setProperty(hibernate.connection.url, jdbc:h2:mem:test);
config.setProperty(hibernate.hbm2ddl.auto, update);
config.setProperty(hibernate.show_sql, false);
config.setProperty(hibernate.format_sql, true);
config.setProperty(hibernate.hbm2ddl.import_files, xxx);
config.setProperty(hibernate.search.default.directory_provider,
RAMDirectoryProvider.class.getName());
}

}


public abstract class AbstractHibernateTest {

private HibernateSessionManager sessionManager;
private SearchService searchService;
private Session session;

@BeforeClass
public void abstractBefore() {
System.out.println(abstractBefore);
Registry registry =
RegistryBuilder.buildAndStartupRegistry(AppModuleTest.class,
HibernateCoreModule.class);
this.sessionManager =
registry.getService(HibernateSessionManager.class);
this.searchService = registry.getService(SearchService.class);
this.session = sessionManager.getSession();
before(registry);
}

protected abstract void before(Registry registry) ;

public HibernateSessionManager getSessionManager() {
return sessionManager;
}

public Session getSession() {
return session;
}

public SearchService getSearchService() {
return searchService;
}

public void setDelete(Object object) {
session.delete(object);
sessionManager.commit();
}

public int getResultSize(Class? clazz) {
return session.createCriteria(clazz).list().size();
}

public void getCommit() {
session.flush();
sessionManager.commit();
}

}


public class SampleTest extends AbstractHibernateTest {

@Override
public void before(Registry registry) {
}

@Test
public void testDatabase() {
UserProfile userProfile = new UserProfile();
userProfile.setShortname(gmc07);
getSession().save(userProfile);

getCommit();

assertEquals(getResultSize(UserProfile.class), 1);

setDelete(userProfile);

assertEquals(getResultSize(UserProfile.class), 0);

}

}


public class ProfileTest extends AbstractHibernateTest {

@Override
protected void before(Registry registry) {
}

@Test
private void firstTest() {
UserProfile userProfile = new UserProfile();
userProfile.setShortname(jrr06);
getSession().save(userProfile);
getCommit();

getResultSize(UserProfile.class);
assertEquals(getResultSize(UserProfile.class), 1);

FullTextQuery query = getSearchService().search(UserProfile.class,
jrr06, 

Re: Tapestry in distributed environment

2014-08-29 Thread Daniel Jue
Another good place to look is in any of the unit or integration tests for
frameworks or apps that use Tapestry.  You often want to start up a
registry there so you can import modules to wire up DAOs, services, etc.


On Fri, Aug 29, 2014 at 8:50 AM, Thiago H de Paula Figueiredo 
thiag...@gmail.com wrote:

 On Fri, 29 Aug 2014 08:39:50 -0300, Mugat Gurkowsky zenpunk...@gmail.com
 wrote:

  hello,


 Hi!


  i would like to be able to use tapestry IoC (especially injections) in
 the drone-clients, but i have run into problems with that. in the
 documentations i have not seen any way which would make use of Tapestry
 IoC from a java-main without the ise of a web-server, so i wanted to ask you
 how i could do that best.


 Have you seen http://tapestry.apache.org/starting-the-ioc-registry.html?
 :D

 --
 Thiago H. de Paula Figueiredo
 Tapestry, Java and Hibernate consultant and developer
 http://machina.com.br


 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




Re: Tapestry in distributed environment

2014-08-29 Thread Daniel Jue
For instance, in my project, see this BeforeSuite annotated method:

https://github.com/Sotera/graphene/blob/master/graphene-parent/graphene-util/src/test/java/graphene/util/fs/PropertiesFileSymbolProviderTest.java


On Fri, Aug 29, 2014 at 10:24 AM, Daniel Jue teamp...@gmail.com wrote:

 Another good place to look is in any of the unit or integration tests for
 frameworks or apps that use Tapestry.  You often want to start up a
 registry there so you can import modules to wire up DAOs, services, etc.


 On Fri, Aug 29, 2014 at 8:50 AM, Thiago H de Paula Figueiredo 
 thiag...@gmail.com wrote:

 On Fri, 29 Aug 2014 08:39:50 -0300, Mugat Gurkowsky zenpunk...@gmail.com
 wrote:

  hello,


 Hi!


  i would like to be able to use tapestry IoC (especially injections) in
 the drone-clients, but i have run into problems with that. in the
 documentations i have not seen any way which would make use of Tapestry
 IoC from a java-main without the ise of a web-server, so i wanted to ask you
 how i could do that best.


 Have you seen http://tapestry.apache.org/starting-the-ioc-registry.html?
 :D

 --
 Thiago H. de Paula Figueiredo
 Tapestry, Java and Hibernate consultant and developer
 http://machina.com.br


 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org





Re: [5.4-beta-6] Strange behavior with JSR 303 client-side validation and nested beans

2014-08-29 Thread Christian Dutaret
Hi Thiago,

Switched to beta-16 and yes it is fixed.
Thanks

Christian


2014-08-29 15:01 GMT+02:00 Thiago H de Paula Figueiredo thiag...@gmail.com
:

 On Fri, 29 Aug 2014 06:41:26 -0300, Christian Dutaret 
 cdtapes...@gmail.com wrote:

  Hi list,


 Hi!

 Have you tried one of the latest betas, available in the Apache Maven
 staging repository? I recall fixing something like that.


  I'm using JSR-303 annotations. When validating a field from the page
 class,
 it works as expected, and client-side validation is correctly triggered.

 Page.java:

@NotNull
@Property
private String firstName;

 Page.tml:

   t:form t:id=fill
 fieldset
   t:label for=firstName /
   t:textfield t:id=firstName value=firstName/
 /fieldset

 fieldset
   t:submit /
 /fieldset
   /t:form

 If I submit the form, client-side validation tells me that first name
 should not be empty.

 If I try the same, but from a field of a nested bean, then only
 server-side
 validation occurs, not client-side.

 Page.java:

@Property
private Person person = new Person();

 Page.tml:

   t:form t:id=fill validate=person
 fieldset
   t:label for=firstName /
   t:textfield t:id=firstName value=person.firstName/
 /fieldset

 fieldset
   t:submit /
 /fieldset
   /t:form

 Person.java:

@NotNull
private String firstName;

 I don' know if this was working with earlier versions.

 Christian



 --
 Thiago H. de Paula Figueiredo
 Tapestry, Java and Hibernate consultant and developer
 http://machina.com.br

 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org




Re: Select with delimiters

2014-08-29 Thread squallmat .
I mean having different object types in a select, each titled by a field
not associated with any object that make differentiation of the different
types of object in the select.


2014-08-25 18:19 GMT+02:00 Lance Java lance.j...@googlemail.com:

 Im not entirely sure what you mean by a delimeter here? Are you talking
 about the optgroup tag inside select?
 If so, you can use SelectModel.getOptionGroups()

 http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/SelectModel.html#getOptionGroups()

 Or are you wanting to add your own custom html (images etc) to the option
 label?



 On 25 August 2014 15:55, squallmat . squall...@gmail.com wrote:

  Hi,
 
  As said in title, I would like to know if it's possible to add special
  values in a select list of objects, that are not bind to encoder like
 the
  blank one, I need to add a delimitation in the list of my entities to
  select.
 
  Thanks.
 



Re: Select with delimiters

2014-08-29 Thread Thiago H de Paula Figueiredo
On Fri, 29 Aug 2014 11:55:01 -0300, squallmat . squall...@gmail.com  
wrote:



I mean having different object types in a select, each titled by a field
not associated with any object that make differentiation of the different
types of object in the select.


Implement your own OptionModel and use whatever you want for label and  
value and then pass them to a SelectModel.


--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Setup integration test with testng and tapestry services.

2014-08-29 Thread Kalle Korhonen
To nuke the H2 db, this is what I use (it's JPA, adjust for Hibernate):

// based on
http://www.objectpartners.com/2010/11/09/unit-testing-your-persistence-tier-code/
public void clearDatabase() throws SQLException {
EntityTransaction transaction = em.getTransaction();
if (!transaction.isActive()) transaction.begin();
Connection c = em.unwrap(Connection.class);
Statement s = c.createStatement();
s.execute(SET REFERENTIAL_INTEGRITY FALSE);
SetString tables = new HashSetString();
ResultSet rs = s.executeQuery(select table_name  + from
INFORMATION_SCHEMA.tables 
+ where table_type='TABLE' and table_schema='PUBLIC');
while (rs.next()) {
// if we don't skip over the sequence table, we'll start
getting The sequence table information is not complete
// exceptions
if (!rs.getString(1).startsWith(DUAL_) 
!rs.getString(1).equals(SEQUENCE)) {
tables.add(rs.getString(1));
}
}
rs.close();
for (String table : tables) {
s.executeUpdate(DELETE FROM  + table);
}
transaction.commit();
s.execute(SET REFERENTIAL_INTEGRITY TRUE);
s.close();
}

Kalle


On Fri, Aug 29, 2014 at 6:14 AM, George Christman gchrist...@cardaddy.com
wrote:

 Hi everyone, I'm trying to setup integration test with testng and tapestry
 services. Lance kindly helped me get some of this up and running on my
 personal project, but my day job is requiring a little bit more. So far I
 have the following code. but experiencing the following two issues.

 Issue 1. (SerializationSupport.java:38) - Setting a new service proxy
 provider when there's already an existing provider. This may indicate that
 you have multiple IoC Registries. (I'm aware of the cause, I just don't
 know how to fix it)
 Issue 2. The h2 in mem database doesn't clear between test, is there a way
 to clear the data without having to session.delete() the content manually?

 public class AppModuleTest {

 public static void bind(ServiceBinder binder) {
 binder.bind(SearchService.class, SearchServiceImpl.class);
 binder.bind(UserInfoService.class, UserInfoServiceImpl.class);
 }

 public static Messages buildMessages() {
 return Mockito.mock(Messages.class);
 }

 public static Request buildRequest() {
 Request request = Mockito.mock(Request.class);
 when(request.isXHR()).thenReturn(false);
 return request;
 }

 public static void
 contributeHibernateSessionSource(OrderedConfigurationHibernateConfigurer
 configuration) {
 configuration.add(test, new TestHibernateConfigurer());
 configuration.addInstance(test, ETSSHibernateConfigurer.class);
 }

 public static void

 contributeHibernateEntityPackageManager(org.apache.tapestry5.ioc.ConfigurationString
 config) {
 config.add(org.healthresearch.etss.entities);
 }

 @Scope(ScopeConstants.PERTHREAD)
 public static FullTextSession
 buildFullTextSession(HibernateSessionManager sessionManager) {
 return Search.getFullTextSession(sessionManager.getSession());
 }

 public static void
 contributeApplicationDefaults(MappedConfigurationString, Object config) {
 config.add(HibernateSymbols.DEFAULT_CONFIGURATION, false);
 }

 }


 public class TestHibernateConfigurer implements HibernateConfigurer {

 @Override
 public void configure(Configuration config) {
 config.setProperty(hibernate.dialect,
 org.hibernate.dialect.H2Dialect);
 config.setProperty(hibernate.connection.driver_class,
 org.h2.Driver);
 config.setProperty(hibernate.connection.url, jdbc:h2:mem:test);
 config.setProperty(hibernate.hbm2ddl.auto, update);
 config.setProperty(hibernate.show_sql, false);
 config.setProperty(hibernate.format_sql, true);
 config.setProperty(hibernate.hbm2ddl.import_files, xxx);
 config.setProperty(hibernate.search.default.directory_provider,
 RAMDirectoryProvider.class.getName());
 }

 }


 public abstract class AbstractHibernateTest {

 private HibernateSessionManager sessionManager;
 private SearchService searchService;
 private Session session;

 @BeforeClass
 public void abstractBefore() {
 System.out.println(abstractBefore);
 Registry registry =
 RegistryBuilder.buildAndStartupRegistry(AppModuleTest.class,
 HibernateCoreModule.class);
 this.sessionManager =
 registry.getService(HibernateSessionManager.class);
 this.searchService = registry.getService(SearchService.class);
 this.session = sessionManager.getSession();
 before(registry);
 }

 protected abstract void before(Registry registry) ;

 public HibernateSessionManager getSessionManager() {
 return sessionManager;
 }

 public Session getSession() {
 return session;
 }


Re: Setup integration test with testng and tapestry services.

2014-08-29 Thread Lance Java
You should call registry.shutdown() in @AfterClass and
registry.cleanupThread() in @After.


kaptchafield won't validate after zone rerender

2014-08-29 Thread John
Hi,

I have t:kaptchaimage and t:kaptchafield in a form within a zone of a component.

After I rerender the zone if there is a error on the form, the kaptchaimage 
stays the same and teh validation always fails.

If I refresh the page and get a new kaptchaimage and get the answer right first 
time it works ok, otherwise I get stuck with Enter the text displayed in the 
image.

Is this a known bug or perhaps something I did wrong?

John

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


Re: Setup integration test with testng and tapestry services.

2014-08-29 Thread George Christman
Thanks guys for your input.

Lance, I tried the following configuration without success, but then tried
the second configuration and succeeded. Could you take a quick peak to be
sure I'm doing it correctly.

-- cleanup in @AfterMethod = This failed with the following exception
Failed: org.hibernate.SessionException: Session is closed
-- cleanup in @AfterTest = Failed:java.lang.IllegalStateException: Method
org.apache.tapestry5.ioc.internal.RegisteryImpl.cleanupThread(RegistryImpl.java.519)
may no longer be involked

-- I found success moving before to @BeforeMethod and moving registry
shutdown into @AfterMethod.

public class RegistryBuilderTest {

protected final Registry buildRegistry(Class... moduleClasses) {
RegistryBuilder builder = new RegistryBuilder();
builder.add(moduleClasses);
return builder.build();
}

}

public class SampleTest extends RegistryBuilderTest {

private Registry registry;
private HibernateSessionManager sessionManager;
private Session session;

@BeforeClass
protected void before() {
registry = buildRegistry(AppModuleTest.class,
HibernateCoreModule.class);
sessionManager = registry.getService(HibernateSessionManager.class);
session = sessionManager.getSession();
}

@Test
public void test1() {
System.out.println(test1);
UserProfile userProfile = new UserProfile();
userProfile.setShortname(test1);
session.save(userProfile);

session.flush();
sessionManager.commit();

assertEquals(getResultSize(UserProfile.class), 1);

}

@Test
public void test2() {
System.out.println(test2);
UserProfile userProfile = new UserProfile();
userProfile.setShortname(test2);
session.save(userProfile);

session.flush();
sessionManager.commit();

assertEquals(getResultSize(UserProfile.class), 1);

}

public int getResultSize(Class? clazz) {
return session.createCriteria(clazz).list().size();
}

@AfterClass
public void shutDown() {
System.out.println(shutDown);
registry.shutdown();
}

@AfterMethod
public void cleanupThread() {
System.out.println(cleanupThread);
registry.cleanupThread();
}

}





 Working configuration 


public class SampleTest extends RegistryBuilderTest {


private Registry registry;
private HibernateSessionManager sessionManager;
private Session session;

@BeforeMethod
protected void before() {
registry = buildRegistry(AppModuleTest.class,
HibernateCoreModule.class);
sessionManager = registry.getService(HibernateSessionManager.class);
session = sessionManager.getSession();
}

@Test
public void test1() {
System.out.println(test1);
UserProfile userProfile = new UserProfile();
userProfile.setShortname(test1);
session.save(userProfile);

session.flush();
sessionManager.commit();

assertEquals(getResultSize(UserProfile.class), 1);
}

@Test
public void test2() {
System.out.println(test2);
UserProfile userProfile = new UserProfile();
userProfile.setShortname(test2);
session.save(userProfile);

session.flush();
sessionManager.commit();

assertEquals(getResultSize(UserProfile.class), 1);
}

public int getResultSize(Class? clazz) {
return session.createCriteria(clazz).list().size();
}

@AfterMethod
public void cleanupThread() {
System.out.println(cleanupThread);
registry.cleanupThread();
registry.shutdown();
}

}



On Fri, Aug 29, 2014 at 11:33 AM, Lance Java lance.j...@googlemail.com
wrote:

 From the h2 docs here:
 http://www.h2database.com/html/features.html#in_memory_databases

 In some cases, only one connection to a in-memory database is required.
 This means the database to be opened is private. In this case, the database
 URL is jdbc:h2:mem: Opening two connections within the same virtual machine
 means opening two different (private) databases.

 Sometimes multiple connections to the same in-memory database are required.
 In this case, the database URL must include a name. Example:
 jdbc:h2:mem:db1. Accessing the same database using this URL only works
 within the same virtual machine and class loader environment.

 So, if you use a connection url of jdbc:h2:mem: AND you make sure to call
 registry.cleanupThread() in the @After of each test. You will get a new
 database for every test.




-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York


Event Bubbling Help Required.

2014-08-29 Thread Yubraj Ghimire
Hello Guys,

I've stumbled upon a problem with EventLinks and Im unable to find a
solution.

I have a component A with eventlink and component B which acts as container
for component B.

ComponentA.tml

///all other code
a t:type=eventlink t:event=redirect context=prop:messageId/a

///all other code
ComponentA.java

void onRedirect(String context) {
   dosomething..
}
This is working fine .But i want to handle this event in Component B and I
also need the context which is passed to the component A onRedirect method.

So I removed onredirect from componentA and moved it component B thinking
that it bubbles up.
ComponentB.java

void onRedirect(String context) {
  dosomething
}

But I'm getting exception. I've searched jumpstart but their i saw examples
for event bubbling without context. How to bubble up events which have
context.

Im pretty new and would like to get a start in the right direction. If this
question has been previously answered please give me the link. I could not
find any.

I also saw pageRenderLinkResources.eventlinkwithcontext, but have no idea
how to pass this context in the second parameter. I know i'm doing
something wrong.

Help me outt..

thank you


Re: Event Bubbling Help Required.

2014-08-29 Thread Yubraj Ghimire
sorry typo error with pageRenderlinkresources..

It should have been

componentResources.triggerEventWithContext



On Fri, Aug 29, 2014 at 11:59 PM, Yubraj Ghimire eass2014.mast...@gmail.com
 wrote:

 Hello Guys,

 I've stumbled upon a problem with EventLinks and Im unable to find a
 solution.

 I have a component A with eventlink and component B which acts as
 container for component B.

 ComponentA.tml

 ///all other code
 a t:type=eventlink t:event=redirect context=prop:messageId/a

 ///all other code
 ComponentA.java

 void onRedirect(String context) {
dosomething..
 }
 This is working fine .But i want to handle this event in Component B and I
 also need the context which is passed to the component A onRedirect method.

 So I removed onredirect from componentA and moved it component B thinking
 that it bubbles up.
 ComponentB.java

 void onRedirect(String context) {
   dosomething
 }

 But I'm getting exception. I've searched jumpstart but their i saw
 examples for event bubbling without context. How to bubble up events which
 have context.

 Im pretty new and would like to get a start in the right direction. If
 this question has been previously answered please give me the link. I could
 not find any.

 I also saw pageRenderLinkResources.eventlinkwithcontext, but have no idea
 how to pass this context in the second parameter. I know i'm doing
 something wrong.

 Help me outt..

 thank you



Re: Event Bubbling Help Required.

2014-08-29 Thread Sumanth
There is already a solution provided by Howard Lewis Ship. I also hope this
makes up available as an example in jumpstart or the documentation of
tapestry itself as it is a common problem. It is as simple as just adding
FromComponentName for each of the bubbling up event.
For more explanation please look at this link
http://markmail.org/message/fjev6gt76fpc6akq and even this link which
points out to the previous link.
Hope this helps
http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/T5-Event-bubbling-td2423435.html
.




On Sat, Aug 30, 2014 at 12:11 AM, Yubraj Ghimire eass2014.mast...@gmail.com
 wrote:

 sorry typo error with pageRenderlinkresources..

 It should have been

 componentResources.triggerEventWithContext



 On Fri, Aug 29, 2014 at 11:59 PM, Yubraj Ghimire 
 eass2014.mast...@gmail.com
  wrote:

  Hello Guys,
 
  I've stumbled upon a problem with EventLinks and Im unable to find a
  solution.
 
  I have a component A with eventlink and component B which acts as
  container for component B.
 
  ComponentA.tml
 
  ///all other code
  a t:type=eventlink t:event=redirect context=prop:messageId/a
 
  ///all other code
  ComponentA.java
 
  void onRedirect(String context) {
 dosomething..
  }
  This is working fine .But i want to handle this event in Component B and
 I
  also need the context which is passed to the component A onRedirect
 method.
 
  So I removed onredirect from componentA and moved it component B thinking
  that it bubbles up.
  ComponentB.java
 
  void onRedirect(String context) {
dosomething
  }
 
  But I'm getting exception. I've searched jumpstart but their i saw
  examples for event bubbling without context. How to bubble up events
 which
  have context.
 
  Im pretty new and would like to get a start in the right direction. If
  this question has been previously answered please give me the link. I
 could
  not find any.
 
  I also saw pageRenderLinkResources.eventlinkwithcontext, but have no idea
  how to pass this context in the second parameter. I know i'm doing
  something wrong.
 
  Help me outt..
 
  thank you