How to make NewsList from News package show news as list - c1-cms

I'am calling the NewsList (from the standard Composite.News package) from a template like this:
<f:function name="Composite.News.NewsList" xmlns:f="http://www.composite.net/ns/function/1.0">
<f:param name="ListOptions" value="Show date,Show teaser" />
<f:param name="PageSize" value="10" />
<f:param name="DateFormat" value="dddd, MMMM dd, yyyy" />
</f:function>
I can't make it to show the news as a list. It only shows the first newsitem in the detailsmode.
What does the below line in the NewsList function do?
How can I make the control show my news in a list and not the first (most recent) item?
I have talked to a more experienced Composite Developer and he couldn't either make the Composite.News.Newslist show news in a list.
UPDATE:
I can se that the OMNICORP site doesn't use the standard News package. What is the reason for that?

Omnicorp Demo Site has its own News module based on global data type "Omnicorp.Content.News" and XSLT function "Omnicorp.Content.News"
Composite.News package is different and based on page data folder named "Composite.News.NewsItem" and two XSLT functions: "Composite.News.NewsList" and "Composite.News.NewsTeasers". So to use this package you should follow the steps described here - http://docs.composite.net/Packages/CompositeNews: create a page with page type = "News page". Add news item to the News page data folder (under the page). On the Content tab, have the Composite.News.NewsList function, which will render News List with links to the details.

But can I make the NewsTeasers list all the news and set up paging as well?
Yes you can. You can modify the existent NewsTeaser function or create the new function. On the Function Call tab modify the "Composite.News.NewsItem.GetNewsItemXml" function call and specify next parameters "PageNumber" and "IncludePagingInfo" with next values:
<f:param name="PageNumber">
<f:function name="Composite.Web.Request.QueryStringIntegerValue">
<f:param name="ParameterName" value="Page" />
<f:param name="FallbackValue" value="1" />
</f:function>
</f:param>
<f:param name="IncludePagingInfo" value="True" />
On the function Template tab add template to display PagingInfo:
<xsl:param name="pagingInfo" select="/in:inputs/in:result[#name='GetNewsItemXml']/PagingInfo" />
...
<xsl:if test="$pagingInfo/#TotalPageCount > 1">
<div class="Paging">
<xsl:apply-templates select="$pagingInfo" />
</div>
</xsl:if>
...
<xsl:template match="PagingInfo">
<xsl:param name="page" select="1" />
<xsl:if test="$page < #TotalPageCount + 1">
<xsl:if test="$page = #CurrentPageNumber">
<span><xsl:value-of select="$page" /></span>
</xsl:if>
<xsl:if test="not($page = #CurrentPageNumber)">
<xsl:value-of select="$page" />
</xsl:if>
<xsl:apply-templates select=".">
<xsl:with-param name="page" select="$page+1" />
</xsl:apply-templates>
</xsl:if>
</xsl:template>
For more information how to add Paging to the XSLT read this article- http://docs.composite.net/XSLT/SortingAndPaging

Related

anychart column-3d doesn't correctly display x-axis labels with categorized_by_series=true

I am wondering is anychart column-3d has a way to fix displaying correct x-axis named while categorizing the series.
I have the following xml:
<anychart xmlns="http://anychart.com/schemas/8.0.0/xml-schema.xsd">
<chart type="column-3d" default_series_type="column" y_scale="0" z_angle="30" z_aspect="20" categorized_by_series="true">
<margin top="40">
</margin>
<chart_labels>
<label text="Bericht Gesamt||export.aspx?questionGroupId=38&version=2" anchor="top" position="left" enabled="true">
</label>
<label text="../anychart.aspx?qg=38&version=2" anchor="top" position="left" enabled="true">
</label>
</chart_labels>
<title enabled="true" use_html="true">
<text><![CDATA[Report für ELBI International S.p.A., GT Gerätefertigung (DE), 20200101 - 20210114, Lieferantenqualifizierung<br><div style="color:#0000FF; font-size: 10px;border: solid 1px #000;">Lieferantenqualifizierung, Erfüllung in % : 86,19 (AB)</span>]]></text>
</title>
<y_grids>
<grid>
<palette>
<items>
<item color="#CCC" opacity="0.25"/>
<item color="#FFF"/>
</items>
</palette>
</grid>
</y_grids>
<y_axes>
<axis>
<title use_html="true">
<text><![CDATA[<b>Set axis name here</b>]]></text>
</title>
<minor_ticks enabled="true"/>
</axis>
</y_axes>
<scales>
<scale type="linear" minimum="0" maximum="100">
<ticks interval="10" />
<minor_ticks interval="2" />
</scale>
</scales>
<series_list>
<series name="Qualität">
<tooltip enabled="true">
<format><![CDATA[Erfüllung in %: {%percentReached} ({%rating}) \nPunkte: {%score}]]></format>
<title>Qualität</title>
</tooltip>
<data>
<point value="81.9" percentReached="81,90" actionType="updateChart" sourceMode="externalData" rating="AB" score="40,95" x="1" source="../anychart.aspx?qg=39&version=2">
</point>
</data>
</series>
<series name="Lieferung">
<tooltip enabled="true">
<format><![CDATA[Erfüllung in %: {%percentReached} ({%rating}) \nPunkte: {%score}]]></format>
<title>Lieferung</title>
</tooltip>
<data>
<point value="90.48" percentReached="90,48" actionType="updateChart" sourceMode="externalData" rating="A " score="45,24" x="1" source="../anychart.aspx?qg=41&version=2">
</point>
</data>
</series>
</series_list>
</chart>
In 3d mode it shows x-labels from point's x value directly and looks like this:
But switching back to simple column type fix the issues:
Maybe someone knows a way around to overcome this?
This is the last chart version 8.
So, thanks goes to anychart support.
Unfortunatly, 3d charts doesn't support categorized_by_series attribute, at least for now.
If you need this functionality, you have to used 2d variant only.

