Hi all, just checking it’s not me doing something silly.
I create a simple webpage for user management. Web app using DBKit, and the tableConnection is subclassed - no issues anywhere else in the app.
The simple elements are shown in the picture below. All controls are dbkit subclasses except label1. None of the controls have any code except the popup (which has 3 me.addrows)
ManageUsers.Name Type mismatch error. Expected class DBKit.TextField, but got TextLiteral ManageUsers
and
ManageUsers.title.Name Layout (property name) This property shadows a property of a different type Name
As you can see in the screen shot, there is no dbkit.textfield called ‘ManageUsers’. If I change the web page’s name to ‘xyz’ and it’s title to ‘zyx’ I still get the same errors…
Whenever you get an error against <webpage>.Name, the error comes from the internal rendering code of the IDE. You see, there’s all this prep code that makes default values work.
go through the default values you have set for every item on that page and look for places where the value is incorrect. Things like places where you included quotes around a string, or used an object where a string is expected.
Otherwise you’ll need Xojo or some other knowledgeable person to help you figure it out.
Before I saw your reply I added in each dbkit.textfield individually. Got an error on the field called ‘title’ - named as such to pick up the database column automatically but have changed the dbkit settings of the field instead and renamed the field to ‘usertitle’ - that resolved the issue.
Even adding a WebTextField with the name ‘Title’ reproduces this error
Seems pretty weak that XOJO would stumble on something like this… do you think this is worth a ticket?
Edit: Adding any web control and naming it “title” reproduces the same error…
But what do you expect here?
Title is a String property of a WebPage. When you add a control of the same name, how should the IDE or compiler distinguish between them?
The IDE should prevent this renaming from taking place - it already does it for many other situations - for example if you try to name a DesktopButton instance as “Window” you get a beep and the name changes back to Button1.
The same behavior as Desktop.
Title (for Desktop) is also a String property of a Window.
You can name the DesktopTextField = Title and the app runs without errors.
Web is not working like this.
I’m a bit disconcerted that a property (such as webpage.title = “page_name”) can be confused with the value of another property (eg WebButton.name = “title”).
Is this is normal? I’ve never encountered this before in other environments.
Now I’m aware of it I’ll try to avoid, but how many properties IDE should I have to keep track of to avoid tripping on this annoying issue?
Wouldn’t it be better if XOJO used some form of introspection to avoid this confusion?
And if it cannot be rectified, it should be prevented by the IDE as a reserved word. The error messages raised were stunningly unhelpful, mainly because it never crossed my mind that webpage.title would be confused with control.name=“title”.
As I explained in my bug report, the naming is actually recommended by XOJO’s own DBKit (naming controls the same as the database column).
I am lazy and I have no free time, which is why I like XOJO+DBKit, and it’s not an exaggeration to say that is a major factor in me re-subbing after a number of years: it saves me a ton of time. Except for when it doesn’t I suppose
Following your advice of prefixes/suffixes would invalidate all the immediacy of DBKit, although it is possible to set the referenced column name in a different DBKit property, so I was not limited by this.
I only had to understand the issue but it still seems bizarre to me that the value of a control property can be mistaken for the name of a parent property.
No one I know with a professional grade understanding of Xojo thinks that DBKit is usable. I have to be very careful about how frequently I mention this, but you should not use it.
You need a prefix or suffix naming scheme. Neglecting this will only cause headaches, and not just now with this issue, but down the road.
Controls are like properties in a window or webpage. For you to write something like control.value=”val” the compiler has to make some asumptions, mostly, that you are refering to webpage.control.value
So you cant have a webpage.title string property and add another of different type like a control
I ask because XOJO is not my strong point - I only use it because with DBKit I was able to create a full web app in 3 days on a MySQL backend and it works well.
Is there something I should know about/be concerned about?
I mean I know this isn’t the very best approach and it is quick and dirty - but that’s what I use it.
using reserved words or existing property names for a control should not be allowed - the IDE should prevent you from doing this by the beep/undo
however, since it’s possible to edit source code outside the IDE… if you manage to do something illegal, the compile error message should be much more clear: The name of Window1.DesktopButton (‘Title’ ) conflicts with an existing property or method name of the DesktopWindow class of the same name.
In this case with a reference, it behaves like an overload. But write the code as it is normally used, without the parent refference and the compiler cant guess.