incubator-jspwiki-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Louis.Mast...@log-net.com
Subject Re: Dynamically inserting forms
Date Fri, 19 Sep 2008 11:20:04 GMT
Benedikt:

I have a plugin that creates a sortable table - the XHTML, not the wiki 
markup.  Here is a snippet of what the plugin does:

                out.append( "<div class=\"sortable\">\n" );
                out.append( "<div class=\"table-filter\">\n" );
                out.append( "<div class=\"zebra-table\">\n" );
                out.append( "<table class=\"wikitable\" border=\"1\">\n" 
);

                out.append( "<tr class=\"odd\">\n" );


                for (Iterator iter = headers.iterator(); iter.hasNext(); ) 
{
                        out.append( "<th>");
                        out.append((String)iter.next());
                        out.append( "</th>");
                }

                out.append( "</tr>\n" );

                //snipped DB stuff
                while (rs.next()) {
                        //snipped business logic here
                        createRow(cells, isOdd);
                        isOdd=!isOdd;
                }


                out.append( "</table>\n" );
                out.append( "</div></div></div>\n" );



The createRow method called from the loop:
        protected void createRow(ArrayList cells, boolean isOdd)
        {
                if(isOdd)
                {
                        out.append( "<tr class=\"odd\">\n" );
                }
                else
                {
                        out.append( "<tr class=\"even\">\n" );
                } 



                for (Iterator iter = cells.iterator(); iter.hasNext(); ) {
                        out.append( "<td>");
                        out.append((String)iter.next());
                        out.append( "</td>");
                }

                out.append( "</tr>\n" );
        }


It's nothing fancy, but it looks great and gets the job done.  Hope it 
helps.

-Lou







Benedikt Mohrmann <mohrmann@mail.upb.de> 
09/19/2008 03:34 AM
Please respond to
jspwiki-user@incubator.apache.org


To
jspwiki-user@incubator.apache.org
cc

Subject
Re: Dynamically inserting forms






Hi,

I didn't get it unitl now.
My goal is to dynamically add wikimarkup into the page.
To be more precise, I am trying to add a sortable table (via the 
%%sortable Tag) into my document, which contains the content that my 
Plugin returned.

Thus I tried things (in my plugin) like:
return "%%sortable myContent  /%"
and
return "%%sortable \n myContent \n  /%"
and
return "%%sortable <br> myContent <br> /%"

but none of this alternatives solved my problem, because there is never 
a table inserted into the document, but only the String!


Regards
Benedikt


Janne Jalkanen schrieb:
>>
>> My Plugin returns a String, which contains e.g. "[{FormTextarea 
>> name='output' rows=10 cols=80}]".
>> But it does not create a TextArea, but instead just prints the String 
>> on the Main Page!
>
> Hi!
>
> Plugins should always insert XHTML.  If you want to return wikimarkup, 
> you'll have to first run it through RenderingManager.
>
> /Janne



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message