Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Anjo Krank
I'm not sure you understand... the String thing is only the  
bottleneck. I have caller code like:


	ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper(ec, model.name 
());

ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper(ec, dbc);
	ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper(ec,  
channel);


Surely you don't suggest I need to create a "module" in every top- 
level caller?


My argument being, I have a lot of code that depends on various  
"services" and their instantiation. But 90% of the time, this code  
depends on user input, program state and external stuff. It's very  
rare that I actually know at compile time what implementation I have.  
We normally use Class.forName().newInstance() in some way or other to  
handle that. So can DI help me there? If yes, how?


And Kieran: properties are there to make things *easier* I wouldn't  
want to avoid if's at the cost of putting every constructor in  
there... I dread the guy who has to deal with that after you...


Cheers, Anjo



Am 22.09.2009 um 00:11 schrieb Henrique Prange:


Hi Anjo,

You would not need a static method to create new ERXSQLHelper  
objects if you were using a DI container. For example, using Guice  
you could declare a helper property that must be injected.


@Inject
ERXSQLHelper helper;

If you were too lazy you could let the user define which  
implementation to use. For example, using Guice this is achieved  
with a Module with the following binding:


bind(ERXSQLHelper.class).to(OracleSQLHelper.class);

If I had to implement this using Guice, I would create an  
ERXSQLHelper provider that would return the right ERXSQLHelper based  
on the chosen database. Of course, to avoid the same code (nested  
ifs) inside the provider, I would refactor the way the database type  
is defined too.


IMHO, one advantage of this approach is I could create my own  
extension of ERXSQLHelper class and bind to all ERXSQLHelper  
declarations easily. I just need to create my own Module with the  
following code:


bind(ERXSQLHelper.class).to(MyOwnSQLHelper.class);

I could do the same thing with the current implementation, but I  
need to set a property that is not type safe and you had to write a  
lot of boilerplate code to support this.


Guice fail fast mechanism also helps to find problems earlier. If  
something is wrong with the bindings, an exception is thrown as soon  
as you create the Injector. In your example, I would get a  
NoClassDefFound in runtime, during a very important presentation, of  
course. :p


And last, but not least, you could bind a MockERXSQLHelper class  
when unit testing classes that depend upon ERXSQLHelper.


Cheers,

Henrique

Anjo Krank wrote:
U-huh. So how about a real world example and not these cooked up  
things. Take a look at the ERXSQLHelper. Depending on various types  
of input it creates a concrete subclass. Can DI change this to sth  
more "clean"?

