Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Dec 12, 2017 1:19 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: WebToolbar dynamic caption issue
PostPosted: Thu May 02, 2013 5:16 pm 
Offline

Joined: Fri Jul 27, 2012 9:52 am
Posts: 8
Hello all;

I am writing a web app that needs to be multi-lingual. TYhe strings are in a database, and upon loginm, I load the language-specific strings in an array setup as a session property. Then, each page gets assigned the appropriate strings in the Open event.

I am experiencing a problem with the WebToolbar. It resists my best efforts to set the menu item captions at runtime. My code is like this, in the M.Open event section:

(The page is called Mainmenu and the toolbar is currently called M, and each item is called M01, M02 etc.)

Dim item1 As WebToolbarContainer
item1 = WebToolbarContainer(Me.ItemWithName("M01"))
If item1 <> Nil Then
item1.Caption = session.apptext(3) 'Application menu
End If


This code compiles OK, but I always get an Unhandled IllegalCastException error. If I use for example "M00", which is not already set at design time, then the code runs just fine.

Can someone please point me in the direction of a solution? (or at least shed some light on my error)

Thanks in advance.

LD


Top
 Profile  
Reply with quote  
 Post subject: Re: WebToolbar dynamic caption issue
PostPosted: Thu May 02, 2013 6:07 pm 
Offline

Joined: Wed Mar 22, 2006 11:15 am
Posts: 712
Location: Southern California
Stab in the dark: does the code work in the Shown event? In WE the page and controls are not fully setup in Open.

_________________
Daniel L. Taylor
Custom Controls for Real Studio WE!
Visit: http://www.webcustomcontrols.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: WebToolbar dynamic caption issue
PostPosted: Thu May 02, 2013 7:05 pm 
Offline

Joined: Fri Jul 27, 2012 9:52 am
Posts: 8
I also tried in the shown event. Same issue.

I should also perhaps have indicated that I am using 2012 R2.

thanks.

LD


Top
 Profile  
Reply with quote  
 Post subject: Re: WebToolbar dynamic caption issue
PostPosted: Thu May 02, 2013 7:58 pm 
Offline

Joined: Wed Mar 22, 2006 11:15 am
Posts: 712
Location: Southern California
Looking over the code...is M01 actually a WebToolbarContainer? The code works for me. But if I remove the container and add a button with the name M01, then it fails with an IllegalCastException.

If you have different types in your toolbar you will need to use IsA to check type and correctly cast each item. Example:

Dim item1 As WebToolbarItem
item1 = Me.ItemWithName("M01")

If item1 IsA WebToolbarContainer Then
WebToolbarContainer(item1).Caption = "Test"
ElseIf item1 Isa WebToolbarButton Then
WebToolbarButton(item1).Caption = "Test"
End If

_________________
Daniel L. Taylor
Custom Controls for Real Studio WE!
Visit: http://www.webcustomcontrols.com/


Top
 Profile  
Reply with quote  
 Post subject: Re: WebToolbar dynamic caption issue
PostPosted: Thu May 02, 2013 8:09 pm 
Offline

Joined: Fri Jul 27, 2012 9:52 am
Posts: 8
Doh!

I guess I overlooked the obvious. Thank you so much for your help!

LD


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group