Package org.apache.ecs

Examples of org.apache.ecs.ElementContainer


    /**
    Get the content for this PortletController
    */
    public ConcreteElement getContent( RunData rundata ) {

        ElementContainer base = new ElementContainer();

        try
        {
        PortletSet portlets = getPortlets();
        PortletConfig pc = portlets.getPortletConfig();

        // first get the number of columns and rows to display
        Enumeration en = portlets.getPortlets();
     
        //see if any or the Portlets you want to add have a larger column or
        //row number than that defined in PSML
        while ( en.hasMoreElements() ) {

            Portlet portlet = (Portlet)en.nextElement();

            calculateControllerLayout( portlet );
           
        }

        setWidth( pc.getLayout( "width", getWidth() ) );

        int rows = getRow();
        int cols = getColumn();

        if (0 == rows || 0 == cols)
            return base; // empty container

        Table t = new Table()
                       .setWidth( this.getWidth() )
                       .setCellPadding( this.getPadding() )
                       .setAlign("center");

        base.addElement( t );

        ElementContainer[][] elements = new ElementContainer[rows][cols];

        for( int i = 0; i < rows; i++ )  {
            for ( int j = 0 ; j < cols; j++ ) {
                elements[i][j]=new ElementContainer();
            }
        }

        // populate the elements array
        en = portlets.getPortlets();
View Full Code Here


    @author <A HREF="mailto:burton@apache.org">Kevin A. Burton</A>
    @version $Id: PollPortlet.java,v 1.3 2001/03/07 07:12:35 taylor Exp $
    */
    private ConcreteElement getResults( RunData rundata ) {
       
        ElementContainer ec = new ElementContainer();

        AnswerGroup ag = this.getAnswerGroup();
       
        Answer[] answers = ag.getAnswers();
       
        int top = ag.getTopAnswer().getVoteCount();
       
        ConcreteElement nbsp = new ClearElement( "&nbsp;" );

        //make sure the user hasn't voted before.
        if ( this.hasVoted( rundata ) ) {
            ec.addElement( new I().addElement( "You have already voted!" ) );
            ec.addElement( new BR() );
        }
       
       
        //add the question to the Portlet so that he user knows what they just
        //voted on.
        ec.addElement( new B().addElement( this.getQuestion().getTitle() ) );       
       
        Table table = new Table();
       
        for( int i = 0; i < answers.length; ++i ) {
           
            Answer answer = answers[i];
           
            //compute the width of this vote item.

            int width = 0;
           
            TR row = new TR();

            row.addElement( getColumn( answer.getTitle() ) );
           
            if ( answer.getVoteCount() == 0 ) {
                width = 1;
            } else {
                width = ( DEFAULT_IMG_WIDTH / top ) * answer.getVoteCount();
            }
           

           
            TD result = getColumn( new IMG().setSrc( IMG_MAINBAR )
                                                .setWidth( width )
                                                .setHeight( DEFAULT_IMG_HEIGHT ) );

            //get the current vote count and percentage
            result.addElement( nbsp );
            result.addElement( Integer.toString( answer.getVoteCount() ) +
                               " / " +
                               Integer.toString( ag.getPercentage( answer ) ) +
                               "%" );
                                               
            row.addElement( result );
           
            row.addElement( new TD().setWidth( "100%" ) );
           
            table.addElement( row );
        }
       
        ec.addElement( table );
       
        //now add the total number of votes.
        ec.addElement( new BR() );
        ec.addElement( new B()
            .addElement( Integer.toString( this.getAnswerGroup().getTotal() ) +
                         " total vote(s)" ) );

        //add the warning
        ec.addElement( new BR() );
        ec.addElement( WARNING );
                        
        return ec;
    }
View Full Code Here

     * Method returning HTML markup for a date list box
     */
    public String getContent(RunData data, String name, String value, Map parms)
    {

        ElementContainer container = new ElementContainer();

        if ( value.equals("$today") )
        {
            Date dt = new Date(System.currentTimeMillis());
            value = new SimpleDateFormat("M/d/yyyy").format(dt);
        }

        container.addElement(new Script().setLanguage("JavaScript").setSrc("javascript/PopupCalendar.js"));

        container.addElement(new Input(Input.TEXT, name, value));

        IMG img = new IMG("images/cal.gif").setAlt("Click here for popup calendar").setBorder(0);
        A a = new A(this.getJavaScript(name), img);

        container.addElement(a);

        return container.toString();
    }
View Full Code Here

     *
     * @param rundata the RunData for the request
     */
    public ConcreteElement getContent(RunData rundata)
    {
        if (getPortlet()==null) return new ElementContainer();
        return getPortlet().getContent( rundata );
    }
View Full Code Here

    /**
    */
    protected ConcreteElement getContent( PortletSet set, RunData data )
    {
        return new ElementContainer();
    }
View Full Code Here

    /**
    */
    protected ConcreteElement getWMLContent( PortletSet set, RunData data )
    {
        return new ElementContainer();
    }
View Full Code Here

    /**
    */
    protected ConcreteElement getHTMLContent( PortletSet set, RunData data )
    {
        return new ElementContainer();
    }
View Full Code Here

    /**
    Get the content for this PortletController
    */
    public ConcreteElement getContent( RunData rundata ) {

        ElementContainer base = new ElementContainer();

        try
        {
        PortletSet portlets = getPortlets();
        PortletConfig pc = portlets.getPortletConfig();

        // first get the number of columns and rows to display
        Enumeration en = portlets.getPortlets();
     
        //see if any or the Portlets you want to add have a larger column or
        //row number than that defined in PSML
        while ( en.hasMoreElements() ) {

            Portlet portlet = (Portlet)en.nextElement();

            calculateControllerLayout( portlet );
           
        }

        setWidth( pc.getLayout( "width", getWidth() ) );

        int rows = getRow();
        int cols = getColumn();

        if (0 == rows || 0 == cols)
            return base; // empty container

        Table t = new Table()
                       .setWidth( this.getWidth() )
                       .setCellPadding( this.getPadding() )
                       .setAlign("center");

        base.addElement( t );

        ElementContainer[][] elements = new ElementContainer[rows][cols];

        for( int i = 0; i < rows; i++ )  {
            for ( int j = 0 ; j < cols; j++ ) {
                elements[i][j]=new ElementContainer();
            }
        }

        // populate the elements array
        en = portlets.getPortlets();
View Full Code Here

    }
   
    /**
    */
    public synchronized ConcreteElement postArticle( String provider, RunData rundata ) {
        ElementContainer ec = new ElementContainer();

        ParameterParser params = rundata.getParameters();       
       
        String topic = params.getString( "topic", "" );
        String title = params.getString( "title", "" );
        String link  = params.getString( "link", "" );
        String description  = params.getString( "description", "" );
       
        //create the JCM item
        Item item = new Item();
        item.setTopic( topic );
        item.setTitle( title );
        item.setLink( link );
        item.setDescription( description );
       

        Content content = null;
        try {
            content = this.getContentMarkup( this.getURL( provider ) ).getContent();


            //BEGIN reorg of the item list so that the new entry begins at the top
            Vector v = new Vector();
           
            Item[] items = content.getChannel().getItem();
           
            for ( int i = 0; i < items.length; ++i ) {
                v.addElement( items[i] );
            }

            v.insertElementAt( item, 0 );
           
            //now build this into a new array
           
            Item[] newItems = new Item[ v.size() ];
            v.copyInto( newItems );
           
            content.getChannel().removeAllItem();
           
            //now go through all the new items and add those
            for ( int i = 0; i < newItems.length; ++i ) {
                content.getChannel().addItem( newItems[i] );
            }

            //END reorg of the item list so that the new entry begins at the top           
           
            //save the portlet markup after you have made the changes.
            this.getContentMarkup( this.getURL( provider ) ).save();

        } catch ( Throwable t ) {
            logger.error("Throwable", t);
            return new StringElement( "Can't use this provider: " + t.getMessage() );
        }
       
        ec.addElement( "Your article '" + title + "' has been posted within '" + topic + "'" );
       
        return ec;
    }
View Full Code Here

    /**
    Get a list of providers an provide a form for them.
    */
    public ConcreteElement getProviders( RunData rundata ) {
       
        ElementContainer root = new ElementContainer();
       
        root.addElement( new P().addElement( "Select a content provider: " ) );

        Vector v = JetspeedResources.getVector( JetspeedResources.CONTENT_PROVIDER_LIST_KEY );
       
        for ( int i = 0; i < v.size(); ++i ) {
           
            String provider = (String)v.elementAt( i );
           
            String title = JetspeedResources.getString( "content.provider." + provider + ".title" );

            DynamicURI uri = new DynamicURI( rundata );
            uri.addQueryData( rundata.getParameters() );
            uri.addQueryData( PROVIDER_NAME_KEY, provider );

            P row = new P().addElementnew A( uri.toString() ).addElement( title ) )
                           .addElement( " ( " )
                           .addElement( new A( this.getBookmarklet( provider, rundata ) ).addElement( "Bookmarklet" ) )
                           .addElement( " ) " );
                          
            root.addElement( row );
           
           
        }
       
        return root;
View Full Code Here

TOP

Related Classes of org.apache.ecs.ElementContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.