Replace XML Span Element with Inner text of Span Tag in SQL Server

Replace span Element with its inner text whose class is "TAGGED_ITEM " in multiple rows with a column of type XML
<Item title="1234" xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2">
<ItemBody>
<div class="item_text">
<div>
<span class="TAGGED_ITEM " id="c1_ae1">This is a map on a grid.</span>
<span class="TAGGED_ITEM " id="c1_ae2"> It shows a car.</span>
</div>
<span class="TAGGED_ITEM " id="c1_ae3"> It shows a car on Road.</span>
</div>
</ItemBody>
</Item>
Once Element is updated it should looks as below.
<Item title="1234" xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2">
<ItemBody>
<div class="item_text">
<div>
This is a map on a grid.
It shows a car.
</div>
It shows a car on Road.
</div>
</ItemBody>
</Item>
This question had a particular namespace problem which, probably, had aroused the question. Eliminating namespaces on the match= does solve the problem. So an identity transform and a namespace-neutral matching gives the desired result:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|#*">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[local-name() = 'span']">
<xsl:value-of select="text()" />
</xsl:template>
</xsl:stylesheet>
Result:
<?xml version="1.0"?>
<Item xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" title="1234">
<ItemBody>
<div class="item_text">
<div>
This is a map on a grid.
It shows a car.
</div>
</div>
</ItemBody>
</Item>

Transfer XML file with a languages section to a database table using XSLT

below is a part of the xml file I get. I want to transfer this to a single mssql database table. My problem are the different languages of each job-element. The three languages below won't change in time.
I want to create 2 columns for each language in the db-table.
Example: EnglishTitle & EnglishDescription
<jobs>
<job nr="1">
<language name="English">
<title>English title</title>
<description>
<li>English description</li>
<li>English description 2</li>
<li>English description 3</li>
</description>
</language>
<language name="German">
<title>German title</title>
<description>German description</description>
</language>
<language name="Chinese">
<title>Business Mission Chinese</title>
<description>German description</description>
</language>
<general>For all languages</general>
</job>
</jobs>
How can I use XSLT to lookup the language name attribute and create two elements for each language with the content of the name attribute?
UPDATE:
This is what I think the output should look like:
<jobs>
<job nr="1">
<EnglishTitle>English title</EnglishTitle>
<EnglishDescription>
<li>English description</li>
<li>English description 2</li>
<li>English description 3</li>
</EnglishDescription>
<GermanTitle>German title</GermanTitle>
<GermanDescription>German description</GermanDescription>
<ChineseTitle>Business Mission Chinese</ChineseTitle>
<ChineseDescription>Chinese description</ChineseDescription>
<general>For all languages</general>
</job>
</jobs>
Additionally how should I store the <li>-Elements
of a description in the table? Should I replace them with new lines or with a special character?
If there is a better way feel free to tell me.
IMHO, you should have a separate row for each individual description, with columns describing the job number (hopefully unique), the language and the description itself. So something like:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/jobs">
<table>
<xsl:for-each select="job/language/description/text() | job/language/description/li ">
<row>
<col><xsl:value-of select="ancestor::job/#nr"/></col>
<col><xsl:value-of select="ancestor::language/#name"/></col>
<col><xsl:value-of select="."/></col>
</row>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
which in your example would return:
<?xml version="1.0" encoding="utf-8"?>
<table>
<row>
<col>1</col>
<col>English</col>
<col>English description</col>
</row>
<row>
<col>1</col>
<col>English</col>
<col>English description 2</col>
</row>
<row>
<col>1</col>
<col>English</col>
<col>English description 3</col>
</row>
<row>
<col>1</col>
<col>German</col>
<col>German description</col>
</row>
<row>
<col>1</col>
<col>Chinese</col>
<col>German description</col>
</row>
</table>

