Rendering rich text fields in wiki pages

Description
JoernTietjen
Posts: 36
Joined: Tue Jan 10, 2012 2:08 pm
Location: nr Hamburg, Germany

Rendering rich text fields in wiki pages

Postby JoernTietjen » Mon Dec 17, 2012 10:09 am

Hi,

I would like to render rich text fields of workitems in a wiki page.
My code looks like this:

Code: Select all

#set( $items = ["ABC-123","ABC-789"] )

<table cellpadding="5" border="1">
<tr>
  <th>Item ID</th>
  <th>Description</th>
h>
</tr>
#foreach($wiName in $items)
    #set( $wi = $trackerService.getWorkItem( $prjName, $wiName ) )
    <tr>
      <td>$wi.getId()</td>
      <td>$wi.getDescription()</td>
    </tr>
    <tr>
      <td>$wi.getId()</td>
      <td>{workitem: $wi.getId() | fields=description}</td>
    </tr>
#end


When I use the getDescription() method of the IWorkItem class the following occurs:
- the literal text string "text/html:" is prepended to the output
- included images are suppressed

When I use the {workitem:} macro all configured information is rendered but I cannot control the layout of the element being rendered (solid line around bounding box, display of expand/collapse button, display of ID and title, color and font size of text).

I need to show all rich text field information in a wiki page table where formatting is controlled by HTML tags but not the additional items being rendered when the {workitem:} macro is used.

Any idea how I can render comprehensive rich text fields including images in wiki pages without using the {workitem:} macro?

TIA and regards
Joern

martins
Posts: 181
Joined: Thu Nov 05, 2009 3:24 pm

Re: Rendering rich text fields in wiki pages

Postby martins » Mon Dec 17, 2012 10:15 am

Hello Joern,

I use following code:

Code: Select all

#if($wi.getDescription())
{pre}$wi.renderDescription($wi.getDescription(),null).getContent(){/pre}
#end


For custom fields I use:

Code: Select all

#if($wi.getCustomField("Test"))
{pre}$wi.renderDescription($wi.getCustomField("Test"),null).getContent(){/pre}
#end

Kind regards

Martin

JoernTietjen
Posts: 36
Joined: Tue Jan 10, 2012 2:08 pm
Location: nr Hamburg, Germany

Re: Rendering rich text fields in wiki pages

Postby JoernTietjen » Mon Dec 17, 2012 10:38 am

Hi Martin,

excellent!
Your code works right out of the box!

Thanks a lot and have a nice day.

Regards
Joern

langerma
Posts: 1
Joined: Thu Jan 31, 2013 7:58 am

Re: Rendering rich text fields in wiki pages

Postby langerma » Thu Jan 31, 2013 8:55 am

Hello Martin,

is there anything else for the new type test steps.

Until now i can only read out the content by following method:

Code: Select all

 #set($teststeps=$testManagementService.getTestSteps($wi).getSteps())


and you get access to the $testManagementService object by following code:

Code: Select all

#set( $dataService = $trackerService.getDataService() )
#set( $protoTestRun = $dataService.getPrototype("TestRun") )
#set( $aTestRun = $dataService.searchInstances( $protoTestRun, "", "id", 1) )
#set( $aTestRun = $aTestRun.get(0) )
#set( $testManagementService = $aTestRun.getTestManagementService())


But this is really pedestrian.

Is there an easier way to get the content of of test steps?

I got the CustomField by following code:

Code: Select all

$wi.getCustomField("testcaseDescription")


But i do not know what to do then afterwards.

Have you an idea?

Kind regards

Matthias

martins
Posts: 181
Joined: Thu Nov 05, 2009 3:24 pm

Re: Rendering rich text fields in wiki pages

Postby martins » Wed Feb 06, 2013 9:14 am

Sorry, I don't know. We don't use Polarions "test steps" approach at all.

Martin

Stepan Roh
Posts: 34
Joined: Tue Apr 04, 2006 8:46 am

Re: Rendering rich text fields in wiki pages

Postby Stepan Roh » Wed Feb 06, 2013 2:50 pm

Hello.

ITestManagementService is not contributed to HiveMind, but this will work:

Code: Select all

<service-point id="myTestManagementService"
interface="com.polarion.alm.tracker.ITestManagementService">
<invoke-factory>
<construct class="com.polarion.alm.tracker.internal.TestManagementService">
</construct>
</invoke-factory>
</service-point>

<contribution configuration-id="com.polarion.alm.wiki.renderingContext">
<item key="trackerService"
value="service:com.polarion.platform.alm.tracker.trackerService"/>
<item key="transactionService"
value="service:com.polarion.platform.transaction.transactionService"/>
<item key="projectService"
value="service:com.polarion.platform.alm.project.projectService"/>
<item key="wikiService" value="service:com.polarion.alm.wiki.wikiService"/>
<item key="securityService"
value="service:com.polarion.platform.security.securityService"/>
<item key="calendarTool"
value="instance:com.polarion.wiki.util.CalendarTool"/>
<item key="platformService"
value="service:com.polarion.platform.platformService"/>
<item key="testManagementService" value="service:myTestManagementService"/>
</contribution>


It should be put into C:\Polarion\polarion\plugins\com.polarion.alm.wiki_3.6.1\sidecar.jar\META-INF\hivemodule.xml (version and location depends on the Polarion version). Please note that it is packed into the .jar file and that it will be overwritten during update to newer version.

This will make testManagementService accessible from Wiki.
Stepan Roh
Polarion Software

rvz2bda
Posts: 4
Joined: Thu Dec 20, 2012 9:24 am

Re: Rendering rich text fields in wiki pages

Postby rvz2bda » Tue Feb 11, 2014 4:19 pm

Great solution provided by martins!

Thx


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 9 guests