StrataFrame Forum

Enforce field MaxLength in the BOM by default

http://forum.strataframe.net/Topic15074.aspx

By Edhy Rijo - 3/20/2008

As far as I know there is nothing in SF to automatically enforce the characters entered in a Textbox with respect of the field length value.

An error like this can be easily generated by the end user.

BusinessLayerException
  An error occurred while saving an the data to the server.
DataLayerSavingException
  String or binary data would be truncated.

I know I can create a lot of broken rules to validate the field Length, but I strongly believe that this should be handle by the Business Object Mapper since it has all the information needed to add this kind of validation to the BO designer file.

By Trent L. Taylor - 3/21/2008

Just set the MaxLength on the textbox so that no more than what is allowed can be entered.  You wouldn't really want to manage this through the business rules anyway (a very clumsy and dirty way to handle it).  Just set the MaxLength and you will be good.
By Edhy Rijo - 3/21/2008

Trent L. Taylor (03/21/2008)
Just set the MaxLength on the textbox so that no more than what is allowed can be entered.  You wouldn't really want to manage this through the business rules anyway (a very clumsy and dirty way to handle it).  Just set the MaxLength and you will be good.

Trent,

That is exactly my point, the BOM metadata has the field length information then enforcing this kind of rule should be more practical if done via the BOM in one single step instead of me going through all fields in all my textboxes setting the MaxLength manually and then keep remembering to do it all the time.

This is the kind of rule which is a MUST because if I don't do anything to enforce it, then the database will throw and exception which is not good for the end user.

My request is to add this kind of functionality in the BOM to either enforce this via the textbox MaxLength or to automatically generate a broken rule like this:

''' 

''' Checks the business rules on the current row