How to show a message in jsf page after completing DB update

I am using following code to edit value of a record. And the code is working fine.
<rich:popupPanel header="Edit Company Region" id="editCompanyRegionPane"
domElementAttachment="parent" width="230" height="115">
<h:form>
<h:panelGrid columns="3" id="editCompanyRegionGrid">
<h:inputHidden value="#{CompanyAdminPageModel.editCompanyRegion.companyRegionId}"
id="editcompanyRegionId">
</h:inputHidden>
<h:message for="editcompanyRegionId" />
<h:column>
<h:outputText value="Name " />
<h:inputText value="#{CompanyAdminPageModel.editCompanyRegion.name}"
id="editCompanyRegionName">
</h:inputText>
<h:message for="editCompanyRegionName" />
</h:column>
</h:panelGrid>
<h:commandButton value="Update"
action="#{CompanyAdminPageModel.companyRegionUpdate}" render="table"
oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editCompanyRegionPane')}.hide();}" />
<h:commandButton value="Cancel"
onclick="#{rich:component('editCompanyRegionPane')}.hide(); return false;" />
</h:form>
</rich:popupPanel>
I want to show a message in the same page after updating the value in database. For example: when I will click on the update button then it will call method from Bean class and then update value in the DB and after closing the popup panel it will display a message (like: updated successfully) inside the same page.
Any help please.
I used follwoing java code:
public String updateUser(Long usrId, String firstName, String lastName,
String loginName, String emailAddr) {
AllCompanyDAO aDAO = new AllCompanyDAO();
FacesContext.getCurrentInstance().addMessage("test", new javax.faces.application.FacesMessage("Success"));
return aDAO.userUpdate(usrId, firstName, lastName, loginName, emailAddr);
}
and following jsf code:
<div class="content container">
<div style="padding-left:220px;">
To see the relationships between users and regions <a href="#{appPath}/app/insertion/userRegionInfo.faces" >click here</a> <br/>
<h:message for="test"></h:message>
</div>
</div>
At the end of companyRegionUpdate(), add :
A message
FacesContext.getCurrentInstance().addMessage("test", new FacesMessage("Success"));
Where test is the absolute reference to the <h:message> JSF component.
To your <h:commandButton> , add Ajax support
Such as
<h:commandButton value="Update" >
<a4j:support oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('editCompanyRegionPane')}.hide();}" action="#{CompanyAdminPageModel.companyRegionUpdate}" event="onclick" reRender="test, table" />
</h:commandButton>
Where test is the absolute reference to the <h:message> JSF component.
Instead of adding ajax support to your <h:commandButton>, you could simply use <a4j:commandButton > component which has ajax support.
I used following code that solved my problem.
1. Used the following code in the companyRegionUpdate method in java.
FacesContext.getCurrentInstance().addMessage("test", new javax.faces.application.FacesMessage("Successful"));
Then used <h:messages /> inside my desired div. <h:messages /> is different than <h:message />. In my case <h:messages /> works.
That's it. :-)

VisualForce - conditional html tags

I am trying to apply a different style to the first element in a list.
I am currently attempting to use a counter to apply the li with a class only when cnt==0 but I cannot include < > brackets in an OutputText tag. Is there any way to escape the brackets or insert the class into an <li> tag using a condition?
I know this could be done after the fact using JavaScript but I'd rather avoid it.
<apex:variable var="cnt" value="{!0}" />
<apex:repeat value="{!items}" var="item" >
<!-- only render the class if it is the first element -->
<apex:OutputText value="<li class="activeLI">" rendered="{!cnt==0}" />
<apex:OutputText value="<li>" rendered="{!cnt!=0}" />
<img src="{!$Resource[item.Image__c]}" width="85" height="90"/>
</li>
<apex:variable var="cnt" value="{!cnt+1}"/>
</apex:repeat>
Visualforce is strict, every element must have an opening and closing tag or must be self-closing. When compiled, Visualforce will complain as it will only see the closing "li" tag and not the conditional opening "li" tag, one solution is to make the class name a variable as follows:
<apex:variable var="cnt" value="{!0}" />
<apex:variable var="class" value=""/>
<apex:repeat value="{!items}" var="item" >
<apex:variable var="class" value="activeLI" rendered="{!cnt==0}"/>
<apex:variable var="class" value="" rendered="{!cnt!=0}"/>
<li class="{!class}">
...
</li>
<apex:variable var="cnt" value="{!cnt+1}"/>
</apex:repeat>
Have you consider using a CSS selector? Here's an example on how to style the first element of a list.
<style>
ul.myList > li:first-child {color : red}
</style>
<ul class="myList">
<li>this is red</li>
<li>this has default formatting</li>
</ul>
Have you considered using <apex:dataList>? I think it may accomplish what you're looking to do.

Resources