Martin_Snyder | 6 Dec 2004 01:22
Picon
Favicon

Re: Question about SRecordInstance.validateRecord()


I'm just using plain old JSP/Java.  I'm really not a big fan of JSTL,
mainly because I don't see a big advantage of the notation below vs:

  <%= Class.someStaticMethod(args) %> or similar.

I understand the general need, but when a project team is mainly
composed of Java developers, I think they have an easier time with the
"old" notation.

Along these lines though, I have some classes which implement exactly
what you have below.  One class can take a recordset and display a
table of the records.  The other takes an object and builds an HTML
form (and processes the submitted changes).  It can also handle new
object creation.

I don't consider them worthy of submission yet, but I'd be happy to
send them along for your review to see if it might save you some time.
 Also, you could easily put a JSTL wrapper around my classes to offer
users both interfaces.

As for other elements, I've just developed my own simple framework. 
I'm a minimalist (hence the attraction of SimpleORM) and I've *very*
wary of deployment issues caused by having too many dependencies in a
Java project.  Struts carries too much weight for what I need.  I
didn't closely look at all the alternatives, but I did want to be able
to develop both a generic JSP app and a JSR 168 portlet app at a minimum.

In addition to the parts I listed in my original post, I also use the
following:
  JavaMail API (with the Java Activation Framework)
  Apache Jakarta Commons - FileUpload

Thanks for the fast reply.

--- In SimpleORM <at> yahoogroups.com, Anthony & Melissa Berglas
<berglas <at> S...> wrote:
> Hello Martin,
> 
> Looks like you have found a bug, thanks.  I'll fix it soon and
ship. 
> I'll have to think carefully about what IsDirty really means and at 
> least update the docs.
> 
> Yes, customization can sometimes be harder then just implementing. 
And 
> with implementing you know that you will eventually get to where
you 
> really want to be.
> 
> What web technology are you using?   I want to integrate SimpleOrm 
> tightly into JSP with custom tags.  So that you can write
> 
> <s:findRecord var="emp" key="${param.empId}"/>
> <table>
>    <tr><s:labeledField name="Name"/></tr>
>    <s:labeledFields group="address"/>
> </table>
> </s:record>
> <s:commit/>
> 
> The idea beign that s:labeledField would generate
>    <td>Employee Name</td>
>    <td><input id="Employee_Name" value="<s:fieldOut name="NAME"/>">
>        <s:setField name="NAME" value="${param.Employee_Name}"/>
>    </td>
> 
> And labeledfields would do the same but for all the fields marked
to be 
> addresses.
> 
> Business rules then go in the SimpleOrm definitions like you have
done. 
>   Plus a bunch of jstl sql like tags.
> 
> This integration is in sharp contrast to the separation of the 
> Struts/EJB blue print approach.  The goal is to minimize
bookkeeping 
> code rather than to maximize it!
> 
> Regards,
> 
> Anthony
> 
> Martin_Snyder wrote:
> 
> > 
> > I've been using SimpleORM for about 2-3 months now.  I'm building
a
> > JSP/Servlet application to run in Tomcat.  While the details
aren't
> > relevant to my question, I'll offer them here as I think it's
> > sometimes useful to share how a part like SimpleORM is being used.
> > 
> > JDK 1.4.2
> > Tomcat 5.0.28
> > SimpleORM
> > Postgres, Hypersonic DB support
> > 
> > The application is a simple project management application.  It
allows
> > one to create a set of requirements and then record T&M and bugs
> > against those requirements.  Aside from in-project tracking, you
can
> > later generate reports in an attempt to determine what a
particular
> > requirement cost to develop and support.  Part of the motivation
for
> > the application for me was that off the shelf solutions typically
> > require so much customization to get "just right" that I thought
I'd
> > forgo any customization steps and simply build from scratch using
a
> > bunch of freely available components.
> > 
> > My purpose in posting this is simply to be informative, I'm not
> > looking to promote or defend the application - just sharing how
I'm
> > using SimpleORM.
> > 
> > Now, on to my question.  I've added validateRecord() handlers to
all
> > of my data objects to enforce various rules.  For instance, I do
> > regexp matching on email fields and check certain fields to make
sure
> > they are not empty strings (or null).  Nothing too extravigant.
> > 
> > What I've found though is that validateRecord is only called if
> > "isDirty()" is true.  If someone writing code creates a new record
> > using createWithGeneratedKey and then commits the transaction
without
> > modifying the record, validateRecord will not be called and a
> > potentially invalid row will be inserted into the database.  This
is
> > not an impediment to me, though the behavior turned up in some
unit
> > tests that I wrote.
> > 
> > Of course there are two trivial fixes for this.  One is to change
> > isDirty() to return true if the record is newly created.  The
other is
> > to change the logic surrounding the invocation of validateRecord
to
> > make the call if the record is new or its dirty.  I'm sure there
are
> > others.
> > 
> > I haven't modified the SimpleORM code at this point to address the
> > issue, I thought I'd post here to see if anyone had any thoughts
or,
> > more importantly if I'm missing something important about new
record
> > validation.
> > 
> > 
> > 
> > 
> > 
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> > 
> > 
> >

------------------------ Yahoo! Groups Sponsor --------------------~--> 
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/SimpleORM/

<*> To unsubscribe from this group, send an email to:
    SimpleORM-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/


Gmane