Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    use setAttribute() causes Portlets to have different vertical position

    initially all of my three Portlet object is within the same vertical position (where all of them is visually under the same row), but after I have added the setAttribute() method, all three of my Portlet object is now at different vertical position, where it now looks like a stair.

    May I know how can I fix this? Below is my codes:


    Code:
    private Portlet populatePortlet(final int i, final VLayout layout)
    { final Portlet portlet = new Portlet();
    portlet.setHeight((countPortletHeight+20)+"px");
    portlet.setBodyColor("transparent");
    portlet.setBodyStyle("");
    portlet.setLayoutMargin(0);
    portlet.setShowHeader(false);
    portlet.setMinWidth(countPortletMinWidth);
    Element portletElement = portlet.getElement();
    if(UserDetailService.isDeviceModeHandsetOrTablet()){ dashletPortlet.setWidth100(); }
    if(i % 4 == 1)
    { portlet.setBackgroundColor("#EC5B42");
    portlet.setCanSelectText(true);
    portletElement.setAttribute("PortletId", String.valueOf(portletId));
    }else if(i % 4 == 2)
    { portlet.setBackgroundColor("#F2B134");
    portlet.setCanSelectText(true);
    portletElement.setAttribute("PortletId", String.valueOf(portletId));
    }else if(i % 4 == 3)
    { portlet.setBackgroundColor("#2EB997");
    portlet.setCanSelectText(true);
    portletElement.setAttribute("PortletId", String.valueOf(portletId)); } return portlet; }
    
    
    private Layout populatePortlet(Integer count, String headerContent, int i)
    { final VLayout vLayout = new VLayout();
    vLayout.setWidth100();
    vLayout.setHeight100();
    vLayout.setBackgroundColor("transparent");  
    final Label lbl1 = new Label();
    lbl1.setContents(Integer.toString(count));  
    lbl1.setValign(VerticalAlignment.BOTTOM);
    lbl1.setWidth100(); lbl1.setHeight("80%");
    final Label lbl2 = new Label();
    lbl2.setContents(headerContent);
    lbl2.setValign(VerticalAlignment.TOP);
    lbl2.setWidth100(); lbl2.setHeight("20%");
    vLayout.addMember(lbl1); vLayout.addMember(lbl2); return vLayout; }

    Last edited by Chua; 22 Mar 2023, 18:42.

    #2
    Your code has come through all as just two lines of code, so it's unreadable. But, just as a guess, your setAttribute() may be forcing your portlets to be created before you are finished configuring them. Try placing these and any other setAttribute() calls last instead.

    Comment


      #3
      Originally posted by Isomorphic View Post
      Your code has come through all as just two lines of code, so it's unreadable. But, just as a guess, your setAttribute() may be forcing your portlets to be created before you are finished configuring them. Try placing these and any other setAttribute() calls last instead.
      But as you can see from my code, I am trying to pass the Portlet id retrieved from the database to the PopulateDashlet method, and as I have a maximum of 4 dashletPortlet, I am using the "i" value to determine differentiate four portlet and used setAttribute() to set the Portlet id to each Portlet object, so I am not sure how I can call the setAttribute() before finished configuring them

      Comment


        #4
        Sorry, we're not able to understand your response.

        Again, the advice is to move the setAttribute() call after all other calls on the Portlets. You could also move it such that it's done after the Portlets have been added to the layout.

        Comment

        Working...
        X