Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- thufir@dur:~/ruby/file$
- thufir@dur:~/ruby/file$ telnet localhost nntp
- Trying 127.0.0.1...
- Connected to localhost.
- Escape character is '^]'.
- 200 Leafnode NNTP Daemon, version 1.11.8 running at localhost (my fqdn: dur.bounceme.net)
- GROUP comp.lang.java.help
- 211 38 3 40 comp.lang.java.help group selected
- BODY
- 222 3 <afp6m75oi6nli4b6q87s317lkc13g689c2@4ax.com> article retrieved - body follows
- On Tue, 28 Feb 2012 13:53:02 -0800 (PST), navanshu
- <mahor1989@gmail.com> wrote:
- >Uptill now i've read headfirstjava but i want to get my hands dirty by
- >making some simple java projects to get a feel how's done practically,
- >So plz suggest me guys some reference book
- Another approach might be looking at Java source code in the Java
- library classes and on SourceForge.net, github, etc.
- --
- Regards,
- Casey
- .
- BODY
- 222 3 <afp6m75oi6nli4b6q87s317lkc13g689c2@4ax.com> article retrieved - body follows
- On Tue, 28 Feb 2012 13:53:02 -0800 (PST), navanshu
- <mahor1989@gmail.com> wrote:
- >Uptill now i've read headfirstjava but i want to get my hands dirty by
- >making some simple java projects to get a feel how's done practically,
- >So plz suggest me guys some reference book
- Another approach might be looking at Java source code in the Java
- library classes and on SourceForge.net, github, etc.
- --
- Regards,
- Casey
- .
- NEXT
- 223 4 <ed7f31e9-8a19-46c7-9a7c-ad8aabfb9599@x10g2000pbi.googlegroups.com> article retrieved
- BODY
- 222 4 <ed7f31e9-8a19-46c7-9a7c-ad8aabfb9599@x10g2000pbi.googlegroups.com> article retrieved - body follows
- I have been thinking about the way I have been validating form inputs
- in the servelet and wonder if I would be much better off using class
- methods to verify these inputs?
- Consider that I am almost always gathering the inputs to instantiate
- one or more objects, but I gather and validate -- and then
- instantiate. Maybe I should instantiate an empty object and then use
- class methods to validate the inputs?
- Thanks
- .
- BODY
- 222 4 <ed7f31e9-8a19-46c7-9a7c-ad8aabfb9599@x10g2000pbi.googlegroups.com> article retrieved - body follows
- I have been thinking about the way I have been validating form inputs
- in the servelet and wonder if I would be much better off using class
- methods to verify these inputs?
- Consider that I am almost always gathering the inputs to instantiate
- one or more objects, but I gather and validate -- and then
- instantiate. Maybe I should instantiate an empty object and then use
- class methods to validate the inputs?
- Thanks
- .
- NEXT
- 223 5 <uA4ar.13560$fj7.13111@newsfe20.iad> article retrieved
- NEXT
- 223 6 <9942279.960.1332273017948.JavaMail.geo-discussion-forums@pbbpx7> article retrieved
- BODY
- 222 6 <9942279.960.1332273017948.JavaMail.geo-discussion-forums@pbbpx7> article retrieved - body follows
- Daniel Pitts wrote:
- > Davej wrote:
- >> I have been thinking about the way I have been validating form inputs
- >> in the servelet [sic] and wonder if I would be much better off using class
- >> methods to verify these inputs?
- What exactly do you mean by "class methods"? Do you mean 'static' member methods?
- >> Consider that I am almost always gathering the inputs to instantiate
- >> one or more objects, but I gather and validate -- and then
- >> instantiate. Maybe I should instantiate an empty object and then use
- >> class methods to validate the inputs?
- Maybe. It depends on what you mean by "class methods".
- > There are a few frameworks that do this in several phases actually. Its
- > called binding and validating.
- >
- > In the binding phase, values are parsed into appropriate data types, and
- > stored in the model (Form object as it is sometimes called). If the
- > data can not be parsed, or the model rejects the value immediately, it
- > is a binding error.
- >
- > In the validation phase, the values are checked for correctness. This is
- > often a secondary phase because some values are interdependent.
- >
- > If, after validation, you want to have an immutable object, then you
- > could treat your Form object more as a Builder object, and have it
- > construct the Real object, which is fully populated and validated.
- > Alternatively, you could use the Form object as a "Parameter" object for
- > a different Builder class, to keep the concerns of the Form object more
- > pure.
- >
- > I suggest looking into different frameworks, rather than trying to
- > roll-your-own. There are a lot of gotchas that can be avoided, and
- > boilerplate code you can rid yourself of. I've had moderate luck with
- > Spring Binding. If you have typical use-cases it works well. If you
- > have more complicated forms, for instance complex dynamic items, then
- > there is some shoehorning needed to make it work correctly.
- Rolling your own isn't actually that hard, but you won't get the breadth, depth or solidity of a framework with thousands of manhours invested in it already. Then again, you might not need all that.
- There are plenty of better frameworks out there than Spring. There's JSF, regular old JSP with EL and JSTL, and Struts, to name three.
- Your use of the term "class methods", OP, suggests that you need to study Java some more, and likely also servlets and presentation technologies some more. Look up the "Model 2" web-application paradigm. Then go with JSP/EL or JSF/Facelets.
- --
- Lew
- .
- QUIT
- 205 Always happy to serve!
- Connection closed by foreign host.
- thufir@dur:~/ruby/file$
Add Comment
Please, Sign In to add comment