'''

Private Sub MyBusinessObject_CheckRulesOnCurrentRow(ByVal e As

MicroFour.StrataFrame.Business.CheckRulesEventArgs) Handles Me.CheckRulesOnCurrentRow

    '-- Make sure the customer's last name length is not greater than 30

    If Me.cust_lname.Length > 30 Then

        Me.AddBrokenRule(MyBusinessObjectFieldNames.cust_lname, "Last name lenght can not be more than 30 characters.")

    End If

End Sub

By Trent L. Taylor - 3/21/2008

Edhy,

I feel like we keep going around in circles here.  I have already told you, in more than one post, that we will consider adding some of this functionality down the road.  Developers create massive applicatons, everyday, including ourselves, without letting this slow us down.  It is a very simple property to set...this is not a "show-stopping" request.  You are coming from a data-driven environment...VFP.  We too came from VFP and have implemented logic into the framework with many of the good ideas that they had...the request you are making is coming from a data-dictionary environment which using thi same logic would be suicide in a large application in a disconnected data environment.

We WILL at some point add additional functionality that will bring in field lengths.  Though this should never have to be checked at the BO level...though you could do it this way, it is really pointless as you can set the MaxLength on a textbox to prevent this from ever getting to this point instead of the end-user seeing another error or warning.  So this logic is not as simple as you keep bringing up...because this 1.) needs to be optional 2.) impemented at the control level which means any control that supports text entry will need to support this logic, thus making 3rd party controls more complex. 3.) Needs to provide support for all environments versus just our controls, etc. 4.) This will require support for al database types, not just SQL Server and so it will entail checking for VarChar, NVarChar, and support for SQL Server, Oracle, DB2, VFP, Access, OLEDB, etc. 

When developing a framework and trying to appeal to the masses, it is best to make the change so that it will be respected in the broad spectrum.

Finally, if this is such a huge piece of your application, you could implement this logic in less than an hour.  If you want to take the BO approach, then inherit the BusinessLayer and create your own BoBase (which is a good idea anyway) and then add this logic to check for field lengths for your specific data type....though I would still recommend doing this at the control level.

I hope this helps you understand that I have heard you on all of your other posts and help you to understand that you can add this logic yourself very easily since it will not need to support all data types, etc.  We try to listen to all of our customers and meet their needs.  Especially in areas where there is a high-demand request...which though this is not in high-demand, we do see that there could be some things that help speed development up in the long-term.  Thanks for your input and understanding.

By Edhy Rijo - 3/21/2008

Trent L. Taylor (03/21/2008)

When developing a framework and trying to appeal to the masses, it is best to make the change so that it will be respected in the broad spectrum.

Trent,

As I said before in this forum, I am new to .NET and do appreciate any kind of input anybody here can do to help me out. Tongue

Please don't get my postings in the wrong way, if I gave you the impression of going in circle in this topic, that was not my intention.

I am in the process of converting VFP projects to VB.NET with SF, while doing this, I am learning the .NET way of doing some things and along this the SF approach to those situations, so my posts are in regard to let you guys know of things I believe may enhance SF in the future, based on my experience working with VFP frameworks, of course that does not necesarily means that I want that feature today, or that it is a valid doable feature.

I hope this helps you understand that I have heard you on all of your other posts and help you to understand that you can add this logic yourself very easily since it will not need to support all data types, etc.  We try to listen to all of our customers and meet their needs.  Especially in areas where there is a high-demand request...which though this is not in high-demand, we do see that there could be some things that help speed development up in the long-term.  Thanks for your input and understanding.

Since you made the suggestion, I am already using the MaxLength property Tongue.  So far, nothing is a show stopper for me Hehe the easy way would be to keep building solutions for my customers with VFP and here I am in the .NET world using the framework I believe is closest to what I am used to, and believe me it took me a while to review other framework vendor and decided to stay and invest in SF, and one of the major reason for my decision is the kind of support provided by you and the other SF team members.

Anyway, thanks for the points!!!Wink

By Trent L. Taylor - 3/21/2008

No problem, Edhy.  It is 100% our desire to add anything to the framework that will enhance not our our development experience, but every developer that uses SF.  We listen to every suggestion made from every developer and we discuss and determine which of those suggestions need to be implemented into the framework.

I understand exactly what you are going through at the moment, as do many other developers out here on this forum.  It took us a while to "break out of our shell" so to speak and finally smell the roses BigGrin  Many of the things that you are fighting is simply just trying to come from an environment in which you were comfortable and then try to apply those same techniques towards .NET.  Obviously this is met with some frustration and scratching of the head when trying to resolve your problems.

This is why we have really developers and tweaked our training classes over the years...to cover things just like this. 

At any rate, we are truly glad that you chose SF and we do appreciate your suggestions....this is how things get better!

Happy Easter...I am going to take off and spend the rest of the day with my family.  Talk to you soon.

By Greg McGuffey - 3/21/2008

I understand exactly what you are going through at the moment, as do many other developers out here on this forum. It took us a while to "break out of our shell" so to speak and finally smell the roses BigGrin Many of the things that you are fighting is simply just trying to come from an environment in which you were comfortable and then try to apply those same techniques towards .NET. Obviously this is met with some frustration and scratching of the head when trying to resolve your problems.


Can I get an "Ahmen" brothers and sisters! I vote this as the understatement of the year, both on the frustration part and the smelly roses part Wink



This is why we have really developers and tweaked our training classes over the years...to cover things just like this.


If you haven't signed up for the class yet...do it. Best training class I've ever had.



Happy Easter...I am going to take off and spend the rest of the day with my family.


Happy Easter!
By Edhy Rijo - 3/21/2008

Greg McGuffey (03/21/2008)

If you haven't signed up for the class yet...do it. Best training class I've ever had.


Hi Greg,

I have not signed up yet, but it is on my priority list. 

In my experience with other training and developer conferences, it is best when you are familiarized with the tools, and that is just what I am doing know with this project, getting to know SF.  I belive I'll be in good shape for the July class. Cool 

By Greg McGuffey - 3/21/2008

I belive I'll be in good shapefor the July class. Cool




Me too! Smooooth
By Greg McGuffey - 3/21/2008

er...Blush...what is meant was that I also believe you'll be in good shape by July...you making great progress!
By Ivan George Borges - 3/22/2008

Oh, I was already counting you on, Greg! Wink
By Edhy Rijo - 3/22/2008

Ivan George Borges (03/22/2008)
Oh, I was already counting you on, Greg! Wink

Me too!!!

Ivan, I know you have a big beer contest or something like that for the July class, I don't drink beer, but I'll buy you one (yes, just one Tongue) any size you like, if I make it to the class!

By Ivan George Borges - 3/24/2008

Hi Edhy.

Ivan, I know you have a big beer contest or something like that for the July class, I don't drink beer, but I'll buy you one (yes, just one Tongue) any size you like, if I make it to the class!

You are safe with me, then! I am a very light drinker, but it is going to be a pleasure to have one with you, and just tell me what you prefer instead of the beer. BigGrin

Hope you can make it. Where are you going to be coming from?

By Edhy Rijo - 3/24/2008

Ivan George Borges (03/24/2008)

... and just tell me what you prefer instead of the beer. BigGrin

Hope you can make it. Where are you going to be coming from?

Well, I prefer Steaks and Ice Tea Wow

I live in New York, so it will be a couple of hours trip, of course I won't drive w00t

By Trent L. Taylor - 3/24/2008

Truth be told...we all like to talk big, but everyone (that has posted so far and that I know) including myself, are very light drinkers BigGrin ...but it is more fun to talk big BigGrin

Yeah, we actually have people already coming from as far away as Denmark...so I am pretty sure they aren't driving either Tongue

By Teddy Jensen - 3/24/2008

Yeah, we actually have people already coming from as far away as Denmark...so I am pretty sure they aren't driving either

No - I'm definitely not driving BigGrin it is a three flight trip each way. But i have been there before and know the class is worth it and Ivan is buying the beers.BigGrin

/Teddy

By Ivan George Borges - 3/24/2008

Teddy, I won't even mind if you bring one of those small glasses you showed us. Hehe

http://www.ahajokes.com/crt001.html

By Alex Luyando - 12/8/2008

I don't mean to pour salt into old wounds, but...



I have a question concerning the BO v. control-based validation of value lengths. In apps where essentially all data entry is via forms/controls, maxlength seems like a nice, clean approach. If SF can automatically set (and update when the underlying column widths change) those values based on BOM metadata for us, even better since I don't get any rush setting .maxlength properties these days.



If, however, the app deals with data mining or other importing of external data sans a UI (but using a BO), then the control-based solution is perhaps a bit less of a solution? In my past (VFP/Visual FoxExpress) life as well as my current reincarnation (C#/StrataFrame) it seems I am always dealing with importing of significant amounts of data and I would love to have my BOs deal with whatever it can without requiring my taking time for more complex business logic implementation.



Just interested in everyone's comments on the above... without getting too intense or fanatical... At the end of the day we're all here 'cause we luv SF!!!



Thanks.
By Edhy Rijo - 12/8/2008

Hi Alex,

I agreed with you and would also like to see this implemented/managed via the BOM in a near update. Hehe

By Trent L. Taylor - 12/9/2008

Max length is already on the slate to be implemented at the control level.  The BO already has the field lengths so it is just a matter of implementing logic within controls such as the textbox, etc. to prevent field length issues.  This would obviosuly be a flag that would force the max length.  So this is already on the slate to be implemented.
By Alex Luyando - 12/9/2008

Trent L. Taylor (12/09/2008)
Max length is already on the slate to be implemented at the control level. The BO already has the field lengths so it is just a matter of implementing logic within controls such as the textbox, etc. to prevent field length issues. This would obviosuly be a flag that would force the max length. So this is already on the slate to be implemented.




Trent -



Super, and thanks!



________________

_____/ Regards,

____/ al
By Edhy Rijo - 12/9/2008

Great!
By Luiz Lima - 1/22/2010

Guys,

My team did a class to control something like that (see attached file).

You only write something like that:

fixFormFieldsMaxLength(formname)

Enjoy it!

Luiz

By Fabian R Silva, - - 12/21/2011

thank you so much, I needed something like this. Smile

Luiz Lima (1/22/2010)
Guys,

My team did a class to control something like that (see attached file).You only write something like that:

fixFormFieldsMaxLength(formname)

Enjoy it!

Luiz

By Ger Cannoll - 12/21/2011

Hi

Just wondering if this does anything different to the facility that is there now as standard in StartaFrame ?
By Trent L. Taylor - 12/22/2011

I am not sure what you mean by "facility".  But for quite a while now, we have already had a property on the TextBox called AutoAdjustMaxLength that when set, automatically adjusts the max length of the field.  Some of the comments in this post were prior to that property existing which is what I assume you were referring to.
By Ger Cannoll - 12/22/2011

Hi Trent.

Yes, by facility I was referring to the AutoAdjustMaxLength proerty... just could not remember the name of it. Thanks for clarifying