Tom, I don't really know what to think about making a yet new Struts2 oriented toward JRuby on Rails but I'm sure working on a better integration between JRuby on Rails and legacy J2EE frameworks such as Struts2 would be indeed useful.
Some think Rails succeeded mainly because of ActiveRecord. Well the view part which is 'suboptimal' in Struts as you said is also certainly a reason. As for reusing the clever declarative validation language from Rails, please, bare in mind this reply I already gave to the ActiveHibernate (allow using Hibernate from JRoR) author on the JRuby mailing list: "I saw a chapter of the 'Rails Recipes' book that could help to do the trick, it's called how to use ActiveRecords validations without ActiveRecord. So if ever that helps here is the recommended way to do. May be you can include or document this for ActiveHibernate: the basic trick is to do: [i] Problem You have your own non-database-backed model objects that require validations. You would like to re-use the ActiveRecord validation frame- work to declare how these objects should be validated. You also want to take advantage of the error_messages_on( ) and error_messages_for( ) helpers in your views. How do you make your custom model objects work with ActiveRecord validations? [...] make such a module that takes the ActiveRecord validation module: module Validateable [:save, :save!, :update_attribute].each{|attr| define_method(attr){}} def method_missing(symbol, *params) if(symbol.to_s =~ /(.*)_before_type_cast$/) send($1) end end def self.append_features(base) super base.send(:include, ActiveRecord::Validations) end end Place this module in lib/validateable.rb, and you can mix it into your own non-ActiveRecord models as needed. Now, in terms of validation and error reporting, your model is virtually indistinguishable from a real ActiveRecord model. Here's an example of a non-ActiveRecord model that supports ActiveRe- cord validations. ValidatingNonARObjects/app/models/person.rb class Person include Validateable attr_accessor :age validates_numericality_of :age end To trigger the validations, just call the model's valid?( ) method in your controllers. This will both return true or false depending on whether the object passes validations and will populate the model's errors( ) so that they can be accessed from the ActiveRecord view helpers. Here's an example of how you can interact with the validations from the Rails console: chad> ruby script/console >> person = Person.new => #<Person:0x236e180> >> person.age = "NOT A NUMBER" => "NOT A NUMBER" >> person.valid? => false >> person.errors => #<ActiveRecord::Errors:0x236b430 [EMAIL PROTECTED]"NOT A NUMBER", @errors=#<ActiveRecord::Errors:0x236b430 ...>>, @errors={"age"=>["is not a number"]}> >> person.age = 30 => 30 >> person.valid? => true >> person.errors => #<ActiveRecord::Errors:0x236b430 @base=#<Person:0x236e180 @age=30..> "[/i] Hope this will help. Good luck in your implementation. Regards, Raphael Valyi. --------------------------------------------------------------------- Posted via Jive Forums http://forums.opensymphony.com/thread.jspa?threadID=172941&messageID=247866#247866 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]