Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    6
    Vote Rating
    0
    regular is on a distinguished road

      0  

    Question Programmatically adding portlet into Portal caused auto-size failed

    Programmatically adding portlet into Portal caused auto-size failed


    Hi all,

    I'm using com.extjs.gxt.ui.client.widget.custom.Portal as a desktop page
    I need to programmatically add some pages into desktop page.
    I noticed that the sample portal just add portlet in onRending method.
    And the portlet can autosize to the suitable size, see attachment pictures.
    This is the default desktop, with portlets created onRender.
    Code:
        private PortalLayout container = new PortalLayout(.33, .34, .33) {
            @Override
            protected void onRender(Element parent, int index)
            {
                super.onRender(parent, index);
    
                ExplorerModel model = Registry.get(Explorer.MODEL);
                model.setDesktop(Desktop.this);
    
                addPortlet(Entry.findEntry(CustomerService.CUSTOMER_STOCK), 0);
                addPortlet(Entry.findEntry(CustomerService.CUSTOMER_WEATHER), 1);
                addPortlet(new Entry(new BogusPort()), 2);
            }
        // ...
    portlet1.png
    And another portal page with portlets created onRender.
    Code:
            return new PortalLayout(.5, .5) {
                @Override
                protected void onRender(Element parent, int index)
                {
                    super.onRender(parent, index);
    
                    addPortlet(Entry.findEntry(CUSTOMER_STOCK), 0);
                    addPortlet(Entry.findEntry(CUSTOMER_WEATHER), 1);
                    addPortlet(Entry.findEntry(CUSTOMER_DASHBOARD), 0);
                }
            };
    portlet2.png
    The PortalLayout class added a Portal as the center widget:
    Code:
    public abstract class PortalLayout extends LayoutContainer
    {
        private double[] colWidths;
        protected Portal portal;
    
        public PortalLayout(double... colWidths)
        {
            this.colWidths = Arrays.clone(colWidths);
        }
    
        @Override
        protected void onRender(Element parent, int index)
        {
            super.onRender(parent, index);
            setLayout(new BorderLayout());
    
            portal = new Portal(colWidths.length);
            portal.setBorders(true);
            portal.setStyleAttribute("backgroundColor", "white");
            for (int i = 0; i < colWidths.length; i++) {
                portal.setColumnWidth(i, colWidths[i]);
            }
    
            BorderLayoutData centerData = new BorderLayoutData(LayoutRegion.CENTER);
            centerData.setMargins(new Margins(5));
    
            add(portal, centerData);
        }
        // ...
    When click "save" button, it will add this entry into the desktop page.
    Code:
        protected void addExtraToolIcon(final ContentPanel panel, final Entry entry)
        {
            panel.getHeader().addTool(new ToolButton("x-tool-save", new SelectionListener<IconButtonEvent>() {
                @Override
                public void componentSelected(IconButtonEvent ce)
                {
                    ExplorerModel model = Registry.get(Explorer.MODEL);
                    model.addPortlet(entry, -1);
                    MessageBox.info("Information", "&lt;" + entry.getName() + "&gt; has been added into Desktop.", null);
                }
            }));
        }
    Please ignore the ExplorerModel, just think it as the Desktop instance is adding a new portlet, as below:
    Code:
        public void addPortlet(Entry entry, int col)
        {
            ViewPort view = entry.getViewPort();
            final Portlet portlet = new Portlet(new FitLayout());
            portlet.setData("entry", entry);
            portlet.setIcon(view.getIcon());
            portlet.setHeading(entry.getName());
            addMaximizedIcon(portlet, entry);
            addExtraToolIcon(portlet, entry);
            portlet.add(view.getPortlet());
            if (col >= 0) {
                portal.add(portlet, col);
            } else {
                portal.add(portlet, 2);
            }
        }
    When finished, I got this:
    portlet3.png
    And ...
    portlet4.png
    I got this:
    portlet5.png

    Seems that I didn't do some kind of refresh, or resize, or layout.
    Please, anyone knows how to fix this problem?

  2. #2
    Sencha User
    Join Date
    Apr 2011
    Posts
    6
    Vote Rating
    0
    regular is on a distinguished road

      0  

    Talking Answer & Solution

    Answer & Solution


    OK, after several * n times testing, the result is as follows:

    Try to add a portlet then delay for a while and then move it to a different width column to auto-size it leads to several success and only one fault, when I resist to see the desktop page.

    So, it means it's not the reason for not layout it or not repaint it, it's the reason that, the desktop page is hidden.

    For proving this assumption, I just delay 5 seconds before add the portlet, and turn to the desktop page, to see it be created. And I found that the portlet is well-formed.

    Now, the solution is out. When you want to add a portlet into a "hidden" portal, just like me. U can just queue an operation in list, and when the portal is showing, trigger these operations into handler, and the auto-size layout will work.

Similar Threads

  1. Dynamically adding "portlet" items to an EXT portal component
    By BulletzBill in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 29 Jan 2012, 2:06 PM
  2. Portal - add Portlets without column and auto size columns
    By f.sauter in forum Ext GWT: User Extensions and Plugins
    Replies: 0
    Last Post: 3 Sep 2010, 12:30 AM
  3. Disable Field Auto Validation failed
    By kevinwu8 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 1 Dec 2008, 1:05 AM

Tags for this Thread