Menu

Not update association link key

2005-06-23
2013-03-07
  • Nobody/Anonymous

    I am trying to do a simple onetomany association  between a header menu and a sub menu.

    Its saves all of the sub items but does not link the items and does not retrieve them onload. 

    Can anybody see where I am going wrong.

    _mastermenu = Nothing
            _mastermenu = New watchfinder.site.info.admin.sys_menu
            _mastermenu.OidValue = "000000350002"

            If _mastermenu.Find() Then
                Dim _submenuitem As watchfinder.site.info.admin.sys_menu_sub

                _submenuitem = Nothing
                _submenuitem = New watchfinder.site.info.admin.sys_menu_sub
                _submenuitem.Name = "Products"
                _submenuitem.LinkRef = "~/shopmanger/product/product_list.aspx"
                _mastermenu.SubMenus.Add(_submenuitem)

                _submenuitem = Nothing
                _submenuitem = New watchfinder.site.info.admin.sys_menu_sub
                _submenuitem.Name = "Campains"
                _submenuitem.ParentOID = _mastermenu.OidValue
                _submenuitem.LinkRef = "~/shopmanger/Campains/campain_list.aspx"
                _mastermenu.SubMenus.Add(_submenuitem)

                _submenuitem = Nothing
                _submenuitem = New watchfinder.site.info.admin.sys_menu_sub
                _submenuitem.Name = "Manufacturers"
                _submenuitem.ParentOID = _mastermenu.OidValue
                _submenuitem.LinkRef = "~/shopmanger/Manufacturer/manufactur_list.aspx"
                _mastermenu.SubMenus.Add(_submenuitem)

                _submenuitem = Nothing
                _submenuitem = New watchfinder.site.info.admin.sys_menu_sub
                _submenuitem.Name = "Categories"
                _submenuitem.ParentOID = _mastermenu.OidValue
                _submenuitem.LinkRef = "~/shopmanger/category/category_list.aspx"
                _mastermenu.SubMenus.Add(_submenuitem)

                _submenuitem = Nothing
                _submenuitem = New watchfinder.site.info.admin.sys_menu_sub
                _submenuitem.Name = "Shops"
                _submenuitem.ParentOID = _mastermenu.OidValue
                _submenuitem.LinkRef = "~/shopmanger/shops/shop_list.aspx"
                _mastermenu.SubMenus.Add(_submenuitem)

                _submenuitem = Nothing
                _submenuitem = New watchfinder.site.info.admin.sys_menu_sub
                _submenuitem.Name = "Sites"
                _submenuitem.ParentOID = _mastermenu.OidValue
                _submenuitem.LinkRef = "~/shopmanger/Sites/site_list.aspx"
                _mastermenu.SubMenus.Add(_submenuitem)

                _mastermenu.SetDirtyFlag()
                _mastermenu.Save()

            End If

     
    • Nobody/Anonymous

      Sorry here is the Xml

      <class name="sys_menu" table="sys_menu" database="AFWatchinder">
              <attribute name="OIDValue" column="oid" key="primary" />
              <attribute name="CreatedDate" column="CreatedDate" timestamp="true" />
              <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true" />
              <attribute name="Name" column="name" />
              <attribute name="LinkRef" column="linkref" />
              <attribute name="HelpText" column="helptext" />
              <attribute name="ItemCode" column="itemcode" />
              <attribute name="SubMenus" />
      </class>
         
      <class name="sys_menu_sub" table="sys_menu_sub" database="AFWatchinder">
              <attribute name="OIDValue" column="oid" key="primary" />
              <attribute name="CreatedDate" column="CreatedDate" timestamp="true" />
              <attribute name="ModifiedDate" column="ModifiedDate" timestamp="true" />
              <attribute name="Name" column="name" />
              <attribute name="LinkRef" column="linkref" />
              <attribute name="HelpText" column="helptext" />
              <attribute name="ParentOID" column="parentoid" />
      </class>

      <association fromClass="sys_menu"
              toClass="sys_menu_sub"
              cardinality="oneToMany"
              target="SubMenus"
              retrieveAutomatic="true"
              deleteAutomatic="true"
              saveAutomatic="true"
              inverse="false">
              <entry fromAttribute="OIDValue" toAttribute="ParentOID"/>
      </association>

       
    • Richard Banks

      Richard Banks - 2005-06-23

      At first glance everything looks OK.

      Can you run the program in debug and post the generated SQL for the retrieval of the sys_menu object?

      You should see SQL generated that includes a join between the sys_menu and sys_menu_sub tables.  You can check that the join is selecting the expected data.

      Also (and feel free to ignore this bit since it could just be a style thing), I noticed that you always set an object to nothing before re-initializing it.  For example
      _submenuitem = Nothing
      _submenuitem = New watchfinder.site.info.admin.sys_menu_sub

      You don't need to set the object to Nothing if you are reinitialising.

       
    • Nobody/Anonymous

      Hi

      the sql is

      SELECT sys_menu.oid, sys_menu.CreatedDate, sys_menu.ModifiedDate, sys_menu.name, sys_menu.linkref, sys_menu.helptext, sys_menu.itemcode FROM sys_menu

      this was taken from the project output window when running in debug mode. 

      I must have something wrong somewhere... and I know it s going to be something silly too :)

      Thanks for your comment about setting the object to nothing before reinitialising.  I know there is no need if I reinitialising the object.   All i can say is old vb 6 habbits die hard :D

      Thanks for responding.

       
    • Nobody/Anonymous

      Ahhhhhhh

      I have sorted it.    Somebody slap me on the head for being stupid.

      Must not have had enough coffee yesterday .   Needed to tell the getall function to load all associations.

      I will get my coat ........

      Thanks for the help once again

       
      • Richard Banks

        Richard Banks - 2005-06-24

        That happens - lack of coffee could also explain why you forgot to mention you were using GetAll() instead of Retrieve() or Find() :-)

        Glad it's sorted now.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.