Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 20 total
Thread HashHandler Component
Thu, Aug 27 2015 11:06 AMPermanent Link

Mark Brooks

Slikware

Avatar

Not too sure if this is the right forum for code snippet uploads. Apologies if not.

Today I knocked up a first draft for a HashHandler component. It's a non-visual component that you can drop on a form in order to encapsulate some of the browser hash functionality. It has two main functions:

- It will fire an event when the browser hash changes
- It can be used to update the browser hash

It uses an internal name:value list to represent what's happening with the browser hash and assumes that your chosen format will be of this form:

<Application URL>#<name=value>&<name=value>&<name=value>

Events:

- OnChange (fired when the hash changes)

Properties:

- NumPairs (readonly, used to get the number of pairs in the internal name:value list, typically in the OnChange event)
- Names (readonly, used to get the Name element of a specific pair in the internal name:value list, typically in the OnChange event)
- Values (readonly, used to get the Value element of a specific pair in the internal name:value list, typically in the OnChange event)

Methods

- Clear (empties the internal name:value list in preparation for adding)
- Add  (adds a new name:value pair to the internal name:value list)
- Update (updates the browser hash with the contents of the internal name:value list)

Source is attached - hopefully of some use to those of you who I've been discussing browser hash framework mechanisms with.

Mark

PS. Any bugs found are clearly intentional and put there only to see if you can spot them ..............



Attachments: MCBHashHandler.wbs
Thu, Aug 27 2015 11:12 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mark,

<< Not too sure if this is the right forum for code snippet uploads. Apologies if not. >>

Works for me. Smile

<< Today I knocked up a first draft for a HashHandler component. It's a non-visual component that you can drop on a form in order to encapsulate some of the browser hash functionality. It has two main functions: >>

Thanks, I'll check it out.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Aug 28 2015 8:46 AMPermanent Link

Uli Becker

Hi Mark,

thanks a lot for sharing your code.  I'll try it after my vacation.
Much appreciated.

Uli
Sat, Aug 29 2015 1:56 AMPermanent Link

StewCam

>>Mark Brooks wrote:

>>Not too sure if this is the right forum for code snippet uploads. Apologies if not.

>>Today I knocked up a first draft for a HashHandler component [...]

Thanks, Mark, this works well. The only problem I have encountered is that if the browser back button is used to go back to the start page then it generates an error:

"Error: List index 0 out of bounds
Line: 3070"

I haven't worked out how to eliminate this error.
Sat, Aug 29 2015 8:41 AMPermanent Link

StewCam

StewCam wrote:

>>Thanks, Mark, this works well. The only problem I have encountered is that if the browser back button is used to go back to the start page then it generates an error:

>>"Error: List index 0 out of bounds
>>Line: 3070"

>>I haven't worked out how to eliminate this error.

Answer to own question involved adding the following at the beginning of the OnChange handler for MCBHashHandler:
var
 s: String;
begin
 s := Window.Location.Hash; {Reguires WebDOM}
 if s[1] <> '#' then
   exit;
Sat, Aug 29 2015 9:46 AMPermanent Link

Mark Brooks

Slikware

Avatar

>>StewCam wrote:

>>Answer to own question involved adding the following at the beginning of the OnChange handler for >>MCBHashHandler:
>>var
>> s: String;
>>begin
>>  s := Window.Location.Hash; {Reguires WebDOM}
>>  if s[1] <> '#' then
>>    exit;

Hi Stew

Not sure you should ever get that event with no hash? Will have a look anyway. Thanks

I've attached a sample project that may help

Mark



Attachments: HashTest.zip
Sat, Aug 29 2015 8:08 PMPermanent Link

StewCam

Mark Brooks wrote:

>>Not sure you should ever get that event with no hash? Will have a look anyway. Thanks

>>I've attached a sample project that may help

Thanks, Mark, your project is very helpful.
Sun, Aug 30 2015 3:45 AMPermanent Link

Uli Becker

Mark,

I used your component for the first time now and it really works great. Thanks again.

Uli
Sun, Aug 30 2015 5:57 AMPermanent Link

Uli Becker

Mark,

I can confirm what Stew described. Got the same error. The hash is just
empty:

>#View=home<
>#View=edit<
>#View=home<
><

Uli
Sun, Aug 30 2015 11:17 AMPermanent Link

Mark Brooks

Slikware

Avatar

Uli / Stew

I really canot repeat that here. Very strange. Now I know what Tim feels like!

Of course feel free to modify the code as you wish if it fixes your problem, however it would also be great if you could show me some actual code and a series of actions that repeat the issue.

Also, what browser(s) and OS(s) are we talking about here?

Cheers

Mark
Page 1 of 2Next Page
Jump to Page:  1 2
Image