Cheers, Anjo
 public static ERXSQLHelper newSQLHelper(String  
databaseProductName) {

   synchronized (_sqlHelperMap) {
 ERXSQLHelper sqlHelper = _sqlHelperMap.get(databaseProductName);
 if (sqlHelper == null) {
   try {
 String sqlHelperClassName = ERXProperties.stringForKey 
(databaseProductName + ".SQLHelper");

 if (sqlHelperClassName == null) {
   if (databaseProductName.equalsIgnoreCase("frontbase")) {
 sqlHelper = new FrontBaseSQLHelper();
   }
   else if (databaseProductName.equalsIgnoreCase("mysql")) {
 sqlHelper = new MySQLSQLHelper();
   }
   else if (databaseProductName.equalsIgnoreCase("oracle")) {
 sqlHelper = new OracleSQLHelper();
   }
   else if (databaseProductName.equalsIgnoreCase 
("postgresql")) {

 sqlHelper = new PostgresqlSQLHelper();
   }
   else if (databaseProductName.equalsIgnoreCase 
("openbase")) {

 sqlHelper = new OpenBaseSQLHelper();
   }
   else if (databaseProductName.equalsIgnoreCase("derby")) {
 sqlHelper = new DerbySQLHelper();
   }
   else if (databaseProductName.equalsIgnoreCase 
("microsoft")) {

 sqlHelper = new MicrosoftSQLHelper();
   }
   else {
 try {
   sqlHelper = (ERXSQLHelper) Class.forName 
(ERXSQLHelper.class.getName() + "$" + databaseProductName +  
"SQLHelper").newInstance();

 }
 catch (ClassNotFoundException e) {
   sqlHelper = new ERXSQLHelper();
 }
   }
 }
 else {
   sqlHelper = (ERXSQLHelper) Class.forName 
(sqlHelperClassName).newInstance();

 }
 _sqlHelperMap.put(databaseProductName, sqlHelper);
   }
   catch (Exception e) {
 throw new NSForwardException(e, "Failed to create sql  
helper for the database with the product name '" +  
databaseProductName + "'.");

   }
 }
 return sqlH

Statistik overlay - how to?

2009-09-21 Thread ute Hoffmann

Hello,
has anyone implemented a statistik overlay and can give me a hint?

I see two possible way to do so: first- make the links unique with a  
id which is part of the links, but
that seems not right to me, that two links, which are pointing to the  
same page should be different,

even if only by a parameter.

I could imagine this could work via javascript. either triggering a  
function with onclick, but...
can I call a void function on the server by javascript - function  
returning nothing but just trigger a

write in a textfile or a database?

Or could a javascript insert this into the header or send it as  
hidden parameter i.e.
add it to the link before sending it or submitting a hidden form...  
but submitting a form will not work
with a normal links, will it? That would be the easiest, perhaps, to  
submit a form where one writes an id in via

javascript before...

Well, I'm a bit lost here, so, is there a common praxis to archieve  
this?


I do have a session, but that will not really help me here, right?

Sorry for this off topic post.

Thanks for any help.

Regards

Ute

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Rewrite Rule

2009-09-21 Thread ute Hoffmann

Upps, I think so. At which Property do I have to look to know.

I run in deployment and definitley come via apache but I have not set  
anything deliberately.  I'm a new wonder user

so maybe I overlooked something...?

Am 21.09.2009 um 18:17 schrieb Guido Neitzer:


Are you running in WebServer connect mode?

cug

-- http://www.event-s.net

On 20. Sep. 2009, at 02:02 , ute Hoffmann wrote:


Hi,
should this work for applications which have a session as well,
or will it work only for sessionless apps?

 * 
 * er.extensions.ERXApplication.replaceApplicationPath.pattern=/ 
cgi-bin/WebObjects/YourApp.woa
 * er.extensions.ERXApplication.replaceApplicationPath.replace=/ 
yourapp

 * 
 *
 * and in Apache 2.2:
 * 
 * RewriteRule ^/yourapp(.*)$ /cgi-bin/WebObjects/YourApp.woa$1  
[PT,L]

 * 
 *
 * or Apache 1.3:
 * 
 * RewriteRule ^/yourapp(.*)$ /cgi-bin/WebObjects/YourApp.woa$1 [P,L]
 * 

I put it into the properties file of an Application, but nothing  
changed in the way the URL's were displayed.


I use WOHyperlinks which call directActions with parameters and  
have a session.


I have the Application extend a Application class in a framework  
which then in turn extends ERXApplication.
Could that be part of my problem? But the Application starts up  
ok, and the added properties are in the logfile,

so I THINK they should be seen...

Probably this is very basic, sorry.

Thanks for your help.

Regards,

Ute
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/guido.neitzer 
%40gmail.com


This email sent to guido.neit...@gmail.com




___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: DirectAction with cookies and session

2009-09-21 Thread Chuck Hill


On Sep 21, 2009, at 1:19 PM, Fred Wells wrote:



Hello,
If I missed this I apologize but I can't seem to find anything on  
this. I'm trying to test out SWFUpload within one of my WO apps.
It is currently set up to store sessionID in cookies. SWFUpload  
needs a post-upload URL for processing, I need the session  
information to be

available to that URL.


How are you making the URL?  Cookies should be OK.  Or the URL can  
have ?wosid=



I can't seem to get DirectAction to 'isSessionIDInRequest' always  
comes up false and 'sessionID' always is null. I've tried
constructing the URL through WOActionURL and   
'directActionURLForActionNamed'.


WOActionURL?  WOContext you mean?  If you are doing this in Java,  
WOContext.directActionURLForActionNamed should do what you want.





Both make a [what looks like] a valid directaction URL.
But when sent it never finds the session from the cookie. Is there  
something else I have to do when trying to use a DirectAction in a  
session?



Log out the request headers.  Is the cookie in there?


Chuck


--
Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their  
overall knowledge of WebObjects or who are trying to solve specific  
problems.

http://www.global-village.net/products/practical_webobjects







___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Very interesting case

2009-09-21 Thread Chuck Hill


On Sep 21, 2009, at 2:16 PM, Don Lindsay wrote:

I know, I have been piddling with it and probably violated many  
commandments.


That is not something that you can do and expect sane results.  It is  
a binary sort of thing.  Either you lock correctly and obey the  
commandments, or EOF.doCrazyThingsAtRandom(true).  Your call.


You seem to have found a work around, but that does not address why  
the EO was not getting saved.  I strongly suspect that you have a  
latent bug lurking in the background.



Chuck




Let me explain what I am doing and see if anyone has any insight.

I have a datamodel with the following:

  Users (identifier Integer, username string, password string)
  Pages (identifier Integer, PageDescription string, active integer,  
position Integer)
  Questions (identifier integer, questiontext string, pageidentifier  
integer, active integer)
  Question Lookup Values (identifier, descriptivetext string, active  
integer)
  UserAnswers(identifier integer, useridentifier integer,  
questionidentifier integer, answeridentifier integer)


Pretty simple.  A user can access any page, any question on a page,  
and answer a question only once.  So I created an entity:


useranswers ( User, Question, Answer(would contain a question  
lookup) )


Pages can have one or more questions,
Questions can have zero or more Question Lookup Values.
More than one question can relate to a question lookup value.

So the relationship looks like this:

 Pages  <-->> Questions <<-->> Lookup Values
 User <-->> UserAnswers <<--> Question

So what I have done is create a component that takes a User as a  
property when it is created setUser(...).

I then created a WODisplayGroup for Pages with no detail.
I then created a WODisplayGroup for Questions with detail pointing  
to pages.
I then created a WODisplayGroup for UserAnswers with detail pointing  
to questions.


The issue I have with the UserAnswers displaygroup is that it also  
requires a qualification to a User as well as a question.  N  
problemo, I use the  
queryMatch().setValueForKey(theUserObject,"theUser").


Now here is where I run into issues, Question.theAnswers  
relationship returns an NSArray because it is a to-many.  How do I  
bind this to the selection property of a WOPopupButton, I can't that  
I know of.  <>


Don



On Sep 21, 2009, at 4:31 PM, Chuck Hill wrote:



On Sep 21, 2009, at 1:17 PM, Don Lindsay wrote:


Hello;

I have a component that I am updating a table of answers based on  
selections made by the user from a worepitition.


The code being executed is:

try {
String sEoQualifierText  = "page=";
			sEoQualifierText +=  
Integer.toString((Integer)thePage().valueForKey("identifier"));

sEoQualifierText += " and question=";
			sEoQualifierText +=  
Integer.toString((Integer)theQuestion().valueForKey("identifier"));

sEoQualifierText += " and user=";
			sEoQualifierText += Integer.toString((Integer) 
((EOEnterpriseObject)theUser).valueForKey("identifier"));
			EOQualifier oQual =  
EOQualifier.qualifierWithQualifierFormat(sEoQualifierText,null);


What are you doing?  And why?  What is  
thePage().valueForKey("identifier")?  Home brew binding sync?   
Generic Record based EOs with no Java classes?


Wonder's ERXQ will make your life so much easier to read and  
maintain.




			EOFetchSpecification oFetch = new  
EOFetchSpecification("UserAnswers",oQual,null);

NSArray aAnswer = 
oEO().objectsWithFetchSpecification(oFetch);
oEO().lock();


Nooo.


Why lock like that?  Why not just gouge your eyes out and hammer  
pencils into your ears?  It will be quicker and less painful and  
just as effective.


Locking like that is useless and wrong and just won't work.  Ever.   
Use ERXEC or the MultiECLockManager.  Your chances of doing it  
right another other way approach null.




			 
((UserAnswers 
)aAnswer 
.objectAtIndex(0)).setTheAnswer((QuestionLookup)theAnswer());


//((EOEnterpriseObject)aAnswer.objectAtIndex(0)).willChange();
oEO().unlock();
			//System.out.println("updates to be saved: " +  
oEO().updatedObjects());

oEO().saveChanges();
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println("hiss, didn't work");
}
if (theAnswer!=null) {
			System.out.println("append to response firing "+ 
(String)theAnswer.valueForKey("desc"));

} else {
			System.out.println("append to response firing but the answer is  
null");

}

ThePage is an item from a listing of available pages repetition.
TheQuestion is an item from listing of questions repitition.
TheUser is the user who is currently working with the page

Re: AjaxAutoComplete - is it possible to have the equivalent of a noDisplayString?

2009-09-21 Thread getsharp

On 22/09/2009, at 6:08 AM, J Stephanos wrote:


David:
> Unfortunately the text triggers an immediate search on the default  
string.


It doesn't in my case.  It is working as expected for me per the  
AjaxTextHinter javadoc example.




I experience the same behaviour as David.

AjaxTextHinter does work as per the example, but the presence of the  
text is seen as a change by AjaxObserveField.


Sharpy.
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[Solved] Re: Very interesting case

2009-09-21 Thread Don Lindsay
I was making it too difficult.  I was able to solve the issue by using  
the UserAnswers as the primary Display Group.


Don


On Sep 21, 2009, at 5:16 PM, Don Lindsay wrote:

I know, I have been piddling with it and probably violated many  
commandments.  Let me explain what I am doing and see if anyone has  
any insight.


I have a datamodel with the following:

  Users (identifier Integer, username string, password string)
  Pages (identifier Integer, PageDescription string, active integer,  
position Integer)
  Questions (identifier integer, questiontext string, pageidentifier  
integer, active integer)
  Question Lookup Values (identifier, descriptivetext string, active  
integer)
  UserAnswers(identifier integer, useridentifier integer,  
questionidentifier integer, answeridentifier integer)


Pretty simple.  A user can access any page, any question on a page,  
and answer a question only once.  So I created an entity:


useranswers ( User, Question, Answer(would contain a question  
lookup) )


Pages can have one or more questions,
Questions can have zero or more Question Lookup Values.
More than one question can relate to a question lookup value.

So the relationship looks like this:

 Pages  <-->> Questions <<-->> Lookup Values
 User <-->> UserAnswers <<--> Question

So what I have done is create a component that takes a User as a  
property when it is created setUser(...).

I then created a WODisplayGroup for Pages with no detail.
I then created a WODisplayGroup for Questions with detail pointing  
to pages.
I then created a WODisplayGroup for UserAnswers with detail pointing  
to questions.


The issue I have with the UserAnswers displaygroup is that it also  
requires a qualification to a User as well as a question.  N  
problemo, I use the  
queryMatch().setValueForKey(theUserObject,"theUser").


Now here is where I run into issues, Question.theAnswers  
relationship returns an NSArray because it is a to-many.  How do I  
bind this to the selection property of a WOPopupButton, I can't that  
I know of.  <>


Don



On Sep 21, 2009, at 4:31 PM, Chuck Hill wrote:



On Sep 21, 2009, at 1:17 PM, Don Lindsay wrote:


Hello;

I have a component that I am updating a table of answers based on  
selections made by the user from a worepitition.


The code being executed is:

try {
String sEoQualifierText  = "page=";
			sEoQualifierText +=  
Integer.toString((Integer)thePage().valueForKey("identifier"));

sEoQualifierText += " and question=";
			sEoQualifierText +=  
Integer.toString((Integer)theQuestion().valueForKey("identifier"));

sEoQualifierText += " and user=";
			sEoQualifierText += Integer.toString((Integer) 
((EOEnterpriseObject)theUser).valueForKey("identifier"));
			EOQualifier oQual =  
EOQualifier.qualifierWithQualifierFormat(sEoQualifierText,null);


What are you doing?  And why?  What is  
thePage().valueForKey("identifier")?  Home brew binding sync?   
Generic Record based EOs with no Java classes?


Wonder's ERXQ will make your life so much easier to read and  
maintain.




			EOFetchSpecification oFetch = new  
EOFetchSpecification("UserAnswers",oQual,null);

NSArray aAnswer = 
oEO().objectsWithFetchSpecification(oFetch);
oEO().lock();


Nooo.


Why lock like that?  Why not just gouge your eyes out and hammer  
pencils into your ears?  It will be quicker and less painful and  
just as effective.


Locking like that is useless and wrong and just won't work.  Ever.   
Use ERXEC or the MultiECLockManager.  Your chances of doing it  
right another other way approach null.




			 
((UserAnswers 
)aAnswer 
.objectAtIndex(0)).setTheAnswer((QuestionLookup)theAnswer());


//((EOEnterpriseObject)aAnswer.objectAtIndex(0)).willChange();
oEO().unlock();
			//System.out.println("updates to be saved: " +  
oEO().updatedObjects());

oEO().saveChanges();
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println("hiss, didn't work");
}
if (theAnswer!=null) {
			System.out.println("append to response firing "+ 
(String)theAnswer.valueForKey("desc"));

} else {
			System.out.println("append to response firing but the answer is  
null");

}

ThePage is an item from a listing of available pages repetition.
TheQuestion is an item from listing of questions repitition.
TheUser is the user who is currently working with the page.

The entity has 4 attributes (user, page, question, answer).

When I turn on EO Debugging I see that an update is made, but when  
I check the database the answer is always null.  I do not get any  
errors in the logs.  If I had an error I could start working it

Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Henrique Prange

Hi Anjo,

Anjo Krank wrote:
Just so I know: does DI make anything simpler aside from unit testing? 
Is it worth the cost of un-readbility and un-debugablity?  I mean, for
foreign code i totally rely on eclipse call graphs... these are a 
nightmare with interfaces, not to mention missing constructors.




You can produce detailed object graph description using Guice Grapher 
extension (of course, you must use Guice as a DI container). I've never 
tried it, but it seems to work.


There is also a Guice plug-in for Eclipse that promises to help in this 
direction.


Cheers,

Henrique


Cheers, Anjo



Am 21.09.2009 um 21:17 schrieb Andrus Adamchik:


Hi Henrique,

Nice, thanks for sharing this info. Yeah, going through WOApplication 
and WOComponentDefinition, I realized I was too optimistic. Most 
interesting methods that would've enabled DI integration are all 
private. Quite a bit of code to rewrite to make it work. I was even 
thinking of limiting injection to just the Application class.


Great that you are willing to open source your work in this area. Even 
if you load your code in its current state to a public SVN 
(ObjectStyle.org is always an option) or git somewhere, it will be a 
rather helpful example.


Cheers,
Andrus

-
Andrus Adamchik
Apache Cayenne ORM: http://cayenne.apache.org/
Creator of Cayenne, VP Apache Software Foundation


On Sep 21, 2009, at 6:18 PM, Henrique Prange wrote:

Hi Andrus,

Andrus Adamchik wrote:
I know it is not the traditional "WO way" of doing things, but from 
my experience using a dependency injection container in your app 
(Spring, Guice, etc.) is one single thing that you can do to 
dramatically improve the design quality, and produce flexible and 
maintainable code.


We have been using Guice with WO for some time in our projects. Our 
code become easier to test without requiring too much boilerplate 
code using a DI container.


WO does a bit of that on its own (such as session and application 
injection in components), but doesn't bundle a container that a 
developer could use for the custom "services" (unlike say Tapestry, 
that does have a DI container at its core).
Say I have a WO application and I'd like to use Spring or Guice to 
inject custom services in the WOComponents, instead of looking them 
up in WOApplication (or worse - defining them as static singletons 
somewhere). This sounds easy on the surface. I don't remember all 
the component creation internals now (it's been a while since I 
poked around the framework code), but I am pretty sure I can create 
them with my own factory that is DI container aware. On the other 
hand (also because I've been out of the loop on WO for quite some 
time), I am sure I am missing some pieces of the puzzle that would 
make such setup less practical or outright painful.


Instead of changing component creation internals, we've created an 
extension of ERXComponent that obtain the injector and inject the 
required members. It is not a perfect solution (you can't use 
constructor injection this way), but it is easy to implement.


This and the fact that DI capabilities don't seem to bother the rest 
of the community, I figured I'd ask the list on your opinions, while 
I am trying to wire this thing up in the background.

So anybody played with DI-on-WO in some form with any success?


We have an audit framework completely based on Guice. We have created 
extensions of other important classes to make it possible, like 
ERXGenericRecord and ERXEC and we have created a @WOSessionScoped 
scope to create/obtain objects per WOSession.


We are planning to create an open source framework with this stuff. 
We are just polishing what we've done to use some new features of 
Guice 2.0.


Cheers,

Henrique


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/anjo%40krank.net

This email sent to a...@krank.net


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/hprange%40gmail.com

This email sent to hpra...@gmail.com

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Henrique Prange

Hi Anjo,

You would not need a static method to create new ERXSQLHelper objects if 
you were using a DI container. For example, using Guice you could 
declare a helper property that must be injected.


@Inject
ERXSQLHelper helper;

If you were too lazy you could let the user define which implementation 
to use. For example, using Guice this is achieved with a Module with the 
following binding:


bind(ERXSQLHelper.class).to(OracleSQLHelper.class);

If I had to implement this using Guice, I would create an ERXSQLHelper 
provider that would return the right ERXSQLHelper based on the chosen 
database. Of course, to avoid the same code (nested ifs) inside the 
provider, I would refactor the way the database type is defined too.


IMHO, one advantage of this approach is I could create my own extension 
of ERXSQLHelper class and bind to all ERXSQLHelper declarations easily. 
I just need to create my own Module with the following code:


bind(ERXSQLHelper.class).to(MyOwnSQLHelper.class);

I could do the same thing with the current implementation, but I need to 
set a property that is not type safe and you had to write a lot of 
boilerplate code to support this.


Guice fail fast mechanism also helps to find problems earlier. If 
something is wrong with the bindings, an exception is thrown as soon as 
you create the Injector. In your example, I would get a NoClassDefFound 
in runtime, during a very important presentation, of course. :p


And last, but not least, you could bind a MockERXSQLHelper class when 
unit testing classes that depend upon ERXSQLHelper.


Cheers,

Henrique

Anjo Krank wrote:
U-huh. So how about a real world example and not these cooked up things. 
Take a look at the ERXSQLHelper. Depending on various types of input it 
creates a concrete subclass. Can DI change this to sth more "clean"?


Cheers, Anjo

  public static ERXSQLHelper newSQLHelper(String databaseProductName) {
synchronized (_sqlHelperMap) {
  ERXSQLHelper sqlHelper = _sqlHelperMap.get(databaseProductName);
  if (sqlHelper == null) {
try {
  String sqlHelperClassName = 
ERXProperties.stringForKey(databaseProductName + ".SQLHelper");

  if (sqlHelperClassName == null) {
if (databaseProductName.equalsIgnoreCase("frontbase")) {
  sqlHelper = new FrontBaseSQLHelper();
}
else if (databaseProductName.equalsIgnoreCase("mysql")) {
  sqlHelper = new MySQLSQLHelper();
}
else if (databaseProductName.equalsIgnoreCase("oracle")) {
  sqlHelper = new OracleSQLHelper();
}
else if (databaseProductName.equalsIgnoreCase("postgresql")) {
  sqlHelper = new PostgresqlSQLHelper();
}
else if (databaseProductName.equalsIgnoreCase("openbase")) {
  sqlHelper = new OpenBaseSQLHelper();
}
else if (databaseProductName.equalsIgnoreCase("derby")) {
  sqlHelper = new DerbySQLHelper();
}
else if (databaseProductName.equalsIgnoreCase("microsoft")) {
  sqlHelper = new MicrosoftSQLHelper();
}
else {
  try {
sqlHelper = (ERXSQLHelper) 
Class.forName(ERXSQLHelper.class.getName() + "$" + databaseProductName + 
"SQLHelper").newInstance();

  }
  catch (ClassNotFoundException e) {
sqlHelper = new ERXSQLHelper();
  }
}
  }
  else {
sqlHelper = (ERXSQLHelper) 
Class.forName(sqlHelperClassName).newInstance();

  }
  _sqlHelperMap.put(databaseProductName, sqlHelper);
}
catch (Exception e) {
  throw new NSForwardException(e, "Failed to create sql helper 
for the database with the product name '" + databaseProductName + "'.");

}
  }
  return sqlHelper;
}
  }



Am 21.09.2009 um 23:24 schrieb Andrew Lindesay:


Hi Anjo;

I guess this could be helpful in _some_ situations; I take for 
example, the Jetty server.  Jetty can have a number of "handlers" 
added to it.  Each handler does something like re-writes, feeds 
disk-based content, runs servlets etc.. etc..  The Jetty authors could 
not have envisaged all of the possible handlers that might have been 
written for Jetty, but because of the configuration style which 
follows the same line of thinking as Andrus is describing, it is 
possible to configure additional handlers.  So that's a good example 
of where this seems quite helpful and Andrus' other examples also feel 
like good examples, but I agree that it seems like over-kill for many 
situations.


cheers.

Thanks for the write-up, but yeah, this can all be achieved w/o it. I 
really don't see why I shouldn't configure my app with 
if(Configration.isStaging())... and instead use DI. At least my way I 
easily find all the occurrences and have full logic support 
if(!Configuration.isStaging()). How is D

Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Kieran Kelleher
To keep stuff like this below 'clean', I define a list of properties  
and lookup the property to get the class name


er 
.extensions.sqlHelper.className.mysql=er.extensions.jdbc.MySQLSQLHelper
er.extensions.sqlHelper.className.frontbase  
=er.extensions.jdbc.FrontBaseSQLHelper


etc.

.. and create it like this

Class.forName( "er.extensions.sqlHelper.className." +  
databaseProductName ).newInstance()



YMMV, Kieran

On Sep 21, 2009, at 5:30 PM, Anjo Krank wrote:

U-huh. So how about a real world example and not these cooked up  
things. Take a look at the ERXSQLHelper. Depending on various types  
of input it creates a concrete subclass. Can DI change this to sth  
more "clean"?


Cheers, Anjo

 public static ERXSQLHelper newSQLHelper(String databaseProductName) {
   synchronized (_sqlHelperMap) {
 ERXSQLHelper sqlHelper = _sqlHelperMap.get(databaseProductName);
 if (sqlHelper == null) {
   try {
 String sqlHelperClassName =  
ERXProperties.stringForKey(databaseProductName + ".SQLHelper");

 if (sqlHelperClassName == null) {
   if (databaseProductName.equalsIgnoreCase("frontbase")) {
 sqlHelper = new FrontBaseSQLHelper();
   }
   else if (databaseProductName.equalsIgnoreCase("mysql")) {
 sqlHelper = new MySQLSQLHelper();
   }
   else if (databaseProductName.equalsIgnoreCase("oracle")) {
 sqlHelper = new OracleSQLHelper();
   }
   else if  
(databaseProductName.equalsIgnoreCase("postgresql")) {

 sqlHelper = new PostgresqlSQLHelper();
   }
   else if  
(databaseProductName.equalsIgnoreCase("openbase")) {

 sqlHelper = new OpenBaseSQLHelper();
   }
   else if (databaseProductName.equalsIgnoreCase("derby")) {
 sqlHelper = new DerbySQLHelper();
   }
   else if  
(databaseProductName.equalsIgnoreCase("microsoft")) {

 sqlHelper = new MicrosoftSQLHelper();
   }
   else {
 try {
   sqlHelper = (ERXSQLHelper)  
Class.forName(ERXSQLHelper.class.getName() + "$" +  
databaseProductName + "SQLHelper").newInstance();

 }
 catch (ClassNotFoundException e) {
   sqlHelper = new ERXSQLHelper();
 }
   }
 }
 else {
   sqlHelper = (ERXSQLHelper)  
Class.forName(sqlHelperClassName).newInstance();

 }
 _sqlHelperMap.put(databaseProductName, sqlHelper);
   }
   catch (Exception e) {
 throw new NSForwardException(e, "Failed to create sql  
helper for the database with the product name '" +  
databaseProductName + "'.");

   }
 }
 return sqlHelper;
   }
 }



Am 21.09.2009 um 23:24 schrieb Andrew Lindesay:


Hi Anjo;

I guess this could be helpful in _some_ situations; I take for  
example, the Jetty server.  Jetty can have a number of "handlers"  
added to it.  Each handler does something like re-writes, feeds  
disk-based content, runs servlets etc.. etc..  The Jetty authors  
could not have envisaged all of the possible handlers that might  
have been written for Jetty, but because of the configuration style  
which follows the same line of thinking as Andrus is describing, it  
is possible to configure additional handlers.  So that's a good  
example of where this seems quite helpful and Andrus' other  
examples also feel like good examples, but I agree that it seems  
like over-kill for many situations.


cheers.

Thanks for the write-up, but yeah, this can all be achieved w/o  
it. I really don't see why I shouldn't configure my app with  
if(Configration.isStaging())... and instead use DI. At least my  
way I easily find all the occurrences and have full logic support  
if(!Configuration.isStaging()). How is DI "cleaner" in any way when:


- I have any number of DI containers and their various syntax to  
chose from
- I can't *find* the dependencies when I really want or need them.  
Have you ever tried to debug such an app that wasn't written by  
yourself? Take a look at the Red5 Media server for some fun...


___
Andrew Lindesay
www.lindesay.co.nz



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists%40mac.com

This email sent to kieran_li...@mac.com


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Anjo Krank
U-huh. So how about a real world example and not these cooked up  
things. Take a look at the ERXSQLHelper. Depending on various types of  
input it creates a concrete subclass. Can DI change this to sth more  
"clean"?


Cheers, Anjo

  public static ERXSQLHelper newSQLHelper(String databaseProductName) {
synchronized (_sqlHelperMap) {
  ERXSQLHelper sqlHelper = _sqlHelperMap.get(databaseProductName);
  if (sqlHelper == null) {
try {
  String sqlHelperClassName = ERXProperties.stringForKey 
(databaseProductName + ".SQLHelper");

  if (sqlHelperClassName == null) {
if (databaseProductName.equalsIgnoreCase("frontbase")) {
  sqlHelper = new FrontBaseSQLHelper();
}
else if (databaseProductName.equalsIgnoreCase("mysql")) {
  sqlHelper = new MySQLSQLHelper();
}
else if (databaseProductName.equalsIgnoreCase("oracle")) {
  sqlHelper = new OracleSQLHelper();
}
else if (databaseProductName.equalsIgnoreCase 
("postgresql")) {

  sqlHelper = new PostgresqlSQLHelper();
}
else if (databaseProductName.equalsIgnoreCase 
("openbase")) {

  sqlHelper = new OpenBaseSQLHelper();
}
else if (databaseProductName.equalsIgnoreCase("derby")) {
  sqlHelper = new DerbySQLHelper();
}
else if (databaseProductName.equalsIgnoreCase 
("microsoft")) {

  sqlHelper = new MicrosoftSQLHelper();
}
else {
  try {
sqlHelper = (ERXSQLHelper) Class.forName 
(ERXSQLHelper.class.getName() + "$" + databaseProductName +  
"SQLHelper").newInstance();

  }
  catch (ClassNotFoundException e) {
sqlHelper = new ERXSQLHelper();
  }
}
  }
  else {
sqlHelper = (ERXSQLHelper) Class.forName 
(sqlHelperClassName).newInstance();

  }
  _sqlHelperMap.put(databaseProductName, sqlHelper);
}
catch (Exception e) {
  throw new NSForwardException(e, "Failed to create sql  
helper for the database with the product name '" + databaseProductName  
+ "'.");

}
  }
  return sqlHelper;
}
  }



Am 21.09.2009 um 23:24 schrieb Andrew Lindesay:


Hi Anjo;

I guess this could be helpful in _some_ situations; I take for  
example, the Jetty server.  Jetty can have a number of "handlers"  
added to it.  Each handler does something like re-writes, feeds disk- 
based content, runs servlets etc.. etc..  The Jetty authors could  
not have envisaged all of the possible handlers that might have been  
written for Jetty, but because of the configuration style which  
follows the same line of thinking as Andrus is describing, it is  
possible to configure additional handlers.  So that's a good example  
of where this seems quite helpful and Andrus' other examples also  
feel like good examples, but I agree that it seems like over-kill  
for many situations.


cheers.

Thanks for the write-up, but yeah, this can all be achieved w/o it.  
I really don't see why I shouldn't configure my app with if 
(Configration.isStaging())... and instead use DI. At least my way I  
easily find all the occurrences and have full logic support if(! 
Configuration.isStaging()). How is DI "cleaner" in any way when:


- I have any number of DI containers and their various syntax to  
chose from
- I can't *find* the dependencies when I really want or need them.  
Have you ever tried to debug such an app that wasn't written by  
yourself? Take a look at the Red5 Media server for some fun...


___
Andrew Lindesay
www.lindesay.co.nz



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Andrew Lindesay

Hi Anjo;

I guess this could be helpful in _some_ situations; I take for  
example, the Jetty server.  Jetty can have a number of "handlers"  
added to it.  Each handler does something like re-writes, feeds disk- 
based content, runs servlets etc.. etc..  The Jetty authors could not  
have envisaged all of the possible handlers that might have been  
written for Jetty, but because of the configuration style which  
follows the same line of thinking as Andrus is describing, it is  
possible to configure additional handlers.  So that's a good example  
of where this seems quite helpful and Andrus' other examples also feel  
like good examples, but I agree that it seems like over-kill for many  
situations.


cheers.

Thanks for the write-up, but yeah, this can all be achieved w/o it.  
I really don't see why I shouldn't configure my app with  
if(Configration.isStaging())... and instead use DI. At least my way  
I easily find all the occurrences and have full logic support if(! 
Configuration.isStaging()). How is DI "cleaner" in any way when:


- I have any number of DI containers and their various syntax to  
chose from
- I can't *find* the dependencies when I really want or need them.  
Have you ever tried to debug such an app that wasn't written by  
yourself? Take a look at the Red5 Media server for some fun...


___
Andrew Lindesay
www.lindesay.co.nz

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Very interesting case

2009-09-21 Thread Don Lindsay
I know, I have been piddling with it and probably violated many  
commandments.  Let me explain what I am doing and see if anyone has  
any insight.


I have a datamodel with the following:

   Users (identifier Integer, username string, password string)
   Pages (identifier Integer, PageDescription string, active integer,  
position Integer)
   Questions (identifier integer, questiontext string, pageidentifier  
integer, active integer)
   Question Lookup Values (identifier, descriptivetext string, active  
integer)
   UserAnswers(identifier integer, useridentifier integer,  
questionidentifier integer, answeridentifier integer)


Pretty simple.  A user can access any page, any question on a page,  
and answer a question only once.  So I created an entity:


useranswers ( User, Question, Answer(would contain a question lookup) )

Pages can have one or more questions,
Questions can have zero or more Question Lookup Values.
More than one question can relate to a question lookup value.

So the relationship looks like this:

  Pages  <-->> Questions <<-->> Lookup Values
  User <-->> UserAnswers <<--> Question

So what I have done is create a component that takes a User as a  
property when it is created setUser(...).

I then created a WODisplayGroup for Pages with no detail.
I then created a WODisplayGroup for Questions with detail pointing to  
pages.
I then created a WODisplayGroup for UserAnswers with detail pointing  
to questions.


The issue I have with the UserAnswers displaygroup is that it also  
requires a qualification to a User as well as a question.  N  
problemo, I use the  
queryMatch().setValueForKey(theUserObject,"theUser").


Now here is where I run into issues, Question.theAnswers relationship  
returns an NSArray because it is a to-many.  How do I bind this to the  
selection property of a WOPopupButton, I can't that I know of.   
<>


Don



On Sep 21, 2009, at 4:31 PM, Chuck Hill wrote:



On Sep 21, 2009, at 1:17 PM, Don Lindsay wrote:


Hello;

I have a component that I am updating a table of answers based on  
selections made by the user from a worepitition.


The code being executed is:

try {
String sEoQualifierText  = "page=";
			sEoQualifierText +=  
Integer.toString((Integer)thePage().valueForKey("identifier"));

sEoQualifierText += " and question=";
			sEoQualifierText +=  
Integer.toString((Integer)theQuestion().valueForKey("identifier"));

sEoQualifierText += " and user=";
			sEoQualifierText += Integer.toString((Integer) 
((EOEnterpriseObject)theUser).valueForKey("identifier"));
			EOQualifier oQual =  
EOQualifier.qualifierWithQualifierFormat(sEoQualifierText,null);


What are you doing?  And why?  What is  
thePage().valueForKey("identifier")?  Home brew binding sync?   
Generic Record based EOs with no Java classes?


Wonder's ERXQ will make your life so much easier to read and maintain.



			EOFetchSpecification oFetch = new  
EOFetchSpecification("UserAnswers",oQual,null);

NSArray aAnswer = 
oEO().objectsWithFetchSpecification(oFetch);
oEO().lock();


Nooo.


Why lock like that?  Why not just gouge your eyes out and hammer  
pencils into your ears?  It will be quicker and less painful and  
just as effective.


Locking like that is useless and wrong and just won't work.  Ever.   
Use ERXEC or the MultiECLockManager.  Your chances of doing it right  
another other way approach null.




			 
((UserAnswers 
)aAnswer.objectAtIndex(0)).setTheAnswer((QuestionLookup)theAnswer());


//((EOEnterpriseObject)aAnswer.objectAtIndex(0)).willChange();
oEO().unlock();
			//System.out.println("updates to be saved: " +  
oEO().updatedObjects());

oEO().saveChanges();
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println("hiss, didn't work");
}
if (theAnswer!=null) {
			System.out.println("append to response firing "+ 
(String)theAnswer.valueForKey("desc"));

} else {
			System.out.println("append to response firing but the answer is  
null");

}

ThePage is an item from a listing of available pages repetition.
TheQuestion is an item from listing of questions repitition.
TheUser is the user who is currently working with the page.

The entity has 4 attributes (user, page, question, answer).

When I turn on EO Debugging I see that an update is made, but when  
I check the database the answer is always null.  I do not get any  
errors in the logs.  If I had an error I could start working it out.


Anyone have any ideas?


My money is on "incorrect EC locking" followed by "violating EOF  
commandments".  This is the classic symptom of doing either (or  
both!) of t

Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Anjo Krank

Am 21.09.2009 um 22:46 schrieb Andrus Adamchik:

To be sure all of that can be achieved without DI. DI just makes it  
declarative and cleaner, and actually encourages you to follow this  
specific development pattern.



Thanks for the write-up, but yeah, this can all be achieved w/o it. I  
really don't see why I shouldn't configure my app with if 
(Configration.isStaging())... and instead use DI. At least my way I  
easily find all the occurrences and have full logic support if(! 
Configuration.isStaging()). How is DI "cleaner" in any way when:


- I have any number of DI containers and their various syntax to chose  
from
- I can't *find* the dependencies when I really want or need them.  
Have you ever tried to debug such an app that wasn't written by  
yourself? Take a look at the Red5 Media server for some fun...


Cheers, Anjo

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Andrus Adamchik
Personally I don't even care that much about unit testing web  
applications. In data-driven apps, even with DI, it is hard to create  
good mock data for most of your services, as it may depend on a pretty  
deep object graph.


To me DI is all about clean design and decoupling of functionality  
from configuration. Implementing core application services as  
interfaces is one part of it (not really dependent on DI), but DI  
serves as a glue for those services. At the end it gives you  
flexibility to tweak things by swapping implementations of services  
without touching the components or writing endless if/else manual  
configuration code.


One real-life example is a CMS system that would generate vhost based  
URLs when in production (http://vhost.example.org) and path-based URLs  
in development environment with no DNS capability (http://localhost/vhost 
).


Another one from the CMS realm is a cache service that is implemented  
differently depending on whether the same application is in live mode  
vs. preview mode, allowing for instantaneous page refreshing in  
preview mode and best performance on a live site.


Then there's all the interceptors that you can build around interface  
method calls. I don't use it too often personally, but on a rare  
occasion when you need it, this is priceless.


To be sure all of that can be achieved without DI. DI just makes it  
declarative and cleaner, and actually encourages you to follow this  
specific development pattern.


Andrus


On Sep 21, 2009, at 11:22 PM, Anjo Krank wrote:
Just so I know: does DI make anything simpler aside from unit  
testing? Is it worth the cost of un-readbility and un-debugablity? I  
mean, for foreign code i totally rely on eclipse call graphs...  
these are a nightmare with interfaces, not to mention missing  
constructors.


Cheers, Anjo



Am 21.09.2009 um 21:17 schrieb Andrus Adamchik:


Hi Henrique,

Nice, thanks for sharing this info. Yeah, going through  
WOApplication and WOComponentDefinition, I realized I was too  
optimistic. Most interesting methods that would've enabled DI  
integration are all private. Quite a bit of code to rewrite to make  
it work. I was even thinking of limiting injection to just the  
Application class.


Great that you are willing to open source your work in this area.  
Even if you load your code in its current state to a public SVN  
(ObjectStyle.org is always an option) or git somewhere, it will be  
a rather helpful example.


Cheers,
Andrus

-
Andrus Adamchik
Apache Cayenne ORM: http://cayenne.apache.org/
Creator of Cayenne, VP Apache Software Foundation


On Sep 21, 2009, at 6:18 PM, Henrique Prange wrote:

Hi Andrus,

Andrus Adamchik wrote:
I know it is not the traditional "WO way" of doing things, but  
from my experience using a dependency injection container in your  
app (Spring, Guice, etc.) is one single thing that you can do to  
dramatically improve the design quality, and produce flexible and  
maintainable code.


We have been using Guice with WO for some time in our projects.  
Our code become easier to test without requiring too much  
boilerplate code using a DI container.


WO does a bit of that on its own (such as session and application  
injection in components), but doesn't bundle a container that a  
developer could use for the custom "services" (unlike say  
Tapestry, that does have a DI container at its core).
Say I have a WO application and I'd like to use Spring or Guice  
to inject custom services in the WOComponents, instead of looking  
them up in WOApplication (or worse - defining them as static  
singletons somewhere). This sounds easy on the surface. I don't  
remember all the component creation internals now (it's been a  
while since I poked around the framework code), but I am pretty  
sure I can create them with my own factory that is DI container  
aware. On the other hand (also because I've been out of the loop  
on WO for quite some time), I am sure I am missing some pieces of  
the puzzle that would make such setup less practical or outright  
painful.


Instead of changing component creation internals, we've created an  
extension of ERXComponent that obtain the injector and inject the  
required members. It is not a perfect solution (you can't use  
constructor injection this way), but it is easy to implement.


This and the fact that DI capabilities don't seem to bother the  
rest of the community, I figured I'd ask the list on your  
opinions, while I am trying to wire this thing up in the  
background.

So anybody played with DI-on-WO in some form with any success?


We have an audit framework completely based on Guice. We have  
created extensions of other important classes to make it possible,  
like ERXGenericRecord and ERXEC and we have created a  
@WOSessionScoped scope to create/obtain objects per WOSession.


We are planning to create an open source framework with this  
stuff. We are just po

Re: Very interesting case

2009-09-21 Thread Chuck Hill


On Sep 21, 2009, at 1:17 PM, Don Lindsay wrote:


Hello;

I have a component that I am updating a table of answers based on  
selections made by the user from a worepitition.


The code being executed is:

try {
String sEoQualifierText  = "page=";
			sEoQualifierText +=  
Integer.toString((Integer)thePage().valueForKey("identifier"));

sEoQualifierText += " and question=";
			sEoQualifierText +=  
Integer.toString((Integer)theQuestion().valueForKey("identifier"));

sEoQualifierText += " and user=";
			sEoQualifierText += Integer.toString((Integer) 
((EOEnterpriseObject)theUser).valueForKey("identifier"));
			EOQualifier oQual =  
EOQualifier.qualifierWithQualifierFormat(sEoQualifierText,null);


What are you doing?  And why?  What is  
thePage().valueForKey("identifier")?  Home brew binding sync?  Generic  
Record based EOs with no Java classes?


Wonder's ERXQ will make your life so much easier to read and maintain.



			EOFetchSpecification oFetch = new  
EOFetchSpecification("UserAnswers",oQual,null);

NSArray aAnswer = 
oEO().objectsWithFetchSpecification(oFetch);
oEO().lock();


Nooo.


Why lock like that?  Why not just gouge your eyes out and hammer  
pencils into your ears?  It will be quicker and less painful and just  
as effective.


Locking like that is useless and wrong and just won't work.  Ever.   
Use ERXEC or the MultiECLockManager.  Your chances of doing it right  
another other way approach null.




			 
((UserAnswers 
)aAnswer.objectAtIndex(0)).setTheAnswer((QuestionLookup)theAnswer());


//((EOEnterpriseObject)aAnswer.objectAtIndex(0)).willChange();
oEO().unlock();
			//System.out.println("updates to be saved: " +  
oEO().updatedObjects());

oEO().saveChanges();
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println("hiss, didn't work");
}
if (theAnswer!=null) {
			System.out.println("append to response firing "+ 
(String)theAnswer.valueForKey("desc"));

} else {
			System.out.println("append to response firing but the answer is  
null");

}

ThePage is an item from a listing of available pages repetition.
TheQuestion is an item from listing of questions repitition.
TheUser is the user who is currently working with the page.

The entity has 4 attributes (user, page, question, answer).

When I turn on EO Debugging I see that an update is made, but when I  
check the database the answer is always null.  I do not get any  
errors in the logs.  If I had an error I could start working it out.


Anyone have any ideas?


My money is on "incorrect EC locking" followed by "violating EOF  
commandments".  This is the classic symptom of doing either (or both!)  
of those.



Chuck


--
Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their  
overall knowledge of WebObjects or who are trying to solve specific  
problems.

http://www.global-village.net/products/practical_webobjects







___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Anjo Krank
Just so I know: does DI make anything simpler aside from unit testing?  
Is it worth the cost of un-readbility and un-debugablity? I mean, for  
foreign code i totally rely on eclipse call graphs... these are a  
nightmare with interfaces, not to mention missing constructors.


Cheers, Anjo



Am 21.09.2009 um 21:17 schrieb Andrus Adamchik:


Hi Henrique,

Nice, thanks for sharing this info. Yeah, going through  
WOApplication and WOComponentDefinition, I realized I was too  
optimistic. Most interesting methods that would've enabled DI  
integration are all private. Quite a bit of code to rewrite to make  
it work. I was even thinking of limiting injection to just the  
Application class.


Great that you are willing to open source your work in this area.  
Even if you load your code in its current state to a public SVN (ObjectStyle.org 
 is always an option) or git somewhere, it will be a rather helpful  
example.


Cheers,
Andrus

-
Andrus Adamchik
Apache Cayenne ORM: http://cayenne.apache.org/
Creator of Cayenne, VP Apache Software Foundation


On Sep 21, 2009, at 6:18 PM, Henrique Prange wrote:

Hi Andrus,

Andrus Adamchik wrote:
I know it is not the traditional "WO way" of doing things, but  
from my experience using a dependency injection container in your  
app (Spring, Guice, etc.) is one single thing that you can do to  
dramatically improve the design quality, and produce flexible and  
maintainable code.


We have been using Guice with WO for some time in our projects. Our  
code become easier to test without requiring too much boilerplate  
code using a DI container.


WO does a bit of that on its own (such as session and application  
injection in components), but doesn't bundle a container that a  
developer could use for the custom "services" (unlike say  
Tapestry, that does have a DI container at its core).
Say I have a WO application and I'd like to use Spring or Guice to  
inject custom services in the WOComponents, instead of looking  
them up in WOApplication (or worse - defining them as static  
singletons somewhere). This sounds easy on the surface. I don't  
remember all the component creation internals now (it's been a  
while since I poked around the framework code), but I am pretty  
sure I can create them with my own factory that is DI container  
aware. On the other hand (also because I've been out of the loop  
on WO for quite some time), I am sure I am missing some pieces of  
the puzzle that would make such setup less practical or outright  
painful.


Instead of changing component creation internals, we've created an  
extension of ERXComponent that obtain the injector and inject the  
required members. It is not a perfect solution (you can't use  
constructor injection this way), but it is easy to implement.


This and the fact that DI capabilities don't seem to bother the  
rest of the community, I figured I'd ask the list on your  
opinions, while I am trying to wire this thing up in the background.

So anybody played with DI-on-WO in some form with any success?


We have an audit framework completely based on Guice. We have  
created extensions of other important classes to make it possible,  
like ERXGenericRecord and ERXEC and we have created a  
@WOSessionScoped scope to create/obtain objects per WOSession.


We are planning to create an open source framework with this stuff.  
We are just polishing what we've done to use some new features of  
Guice 2.0.


Cheers,

Henrique


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/anjo%40krank.net

This email sent to a...@krank.net


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


DirectAction with cookies and session

2009-09-21 Thread Fred Wells
Hello,
If I missed this I apologize but I can't seem to find anything on this. 
I'm trying to test out SWFUpload within one of my WO apps. 
It is currently set up to store sessionID in cookies. SWFUpload needs a 
post-upload URL for processing, I need the session information to be
available to that URL. I can't seem to get DirectAction to 
'isSessionIDInRequest' always comes up false and 'sessionID' always is 
null. I've tried
constructing the URL through WOActionURL and 
'directActionURLForActionNamed'. Both make a [what looks like] a valid 
directaction URL.
But when sent it never finds the session from the cookie. Is there 
something else I have to do when trying to use a DirectAction in a 
session?

thanks.

-fw
 

Disclaimer 
The information in this email and any attachments may contain proprietary and 
confidential information that is intended for the addressee(s) only. If you are 
not the intended recipient, you are hereby notified that any disclosure, 
copying, distribution, retention or use of the contents of this information is 
prohibited.  When addressed to our clients or vendors, any information 
contained in this e-mail or any attachments is subject to the terms and 
conditions in any governing contract. If you have received this e-mail in 
error, please immediately contact the sender and delete the e-mail.
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Very interesting case

2009-09-21 Thread Don Lindsay

Hello;

I have a component that I am updating a table of answers based on  
selections made by the user from a worepitition.


The code being executed is:

try {
String sEoQualifierText  = "page=";
			sEoQualifierText +=  
Integer.toString((Integer)thePage().valueForKey("identifier"));

sEoQualifierText += " and question=";
			sEoQualifierText +=  
Integer.toString((Integer)theQuestion().valueForKey("identifier"));

sEoQualifierText += " and user=";
			sEoQualifierText += Integer.toString((Integer) 
((EOEnterpriseObject)theUser).valueForKey("identifier"));
			EOQualifier oQual =  
EOQualifier.qualifierWithQualifierFormat(sEoQualifierText,null);
			EOFetchSpecification oFetch = new  
EOFetchSpecification("UserAnswers",oQual,null);

NSArray aAnswer = 
oEO().objectsWithFetchSpecification(oFetch);
oEO().lock();
			 
((UserAnswers 
)aAnswer.objectAtIndex(0)).setTheAnswer((QuestionLookup)theAnswer());


//((EOEnterpriseObject)aAnswer.objectAtIndex(0)).willChange();
oEO().unlock();
			//System.out.println("updates to be saved: " +  
oEO().updatedObjects());

oEO().saveChanges();
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println("hiss, didn't work");
}
if (theAnswer!=null) {
			System.out.println("append to response firing "+ 
(String)theAnswer.valueForKey("desc"));

} else {
			System.out.println("append to response firing but the answer is  
null");

}

ThePage is an item from a listing of available pages repetition.
TheQuestion is an item from listing of questions repitition.
TheUser is the user who is currently working with the page.

The entity has 4 attributes (user, page, question, answer).

When I turn on EO Debugging I see that an update is made, but when I  
check the database the answer is always null.  I do not get any errors  
in the logs.  If I had an error I could start working it out.


Anyone have any ideas?

Thanks

Don


 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: AjaxAutoComplete - is it possible to have the equivalent of a noDisplayString?

2009-09-21 Thread J Stephanos
Kieran:

Thanks - Ajax*TextHinter* works beautifully!
This is an example  of* Y*et *A*nother *W*onder *N*ugget!

David:
> Unfortunately the text triggers an immediate search on the default string.


It doesn't in my case.  It is working as expected for me per the
AjaxTextHinter javadoc example.

Thanks again.

--JSt

On Mon, Sep 21, 2009 at 1:21 PM, David Holt  wrote:

>
> On 21-Sep-09, at 9:09 AM, Kieran Kelleher wrote:
>
>  I believe AjaxTextHinter in Wonder/Ajax is what you want.
>>
>
> This is really cool. I just tried it in an auto search field (like the
> example in AjaxExample2). Unfortunately the text triggers an immediate
> search on the default string. Do you know if there is a way to disable that
> behaviour so that the default text is just treated like a label and not
> treated as content of the text field?
>
>
>> On Sep 21, 2009, at 11:33 AM, J Stephanos wrote:
>>
>>  Wonder's AjaxAutoComplete works great - but is it possible to have the
>>> equivalent of a noDisplayString?
>>>
>>> Movie Name:  [ enter a movie name here ]
>>>
>>> We'd like to provide some hint ("enter movie name here")  to the user, to
>>> enter a movie name in the field. It should disappear when you start typing
>>> in the text.   Is this feature already there? Couldn't find it in the
>>> javadoc.
>>>
>>> TIA.
>>>
>>> --JSt
>>> ___
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
>>> Help/Unsubscribe/Update your Subscription:
>>> http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists%
>>> 40mac.com
>>>
>>> This email sent to kieran_li...@mac.com
>>>
>>
>> ___
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/webobjects-dev/programmingosx%
>> 40mac.com
>>
>> This email sent to programming...@mac.com
>>
>
>
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Proper Wonder/App Initialization for testing

2009-09-21 Thread Mike Schrag
initApp is like primeApplication on Wonder steroids  ... I actually  
need to figure out exactly how to run them from Eclipse. Right now I  
run most things using an app wrapper that uses the JUnit console  
TestRunner.


On Sep 21, 2009, at 3:13 PM, Chuck Hill wrote:



On Sep 21, 2009, at 8:55 AM, Greg Brown wrote:


Hi,

I converted an app to use Wonder, and I think my tests need do do  
something new so that all the Wonder stuff initializes properly.


This page:
http://wiki.objectstyle.org/confluence/display/WONDER/Integrate+Wonder+Into+an+Existing+Application

has nothing about tests ;>o

Unit type tests seem to run fine without initializing the wonder  
frameworks, but database type (dbuinit) tests probably need the  
wonder stuff to be properly initialized.


ERXExtensions has a bunch of initApp, initEOF, initialize methods,  
which one is generally best for testNG / dbuinit initializations?  
Or do I need something like an initApp followed by a initEOF?


How do people handle this? a @BeforeSuite annotation to a method  
which calls some er.extensions.ERXExtensions.initFoo()?


In an non-Wonder app with similar startup logic, I need to call  
WOApplication.primeApplication().  See if that helps.



Chuck



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40mdimension.com

This email sent to msch...@mdimension.com



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Default form value encoding was changed after parsing multi-part form. Form values will be lost.

2009-09-21 Thread Mark Wardle
Fantastic. Works perfectly.

I think I should create a new empty PW application and check I have
all the newer properties set appropriately.

Many thanks!

Best wishes,

Mark

2009/9/21 Chuck Hill :
> Have you changed WO versions?  Do you have this in your Properties file?
>
> er.extensions.ERXApplication.DefaultEncoding=UTF-8
>
> Chuck
>
>
> On Sep 21, 2009, at 12:34 PM, Mark Wardle wrote:
>
>> Hi all,
>>
>> I have a component that edits a specific EO allowing upload of a user
>> photo. Using WO 5.4.3 on Snow Leopard,
>> java.runtime.version=1.6.0_15-b03-219, Project Wonder (revision 9861).
>>
>> It used to work. Something changed - my code, leopard->snow leopard,
>> project wonder? I don't know what!
>>
>> Suddenly the component was editing objects that failed validation and
>> it was not clear why. I realised that a form submission seemed to be
>> going wrong (no form values were passed). Eventually I removed the
>> WOUpload component out of desperation and then started receiving this
>> exception:
>>
>> Sep 21 19:31:14 rsdb[52783] WARN  NSLog  -
>> :
>> Exception occurred while handling request:
>> java.lang.IllegalStateException: Default form value encoding was
>> changed after parsing multi-part form. Form values will be lost.
>> [2009-9-21 19:31:14 BST] 
>> java.lang.IllegalStateException: Default form value encoding was
>> changed after parsing multi-part form. Form values will be lost.
>>
>> Aha! A clue. I can solve the problem by removing the WOUpload
>> component AND removing the enctype from the WOForm:
>>
>> > action = "$saveChangesAction">
>> ...
>> 
>>
>> There are many posts on the subject of UTF-8 and UTF8, including on
>> the wiki and even in the apple documentation. However, there doesn't
>> seem to be much consensus and it looks like most of the answers
>> revolve around setting encoding at the end of generating a response
>> (in Application class) and setting the formencoding (in the
>> Application and Session classes). These don't work; they don't cause
>> problems but don't solve the problem. I suspect I'm getting UTF-8
>> encoding anyway from what I get log from different points in the
>> RR-loop.
>>
>> I don't manually set encoding and my application is fully Project
>> Wonder'd; ERXSession, ERXApplication etc., and by the looks of the
>> source code, the encoding should be correctly intuited.
>>
>> Obviously, without the "multipart/form-data" setting, WOUpload
>> (ERXWOUpload) complains.
>>
>> Any ideas? I'm sure this was working.
>>
>> Many thanks,
>>
>> Mark
>>
>> -- Dr. Mark Wardle
>> Specialist registrar, Neurology
>> Cardiff, UK
>> ___
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
>> Help/Unsubscribe/Update your Subscription:
>>
>> http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net
>>
>> This email sent to ch...@global-village.net
>
> -- Chuck Hill             Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their overall
> knowledge of WebObjects or who are trying to solve specific problems.
> http://www.global-village.net/products/practical_webobjects
>
>
>
>
>
>
>
>



-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Default form value encoding was changed after parsing multi-part form. Form values will be lost.

2009-09-21 Thread Chuck Hill

Have you changed WO versions?  Do you have this in your Properties file?

er.extensions.ERXApplication.DefaultEncoding=UTF-8

Chuck


On Sep 21, 2009, at 12:34 PM, Mark Wardle wrote:


Hi all,

I have a component that edits a specific EO allowing upload of a user
photo. Using WO 5.4.3 on Snow Leopard,
java.runtime.version=1.6.0_15-b03-219, Project Wonder (revision 9861).

It used to work. Something changed - my code, leopard->snow leopard,
project wonder? I don't know what!

Suddenly the component was editing objects that failed validation and
it was not clear why. I realised that a form submission seemed to be
going wrong (no form values were passed). Eventually I removed the
WOUpload component out of desperation and then started receiving this
exception:

Sep 21 19:31:14 rsdb[52783] WARN  NSLog  -
:
Exception occurred while handling request:
java.lang.IllegalStateException: Default form value encoding was
changed after parsing multi-part form. Form values will be lost.
[2009-9-21 19:31:14 BST] 
java.lang.IllegalStateException: Default form value encoding was
changed after parsing multi-part form. Form values will be lost.

Aha! A clue. I can solve the problem by removing the WOUpload
component AND removing the enctype from the WOForm:


...


There are many posts on the subject of UTF-8 and UTF8, including on
the wiki and even in the apple documentation. However, there doesn't
seem to be much consensus and it looks like most of the answers
revolve around setting encoding at the end of generating a response
(in Application class) and setting the formencoding (in the
Application and Session classes). These don't work; they don't cause
problems but don't solve the problem. I suspect I'm getting UTF-8
encoding anyway from what I get log from different points in the
RR-loop.

I don't manually set encoding and my application is fully Project
Wonder'd; ERXSession, ERXApplication etc., and by the looks of the
source code, the encoding should be correctly intuited.

Obviously, without the "multipart/form-data" setting, WOUpload
(ERXWOUpload) complains.

Any ideas? I'm sure this was working.

Many thanks,

Mark

--  
Dr. Mark Wardle

Specialist registrar, Neurology
Cardiff, UK
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net

This email sent to ch...@global-village.net


--  
Chuck Hill Senior Consultant / VP Development


Practical WebObjects - for developers who want to increase their  
overall knowledge of WebObjects or who are trying to solve specific  
problems.

http://www.global-village.net/products/practical_webobjects







___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Default form value encoding was changed after parsing multi-part form. Form values will be lost.

2009-09-21 Thread Mark Wardle
Hi all,

I have a component that edits a specific EO allowing upload of a user
photo. Using WO 5.4.3 on Snow Leopard,
java.runtime.version=1.6.0_15-b03-219, Project Wonder (revision 9861).

It used to work. Something changed - my code, leopard->snow leopard,
project wonder? I don't know what!

Suddenly the component was editing objects that failed validation and
it was not clear why. I realised that a form submission seemed to be
going wrong (no form values were passed). Eventually I removed the
WOUpload component out of desperation and then started receiving this
exception:

Sep 21 19:31:14 rsdb[52783] WARN  NSLog  -
:
Exception occurred while handling request:
java.lang.IllegalStateException: Default form value encoding was
changed after parsing multi-part form. Form values will be lost.
[2009-9-21 19:31:14 BST] 
java.lang.IllegalStateException: Default form value encoding was
changed after parsing multi-part form. Form values will be lost.

Aha! A clue. I can solve the problem by removing the WOUpload
component AND removing the enctype from the WOForm:


...


There are many posts on the subject of UTF-8 and UTF8, including on
the wiki and even in the apple documentation. However, there doesn't
seem to be much consensus and it looks like most of the answers
revolve around setting encoding at the end of generating a response
(in Application class) and setting the formencoding (in the
Application and Session classes). These don't work; they don't cause
problems but don't solve the problem. I suspect I'm getting UTF-8
encoding anyway from what I get log from different points in the
RR-loop.

I don't manually set encoding and my application is fully Project
Wonder'd; ERXSession, ERXApplication etc., and by the looks of the
source code, the encoding should be correctly intuited.

Obviously, without the "multipart/form-data" setting, WOUpload
(ERXWOUpload) complains.

Any ideas? I'm sure this was working.

Many thanks,

Mark

-- 
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Multi-Tenant Data Architecture

2009-09-21 Thread Chuck Hill

Hi Henrique,

On Sep 19, 2009, at 8:09 AM, Henrique Prange wrote:


Hi all,

Is there a way to configure EOF to access separate databases for  
each tenant in *one* application?


I'm working in an application that has a strong non-functional  
requirement on multi-tenant architecture with isolated database  
access.


I've seen some discussion related with this subject, but it was not  
clear to me how could I implement this kind of stuff.


Any directions are really appreciated.



The easiest, and perhaps best, way to do this is to have different  
instances for each tenant.  The configuration (in JavaMonitor or  
elsewhere) can then specify the database.


Pros:
- easy
- problems / load on one tenant do not impact others
- guaranteed that one tenant will not accidently see information from  
another



Cons:
- more instances to administer
- some increase in RAM usage due to duplicated loading of code and JVM


If you don't want to do that and are committed to doing this in one  
instance, the next best way is to tag the root object with the  
tenant.  But you said "separate databases", so that is ruled out.


The only way that I can think of to accomplish what you want is to  
create an EOModelGroup for each tenant.  A separate copy of each model  
will need to be loaded into each group and the database connection  
information set for that tenant.  Each EOModelGroup will serve as the  
basis for a new EOF stack (rooted at EOObjectStoreCoordinator).  When  
a session is created, you will need to ensure that all editing  
contexts created for that session use the correct  
EOObjectStoreCoordinator.  You will also want to ensure that you don't  
use default in  your code (defaultEditingContext(),  
defaultModelGroup() etc.) as these are unlikey to return objects from  
the correct EOF stack.  Caveat: this is theoretical, I don't have any  
experience doing this.  I don't think that many people have done this,  
so you run the risk of finding bugs in seldom executed EOF code.



Chuck


--
Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their  
overall knowledge of WebObjects or who are trying to solve specific  
problems.

http://www.global-village.net/products/practical_webobjects







___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Andrus Adamchik

Hi Henrique,

Nice, thanks for sharing this info. Yeah, going through WOApplication  
and WOComponentDefinition, I realized I was too optimistic. Most  
interesting methods that would've enabled DI integration are all  
private. Quite a bit of code to rewrite to make it work. I was even  
thinking of limiting injection to just the Application class.


Great that you are willing to open source your work in this area. Even  
if you load your code in its current state to a public SVN  
(ObjectStyle.org is always an option) or git somewhere, it will be a  
rather helpful example.


Cheers,
Andrus

-
Andrus Adamchik
Apache Cayenne ORM: http://cayenne.apache.org/
Creator of Cayenne, VP Apache Software Foundation


On Sep 21, 2009, at 6:18 PM, Henrique Prange wrote:

Hi Andrus,

Andrus Adamchik wrote:
I know it is not the traditional "WO way" of doing things, but from  
my experience using a dependency injection container in your app  
(Spring, Guice, etc.) is one single thing that you can do to  
dramatically improve the design quality, and produce flexible and  
maintainable code.


We have been using Guice with WO for some time in our projects. Our  
code become easier to test without requiring too much boilerplate  
code using a DI container.


WO does a bit of that on its own (such as session and application  
injection in components), but doesn't bundle a container that a  
developer could use for the custom "services" (unlike say Tapestry,  
that does have a DI container at its core).
Say I have a WO application and I'd like to use Spring or Guice to  
inject custom services in the WOComponents, instead of looking them  
up in WOApplication (or worse - defining them as static singletons  
somewhere). This sounds easy on the surface. I don't remember all  
the component creation internals now (it's been a while since I  
poked around the framework code), but I am pretty sure I can create  
them with my own factory that is DI container aware. On the other  
hand (also because I've been out of the loop on WO for quite some  
time), I am sure I am missing some pieces of the puzzle that would  
make such setup less practical or outright painful.


Instead of changing component creation internals, we've created an  
extension of ERXComponent that obtain the injector and inject the  
required members. It is not a perfect solution (you can't use  
constructor injection this way), but it is easy to implement.


This and the fact that DI capabilities don't seem to bother the  
rest of the community, I figured I'd ask the list on your opinions,  
while I am trying to wire this thing up in the background.

So anybody played with DI-on-WO in some form with any success?


We have an audit framework completely based on Guice. We have  
created extensions of other important classes to make it possible,  
like ERXGenericRecord and ERXEC and we have created a  
@WOSessionScoped scope to create/obtain objects per WOSession.


We are planning to create an open source framework with this stuff.  
We are just polishing what we've done to use some new features of  
Guice 2.0.


Cheers,

Henrique


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Proper Wonder/App Initialization for testing

2009-09-21 Thread Chuck Hill


On Sep 21, 2009, at 8:55 AM, Greg Brown wrote:


Hi,

I converted an app to use Wonder, and I think my tests need do do  
something new so that all the Wonder stuff initializes properly.


This page:
http://wiki.objectstyle.org/confluence/display/WONDER/Integrate+Wonder+Into+an+Existing+Application

has nothing about tests ;>o

Unit type tests seem to run fine without initializing the wonder  
frameworks, but database type (dbuinit) tests probably need the  
wonder stuff to be properly initialized.


ERXExtensions has a bunch of initApp, initEOF, initialize methods,  
which one is generally best for testNG / dbuinit initializations? Or  
do I need something like an initApp followed by a initEOF?


How do people handle this? a @BeforeSuite annotation to a method  
which calls some er.extensions.ERXExtensions.initFoo()?


In an non-Wonder app with similar startup logic, I need to call  
WOApplication.primeApplication().  See if that helps.



Chuck



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Optimistic Locking?

2009-09-21 Thread Kieran Kelleher
Be careful if you use multiple OSCs and OSC Synchrnoization (Wonder  
ERJGroupsSynchronizer for example). In that event you must lock the  
stack during your (short) transaction in which you check for  
optimistic lock exception as part of business logic.


For conceptual and optimistic locking discussion, see this thread by  
Miguel Arroz (Dr. Survs ;-)  )

http://terminalapp.net/dr-optimistic-locking/

BTW, you can create an OptimisticLockAction class to simplify the  
code. For inspiration see ERXEOAccessUtilities.ChannelAction.


HTH, Kieran


On Sep 21, 2009, at 4:19 AM, Andrew Lindesay wrote:


Hi Chan;

In general, optimistic locking will put an extra helping of WHERE  
clause at the end of your UPDATE statements. The extra WHERE clause  
is to check that nothing has changed in the database row since the  
enterprise-object was fetched from the database -- ie; check to make  
sure nobody else has fiddled the row.  So if the row from table FOO  
was fetched with { A=2, B=20 } then a possible UPDATE statement  
(with optimistic locking "A" and "B") would be;


UPDATE FOO SET A=123 WHERE A=2 AND B=20

To see this, turn on SQL logging in your WebObjects application.

cheers.


How do I tell if Optimistic Locking is working?
I've made a EOF Model with a versions field. Everything but the id  
and the versions field has the lock symbol unchecked in WoLIPS. In  
my EOEditingContext delegate's editingContextWillSaveChanges method  
I incremented the versions field by 1. I opened up a web page that  
edits the EOF model, then used another app to change the versions  
number in the database. I made some changes to the EOF model via  
the web page and did a save. I don't get an error.
Is there something I need to turn on? A flag of some sort? Or am I  
misunderstanding how Optimistic Locking works?


___
Andrew Lindesay
www.lindesay.co.nz

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists%40mac.com

This email sent to kieran_li...@mac.com


 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: AjaxAutoComplete - is it possible to have the equivalent of a noDisplayString?

2009-09-21 Thread David Holt


On 21-Sep-09, at 9:09 AM, Kieran Kelleher wrote:


I believe AjaxTextHinter in Wonder/Ajax is what you want.


This is really cool. I just tried it in an auto search field (like  
the example in AjaxExample2). Unfortunately the text triggers an  
immediate search on the default string. Do you know if there is a way  
to disable that behaviour so that the default text is just treated  
like a label and not treated as content of the text field?




On Sep 21, 2009, at 11:33 AM, J Stephanos wrote:

Wonder's AjaxAutoComplete works great - but is it possible to have  
the equivalent of a noDisplayString?


Movie Name:  [ enter a movie name here ]

We'd like to provide some hint ("enter movie name here")  to the  
user, to enter a movie name in the field. It should disappear when  
you start typing in the text.   Is this feature already there?  
Couldn't find it in the javadoc.


TIA.

--JSt
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists% 
40mac.com


This email sent to kieran_li...@mac.com


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/programmingosx 
%40mac.com


This email sent to programming...@mac.com


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Proper Wonder/App Initialization for testing

2009-09-21 Thread Ray Kiddy


On Sep 21, 2009, at 8:55 AM, Greg Brown wrote:


Hi,

I converted an app to use Wonder, and I think my tests need do do  
something new so that all the Wonder stuff initializes properly.


This page:
http://wiki.objectstyle.org/confluence/display/WONDER/Integrate+Wonder+Into+an+Existing+Application

has nothing about tests ;>o



You are right and something can certainly be added. Have you seen http://wiki.objectstyle.org/confluence/display/WONDER/Testing 
 and the pages it points to? If you have suggestions for content to  
add to those pages, I would be glad to discuss it. Or you can add  
whatever you think needs to be added.


Unit type tests seem to run fine without initializing the wonder  
frameworks, but database type (dbuinit) tests probably need the  
wonder stuff to be properly initialized.




I assume you mean dbunit, yes? How do you invoke the tests you have  
now? I looked at dbunit quite a while ago. Things are probably at the  
point where I should look at it again. For example, I was planning on  
making use of the Memory EOAdaptor in a bunch of tests.


I have just started to put junit tests that do EOF-ish stuff into the  
tests in the ERExtensions framework in Project Wonder, which can be  
checked out with svn. I have things set up to parameterize the tests  
so that we can run all the tests with one model, and then another and  
so on. There are, right now, some issues with running tests that use  
more than one EOAdaptor. So, I have checked in test that can  
parameterize on more than one model, but they do not.



ERXExtensions has a bunch of initApp, initEOF, initialize methods,  
which one is generally best for testNG / dbuinit initializations? Or  
do I need something like an initApp followed by a initEOF?




I am not sure you are looking at the right things, or I may not  
understand your question. One can initialize EOF by getting the  
default EOModelGroup (from the static defaultGroup() method), adding a  
model to it and fetching objects from that model. Or one can get an  
instance of an EOAdaptor (EOAdaptor.adaptorWithName()), set the  
connection dictionary properly, and call createAdaptorContext() on the  
adaptor to get a context, then createAdaptorChannel() on the context  
to get a channel and then opening the channel.


Basically, EOF is self-(lazily)-initializing. Or rather, it is as lazy  
as it can be.


How do people handle this? a @BeforeSuite annotation to a method  
which calls some er.extensions.ERXExtensions.initFoo()?




Again, it depends on how you are invoking the tests you have now.

We have different people who run different kinds of tests and invoke  
them in very different ways. I am trying to find methods of testing  
that span methods of test management and invocation. So, if you can  
explain what you want to do and you use tests and want to use tests,  
this will help broaden the use cases.


cheers - ray

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Rewrite Rule

2009-09-21 Thread Guido Neitzer

Are you running in WebServer connect mode?

cug

--  
http://www.event-s.net


On 20. Sep. 2009, at 02:02 , ute Hoffmann wrote:


Hi,
should this work for applications which have a session as well,
or will it work only for sessionless apps?

 * 
 * er.extensions.ERXApplication.replaceApplicationPath.pattern=/cgi- 
bin/WebObjects/YourApp.woa
 * er.extensions.ERXApplication.replaceApplicationPath.replace=/ 
yourapp

 * 
 *
 * and in Apache 2.2:
 * 
 * RewriteRule ^/yourapp(.*)$ /cgi-bin/WebObjects/YourApp.woa$1 [PT,L]
 * 
 *
 * or Apache 1.3:
 * 
 * RewriteRule ^/yourapp(.*)$ /cgi-bin/WebObjects/YourApp.woa$1 [P,L]
 * 

I put it into the properties file of an Application, but nothing  
changed in the way the URL's were displayed.


I use WOHyperlinks which call directActions with parameters and have  
a session.


I have the Application extend a Application class in a framework  
which then in turn extends ERXApplication.
Could that be part of my problem? But the Application starts up ok,  
and the added properties are in the logfile,

so I THINK they should be seen...

Probably this is very basic, sorry.

Thanks for your help.

Regards,

Ute
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/guido.neitzer%40gmail.com

This email sent to guido.neit...@gmail.com


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: AjaxAutoComplete - is it possible to have the equivalent of a noDisplayString?

2009-09-21 Thread Kieran Kelleher

I believe AjaxTextHinter in Wonder/Ajax is what you want.

On Sep 21, 2009, at 11:33 AM, J Stephanos wrote:

Wonder's AjaxAutoComplete works great - but is it possible to have  
the equivalent of a noDisplayString?


Movie Name:  [ enter a movie name here ]

We'd like to provide some hint ("enter movie name here")  to the  
user, to enter a movie name in the field. It should disappear when  
you start typing in the text.   Is this feature already there?  
Couldn't find it in the javadoc.


TIA.

--JSt
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists%40mac.com

This email sent to kieran_li...@mac.com


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Proper Wonder/App Initialization for testing

2009-09-21 Thread Greg Brown

Hi,

I converted an app to use Wonder, and I think my tests need do do  
something new so that all the Wonder stuff initializes properly.


This page:
http://wiki.objectstyle.org/confluence/display/WONDER/Integrate+Wonder 
+Into+an+Existing+Application


has nothing about tests ;>o

Unit type tests seem to run fine without initializing the wonder  
frameworks, but database type (dbuinit) tests probably need the  
wonder stuff to be properly initialized.


ERXExtensions has a bunch of initApp, initEOF, initialize methods,  
which one is generally best for testNG / dbuinit initializations? Or  
do I need something like an initApp followed by a initEOF?


How do people handle this? a @BeforeSuite annotation to a method  
which calls some er.extensions.ERXExtensions.initFoo()?




Thanks,

gb


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: HTTPS Connection

2009-09-21 Thread Kieran Kelleher

Don't waste your time with WOHttpConnection.

Use Apache HttpClient.
http://hc.apache.org/httpclient-3.x/


On Sep 21, 2009, at 10:44 AM, WebObjects - Anazys wrote:


Hi all,

I'm trying to handle transaction with a bank module.. not really  
easy..
Is it possible to send https request under WOHTTPConnection and  
ERXRequest ?

I try many ways but nothing really work as I want.
My code :
	WOHTTPConnection httpConn = new WOHTTPConnection( , 
443 );
	ERXRequest request = new ERXRequest( "POST", param1=value1..>, "HTTP/1.1", null, null, null );


Any help ?
Thanks
Cedric
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/kieran_lists%40mac.com

This email sent to kieran_li...@mac.com


___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


AjaxAutoComplete - is it possible to have the equivalent of a noDisplayString?

2009-09-21 Thread J Stephanos
Wonder's AjaxAutoComplete works great - but is it possible to have the
equivalent of a noDisplayString?

Movie Name:  [ enter a movie name here ]

We'd like to provide some hint ("enter movie name here")  to the user, to
enter a movie name in the field. It should disappear when you start typing
in the text.   Is this feature already there? Couldn't find it in the
javadoc.

TIA.

--JSt
 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: WebObjects and dependency injection (DI)

2009-09-21 Thread Henrique Prange

Hi Andrus,

Andrus Adamchik wrote:
I know it is not the traditional "WO way" of doing things, but from my 
experience using a dependency injection container in your app (Spring, 
Guice, etc.) is one single thing that you can do to dramatically improve 
the design quality, and produce flexible and maintainable code.




We have been using Guice with WO for some time in our projects. Our code 
become easier to test without requiring too much boilerplate code using 
a DI container.


WO does a bit of that on its own (such as session and application 
injection in components), but doesn't bundle a container that a 
developer could use for the custom "services" (unlike say Tapestry, that 
does have a DI container at its core).


Say I have a WO application and I'd like to use Spring or Guice to 
inject custom services in the WOComponents, instead of looking them up 
in WOApplication (or worse - defining them as static singletons 
somewhere). This sounds easy on the surface. I don't remember all the 
component creation internals now (it's been a while since I poked around 
the framework code), but I am pretty sure I can create them with my own 
factory that is DI container aware. On the other hand (also because I've 
been out of the loop on WO for quite some time), I am sure I am missing 
some pieces of the puzzle that would make such setup less practical or 
outright painful.




Instead of changing component creation internals, we've created an 
extension of ERXComponent that obtain the injector and inject the 
required members. It is not a perfect solution (you can't use 
constructor injection this way), but it is easy to implement.


This and the fact that DI capabilities don't seem to bother the rest of 
the community, I figured I'd ask the list on your opinions, while I am 
trying to wire this thing up in the background.


So anybody played with DI-on-WO in some form with any success?



We have an audit framework completely based on Guice. We have created 
extensions of other important classes to make it possible, like 
ERXGenericRecord and ERXEC and we have created a @WOSessionScoped scope 
to create/obtain objects per WOSession.


We are planning to create an open source framework with this stuff. We 
are just polishing what we've done to use some new features of Guice 2.0.


Cheers,

Henrique
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


HTTPS Connection

2009-09-21 Thread WebObjects - Anazys

Hi all,

I'm trying to handle transaction with a bank module.. not really easy..
Is it possible to send https request under WOHTTPConnection and  
ERXRequest ?

I try many ways but nothing really work as I want.
My code :
WOHTTPConnection httpConn = new WOHTTPConnection( ,443 );
	ERXRequest request = new ERXRequest( "POST", param1=value1..>, "HTTP/1.1", null, null, null );


Any help ?
Thanks
Cedric
___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


WebObjects and dependency injection (DI)

2009-09-21 Thread Andrus Adamchik
I know it is not the traditional "WO way" of doing things, but from my  
experience using a dependency injection container in your app (Spring,  
Guice, etc.) is one single thing that you can do to dramatically  
improve the design quality, and produce flexible and maintainable code.


WO does a bit of that on its own (such as session and application  
injection in components), but doesn't bundle a container that a  
developer could use for the custom "services" (unlike say Tapestry,  
that does have a DI container at its core).


Say I have a WO application and I'd like to use Spring or Guice to  
inject custom services in the WOComponents, instead of looking them up  
in WOApplication (or worse - defining them as static singletons  
somewhere). This sounds easy on the surface. I don't remember all the  
component creation internals now (it's been a while since I poked  
around the framework code), but I am pretty sure I can create them  
with my own factory that is DI container aware. On the other hand  
(also because I've been out of the loop on WO for quite some time), I  
am sure I am missing some pieces of the puzzle that would make such  
setup less practical or outright painful.


This and the fact that DI capabilities don't seem to bother the rest  
of the community, I figured I'd ask the list on your opinions, while I  
am trying to wire this thing up in the background.


So anybody played with DI-on-WO in some form with any success?

Thanks,
Andrus

-
Andrus (aka Andrei) Adamchik
Apache Cayenne ORM: http://cayenne.apache.org/
Creator, VP Apache Software Foundation



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: printing margins with LEIPPPrintService from webobjects application

2009-09-21 Thread Andrew Lindesay

Hi Johan;

Have you checked the PPD file on your CUPS server for the margins  
configured there? -- this is possibly a good first thing to check.


Otherwise, the 'LEIPPDocPrintJob' is a simple implementation of IPP  
communications and it is ignoring anything other than Media you are  
supplying it as attributes.  I could get it to pass the margins along  
with the job if it is possible, but it may be easier if you want to  
extend the method...


LEIPPDocPrintJob.getPayloadHeader(..)

...as you have the specific device on-hand to check the result.

Another option to check out;

http://www.lohndirekt.de/software/jipsi_quickstart_drucksoftware.html

It looks good although I have not used it.

Let me know how you get on.

cheers.

I am working on a eticketing system and one of the requirements is  
that the application will print out real tickets at the location  
(it's easier for access control to print humanly easy recognizable  
tickets somewhere before the access control than to check the  
barcode electronically  from a variety of paper/phone sources).
So I create a PDF document via itext.jar (replacing form fields from  
a template with the actual data) and feed that to a printer.

...
to see if that would work. The printing works, but there is a one  
inch gap on the top of the pdf document that I am sending to the  
printer.


___
Andrew Lindesay
www.lindesay.co.nz

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


printing margins with LEIPPPrintService from webobjects application

2009-09-21 Thread Johan Henselmans
I am working on a eticketing system and one of the requirements is  
that the application will print out real tickets at the location (it's  
easier for access control to print humanly easy recognizable tickets  
somewhere before the access control than to check the barcode  
electronically  from a variety of paper/phone sources).


So I create a PDF document via itext.jar (replacing form fields from a  
template with the actual data) and feed that to a printer.


I implemented  Andrew Lindesay's
LEIPPDocPrintJob
LEIPPPrintService
LEIPPPrintServiceTest

to see if that would work. The printing works, but there is a one inch  
gap on the top of the pdf document that I am sending to the printer. I  
looked at some of the solutions to get rid of the 1 inch margin that  
is on top of the document (search for hashprintrequestattributeset  
margin), but none of them seemed to give the desired result.


Does anybody have a working example to reduce the margins to zero, so  
the 8x3.25 inch PDF document would print on a 8x3.25 ticket?


I tried these:

protected HashPrintRequestAttributeSet getPrintRequestAttributeSet(){
HashPrintRequestAttributeSet as = new 
HashPrintRequestAttributeSet();
		as.add(BocaMedia.w576h234);  // the 8 inch translates to a 576 point  
document in CUPS, that's why the w576xh325 document

int x = 0; //left and right margin
int y = 0; //top and bottom margin.
int w = 576; //Width
int h = 234; //Height
int units = MediaPrintableArea.MM;
as.add(new MediaPrintableArea(x, y, w, h, units));
as.add(new JobName("ticket-page", Locale.getDefault()));
}

protected HashPrintRequestAttributeSet getPrintRequestAttributeSet()



Regards,

Johan Henselmans
http://www.netsense.nl
Tel: +31-20-6267538
Fax: +31-20-6279159



___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Optimistic Locking?

2009-09-21 Thread Andrew Lindesay

Hi Chan;

In general, optimistic locking will put an extra helping of WHERE  
clause at the end of your UPDATE statements. The extra WHERE clause is  
to check that nothing has changed in the database row since the  
enterprise-object was fetched from the database -- ie; check to make  
sure nobody else has fiddled the row.  So if the row from table FOO  
was fetched with { A=2, B=20 } then a possible UPDATE statement (with  
optimistic locking "A" and "B") would be;


UPDATE FOO SET A=123 WHERE A=2 AND B=20

To see this, turn on SQL logging in your WebObjects application.

cheers.


How do I tell if Optimistic Locking is working?
I've made a EOF Model with a versions field. Everything but the id  
and the versions field has the lock symbol unchecked in WoLIPS. In  
my EOEditingContext delegate's editingContextWillSaveChanges method  
I incremented the versions field by 1. I opened up a web page that  
edits the EOF model, then used another app to change the versions  
number in the database. I made some changes to the EOF model via the  
web page and did a save. I don't get an error.
Is there something I need to turn on? A flag of some sort? Or am I  
misunderstanding how Optimistic Locking works?


___
Andrew Lindesay
www.lindesay.co.nz

 ___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Optimistic Locking?

2009-09-21 Thread Chan Yeow Heong, Jerome

How do I tell if Optimistic Locking is working?

I've made a EOF Model with a versions field. Everything but the id and  
the versions field has the lock symbol unchecked in WoLIPS. In my  
EOEditingContext delegate's editingContextWillSaveChanges method I  
incremented the versions field by 1. I opened up a web page that edits  
the EOF model, then used another app to change the versions number in  
the database. I made some changes to the EOF model via the web page  
and did a save. I don't get an error.


Is there something I need to turn on? A flag of some sort? Or am I  
misunderstanding how Optimistic Locking works?

___
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list  (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com