StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Custom fields don't show up in addbrokenrule...Expand / Collapse
Author
Message
Posted 04/25/2008 4:23:10 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 12/02/2008 4:27:11 PM
Posts: 28, Visits: 394
Hi,

I have some custom fields in a business object that are used to process a credit card payment. The information isn't stored in database but does need to be validated, and then passed on to a processor.

They are all required fields, and if skipped the error pointer shows up on the form. But when I do custom validation under CheckRulesOnCurrentRow the error pointer won't show up on the form. And I can't select the field from the Addbrokenrule list either.

How can the form identify which field had the error so the error pointer shows up?

Thanks,

Marcel

P.S. -- as a side thought, is it possible to use your business objects with custom fields only? (Nothing stored to database) It seems to have problems with two-way binding, especially when the custom fields are validated, because it can't find the tablename. Just wondering since now I don't save data now, but later however might need to. Just tried to get out of setting up database right now.
Post #15881
Posted 04/25/2008 9:38:36 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 7:08:30 PM
Posts: 4,811, Visits: 4,781
I have created a sample that shows how to do this as it has come up a time or two in the past.  All you really need to do is call the AddBrokenRule method with the weak-typed call:

Me.AddBrokenRule("MyCustomField","This field requires entry.")

But I created a sample that shows how to implement this and properly setup the BO as though it were created through the BO Mapper.  You can get that sample here: http://forum.strataframe.net/FindPost15885.aspx 

as a side thought, is it possible to use your business objects with custom fields only? (Nothing stored to database) It seems to have problems with two-way binding, especially when the custom fields are validated, because it can't find the tablename. Just wondering since now I don't save data now, but later however might need to. Just tried to get out of setting up database right now

Absolutely.  There is no difference between a custom property that is created through the BO Mapper and stored data to the server versus a custom property that just stores to a variable.  The only time that you will have a two-way issue is if you do not setup the property descriptors or change the binding on the control to which it is being bound.  You will see in the above sample that I overwrote the GetCustomBindablePropertyDescriptors method and added the custom property as a ReflectionPropertyDescriptor there.  This ensures that the binding gets properly setup when binding.

Post #15886
Posted 04/25/2008 1:39:35 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 12/02/2008 4:27:11 PM
Posts: 28, Visits: 394
OK, Thanks very much for the sample. Still got a problem though.

This is what I allready had:


Dim _ZipCode As String = ""
'''
''' Zip Code
''' _ZipCode
'''
BusinessFieldDisplayInEditor(), _
Description("Zip Code"), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public Property [ZipCode_cust]() As String
Get
Return _ZipCode
End Get
Set(ByVal value As String)
_ZipCode = value
End Set
End Property



I allready had the call to validate:


Private Sub CCBO_CheckRulesOnCurrentRow(ByVal e As MicroFour.StrataFrame.Business.CheckRulesEventArgs)

'--Validate zip code
If Len(Me.ZipCode_cust.Trim) > 0 Then
If Me.ZipCodeCheck(Me.ZipCode_cust.Trim) = False Then
Me.AddBrokenRule("zipcode_cust", "The Zip Code format in invalid.")
End If
End If

End Sub



I added what you had in your business object:


Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()
Return New FieldPropertyDescriptor() {New ReflectionPropertyDescriptor("ZipCode_cust", GetType(AES_PPM_BOL.CCBO))}
End Function


The code for the field on the web page is as follows:





Finally in the application base page I also had the following:

Private Sub Page_PreRender1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Me.ErrorIcon = "images/brokenrule.gif"
End Sub



Eventhough the error line shows up, which it had from the beginning, the Brokenrule.gif doesn't show up at end of textbox when I do custom validation. It only shows up when the required field is empty (on same textbox). Am I missing something else?
Post #15898
Posted 04/25/2008 1:47:11 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 12/02/2008 4:27:11 PM
Posts: 28, Visits: 394
Sorry the line didn't show up on the web page. Apparently it's parsed out, so I'll add the important bits.

...BindingField="ZipCode_cust" BusinessObjectName="CCBO" IgnoreManageUIReadOnlyState="True" MaxLength="10">...(and ofcourse its as sfweb:textbox)


Post #15900
Posted 04/29/2008 12:16:14 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: StrataFrame Users
Last Login: 12/02/2008 4:27:11 PM
Posts: 28, Visits: 394
PPS: Good Grief!  Also the _ZipCode and _ZipCode_Cust field are really the same. Doesn't change the result though.
Post #15976
Posted 04/29/2008 11:07:05 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 7:08:30 PM
Posts: 4,811, Visits: 4,781
OK...I am not sure what you are doing wrong through the posts here, so I added a web application to the previous sample I supplied and it all works as it should.  So you might be able to determine where your issue is through this sample.

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

Post #15986
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 2:46am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.062. 10 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.