I've been playing around of this issue for awhile now and can't get my head wrapped around of it. I'm using Liferay 6.1 CE GA2.
Goal:
User editable content, for example footer in each page. I've created the web content which id is 12701.
Method:
#set ($local_temp_content = $journalContentUtil.getContent($scope_group_id, "12701", null, "$locale", $theme_display))
$local_temp_content<br />
Issue:
It won't return anything sensible. It's just printing "$local_temp_content" as the result.
Any pointers how to debug this issue?
This is a velocity macro to retrieve a web content by ID from local scope first and then by global scope:
#macro(glarticle $temp_article_id)
#set ($temp_content = "")
#set ($scope_group_id = $theme_display.scopeGroupId)
#set ($global_group_id = $theme_display.companyGroupId)
#set ($temp_content = $journalContentUtil.getContent($scope_group_id, $temp_article_id, null, "$locale", $theme_display))
#set ($temp_content = "$!{temp_content}")
#if ($temp_content.length() == 0)
#set ($temp_content = $journalContentUtil.getContent($global_group_id, $temp_article_id, null, "$locale", $theme_display))
#end
$!{temp_content}
#end
How to use it:
#glarticle('1234')
For debugging velocity try outputting every part of your call.
scope_group_id = $scope_group_id<br>
theme_display = $theme_display<br>
journalContentUtil = $journalContentUtil<br>
If you get exactly what you wrote than that variable is not available.
If all are resolved then possibilitis are:
wrong article id
there was exception during article rendering (you should check log)
Related
Apologies if this has been asked before but i could not find a straightforward answer.
I have the following code, the application is a third party so the incoming $supernet is provided as a string. So what i am wanting to do it take a IP address and then manipulate it to create a list of subnets based on a template.
#set ($Supernet = "10.10.10.10")
#set ($octs = $Supernet.split("\."))
#set ($netmgmt[2] = "$octs[0].$octs[1].$octs[2].$octs[2]+1")
$netmgmt
But this as I expect gives the result "10.10.10.10+1"
I figured out I can do this in a longhand way
convert the $oct[2] to an integer and store in a variable
create a temporary variable and store the result of the converted $oct[2] + 1
Then use this to create the string
like
$Integer = $convert.toInteger($oct[2])
#set ($newoct = $Integer + 1)
#set ($netmgmt[2] = "$octs[0].$octs[1].$octs[2].$newoct")
but i have a lot of these to create and this will get long winded and confusing.
So i am trying to work out if I can write #set ($octs = $Supernet.split(".")) to store as integers. To be honest just trying to directly convert each array value to int does not seem to work as based on what i have found on line. I expected the below would result in "$oct1 = 10" but it does not?
#set ($Supernet = "10.10.10.10")
#set ($octs = $Supernet.split("\."))
#set ($oct1 = $convert.toInteger($oct[0])
New to Velocity any help appreciated.
You should check which version of Velocity-Tools you are using, and which tools are available in the provided context.
Since Velocity-Tools 3.1, for instance, $convert.toInteger() has been deprecated in favor of $math.toInteger(). You can check if those tools are present in the context just by displaying $convert and $math.
The following code works for me with Velocity 1.7 + Tools 2.0, as long as with Velocity 2.X + Tools 3.x:
#set ($Supernet = "10.10.10.10")
#set ($octs = $Supernet.split('\.'))
#set ($last = $math.toInteger($octs[2]) - 1)
#set ($ip = "${octs[0]}.${octs[1]}.${octs[2]}.$last")
$ip
I'm using library apache odftoolkit to generate report from Java code to *.odt file. Have code like this:
outputOdt = TextDocument.newTextDocument();
Paragraph p = outputOdt.addParagraph("some text");
p.appendTextContent("some text");
I'm adding paragraphs, tables, setting fonts, and it works fine.
But I need to set some pages in my document in Landscape mode but
don't know how to do this. I found API class PageLayoutProperties and method setPrintOrientation(), but don't know where to call it. Anybody know?
Found solution:
TextDocument outputOdt;
for( Iterator<StyleMasterPageElement> it = outputOdt.getOfficeMasterStyles().getMasterPages(); it.hasNext(); ) {
StyleMasterPageElement page = it.next();
String pageLayoutName = page.getStylePageLayoutNameAttribute();
OdfStylePageLayout pageLayoutStyle = page.getAutomaticStyles().getPageLayout( pageLayoutName );
PageLayoutProperties pageLayoutProps = PageLayoutProperties.getOrCreatePageLayoutProperties( pageLayoutStyle );
double tmp = pageLayoutProps.getPageWidth();
pageLayoutProps.setPageWidth( pageLayoutProps.getPageHeight());
pageLayoutProps.setPageHeight( tmp );
}
I came across this existing question and answer:
How can the Page Size, Page Orientation, and Page Margins of an ods Spreadsheet Be Set Using ODFDOM?
which is about doing the same thing for an ODS spreadsheet, which is essentially the same. Key is to set the page height and width as well as the print orientation in the PageLayoutProperties
I am using liferay 6.1.20.
Structure variable demo_image : type Document and Media
here is my template code. It is not fetching uuid or groupId from url !
#set ($dlLocalService = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLAppLocalService"))
#set ($url = $getterUtil.getString($demo_image.getData()))
#set ($uuid = $getterUtil.getString($httpUtil.getParameter($url, "uuid", false)))
#set ($groupId = $getterUtil.getLong($httpUtil.getParameter($url, "groupId", false)))
#set ($imageObj = $dlLocalService.getFileEntryByUuidAndGroupId($uuid,$groupId))
#set ($imageSmallid = $imageObj.getSmallImageId())
#set ($imageLargeid = $imageObj.getLargeImageId())
#set ($imageTitle = $imageObj.getTitle())
#set ($imageDescription = $imageObj.getDescription())
#set ($urlLargeImage = "/documents/imageLargeid")
#set ($urlSmallImage = "/documents/imageSmallid")
$imageTitle
<img src="$urlSmallImage" rel="$imageTitle" alt="$imageTitle" />
Check value of $url for your image, does this URL contain uuid & groupId if yes you should get the values. else if url contains imageId try using different method from service util.
Also try using DLFileEntryLocalService instead of DLAppLocalService
Hope this helps you find your solution !
In Dynamics CRM, how do you set the height of an iframe programmatically? The following function doesn't do anything, the iframe always comes up the same size. Even when you go to iframe properties and change the row numbers there, it still doesn't cause any changes in size.
function doOnLoad(sender, args) {
setIframeHeight();
}
function setIframeHeight() {
//lowest control in iframe
var element = $('btnInsert');
//the following line gets called, and what's displayed is 25
alert(window.parent.parent.frames[0].document.getElementById('IFRAME_TransactionProduct_RA_d').parentNode.height);
//the following line doesn't do anything
window.parent.parent.frames[0].document.getElementById('IFRAME_TransactionProduct_RA_d').parentNode.height = 5000000;
}
you may try this in iframe code:
//set div(show iframe) height = iframe body height * 1.2 window.parent.parent.frames[0].document.getElementById('IFRAME_ApprovalProcess_d').style["height"] = ($(body * 1.2)) + "px";
//but it may get some issue if the contenter in the form not load,so that window.parent.parent.frames[0].document.getElementById('IFRAME_ApprovalProcess_d') this can be undifined.
To get the height of a element you can do like you have but to set you have use style, like that:
parentNode.style.height = "100px";
I've created a custom edit form as a simple aspx page in VS2010 (inherits from LayoutsPageBase) which uses the SharePoint Web controls LookupField control to display a drop down list of values from a custom type
The form displays correctly with the drop down box containing the expected range of values
The ControlMode is set to the same as the FormContext (though I have tried explicitly setting this to Edit)
But on the postback the value of the dropdown list is not set - the selected item index is set to -1
How can I correctly use the LookupField control to capture a selected value from the user?
Could it be because I'm adding the controls declaritivly in the aspx and then setting the list id etc from the SPContext in the page load event? - see code snippet below (not the prettiest but just trying to get it to work at this point):
from aspx:
<SharePoint:FileField ID="FileNameText" InputFieldLabel="Name" runat="server" ControlMode="Display"/><br />
<SharePoint:LookupField ID="FeedType" runat="server" />
<SharePoint:TextField ID="FeedStatus" runat="server" />
....
in the code behind page load:
if (!IsPostBack)
{
SPItem feedFileItem = SPContext.Current.Item;
FileNameText.ControlMode = SPContext.Current.FormContext.FormMode;
FileNameText.ListId = SPContext.Current.ListId;
FileNameText.ItemId = SPContext.Current.ItemId;
FileNameText.FieldName = "Name";
FeedType.ControlMode = SPControlMode.Edit;
FeedType.ListId = SPContext.Current.ListId;
FeedType.ItemId = SPContext.Current.ItemId;
FeedType.FieldName = "FeedType";
FeedStatus.ItemContext = SPContext.Current;
FeedStatus.RenderContext = SPContext.Current;
FeedStatus.ControlMode = SPControlMode.Edit;
FeedStatus.ListId = SPContext.Current.ListId;
FeedStatus.ItemId = SPContext.Current.ItemId;
FeedStatus.FieldName = "FeedStatus";
}
UPDATE
Ok I managed to get my form working by adding the controls in the code behind in the override of CreateChildControls - this is in line with the majority of the samples I've seen on the net.
But can someone explain why my approach didn't work and whether I can do this all in a declarative way in the aspx?
During postbacks selected values from lists are simply ignored if the list control isn't populated. So if you choose item 2 and the list items are null it will simply ignore the response parameter and not set the Value property. This is because ProcessPostData occurs prior to LoadData. Even if you were to remove the !IsPostBack on the LoadData method it still wouldn't work because ProcessPostData still occurs before LoadData and you didn't load the list prior to processing the postback.
A simple way to fix this is move your initialization code into the EnsureChildControls method of your Application page.
protected override void EnsureChildControls()
{
base.EnsureChildControls();
...
FeedType.ControlMode = SPControlMode.Edit;
FeedType.ListId = SPContext.Current.ListId;
FeedType.ItemId = SPContext.Current.ItemId;
FeedType.FieldName = "FeedType";
...
}