grails multiple line in g:sortableColumn - grails

how can I do a line-break in a g:sortableColumn tag?
I tried it with
<g:sortableColumn property="film.name" title="Line1\nLine2" />
and
<g:sortableColumn property="film.name" title="Line1<br />Line2" />
but that didn't worked.
What is the right syntax for a line break?
Thanks

A workaround would be to set a variable with the html new line tag <br /> like this:
<c:set var="filmName">Line1<br />Line2</c:set>
And then put your variable in the column title:
<g:sortableColumn property="film.name" title="${filmName}" />

Related

what is f:optionalBlock in jelly

I have seen a jelly file with f:optional block
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler">
<j:choose>
<j:when test="${instance == null}">
<f:entry title="${%File}" field="file">
<input type="file" name="file" size="40" jsonAware="yes"/>
</f:entry>
</j:when>
<j:otherwise>
<f:invisibleEntry>
<f:textbox field="fileName"/>
</f:invisibleEntry>
<f:invisibleEntry>
<f:textbox field="secretBytes"/>
</f:invisibleEntry>
<f:optionalBlock title="${%upload(instance.fileName)}" inline="true">
<f:entry title="${%File}" field="file">
<input type="file" name="file" size="40" jsonAware="yes"/>
</f:entry>
</f:optionalBlock>
</j:otherwise>
</j:choose>
<st:include page="id-and-description" class="${descriptor.clazz}"/>
</j:jelly>
What is f:optional block doing here, i mean whats its significance here ?
Jelly code internally converts to simple HTML and JavaScript code.
<f:optionalBlock> block is used to display a checkbox. When you click on this checkbox, the fields inside the checkbox are displayed on the UI.
In your example, file parameter will be displayed on UI.
We can use inline and checked properties of <f:optional> block

Generated docx file is corrupted

I have a legacy Rails app, that can generate docx file. It's using just xml template, not any gem. Template is written using ERB syntax.
The problem is that generated file is marked as "corrupted" by MS Office Word, though LibreOffice on Linux opens it flawlessly. However, after recovering MS Office Word seems to open file without any content losses too.
I paste full XML template on pastebin.
While debugging I found out, that without the block, starting on the line 602, everything works fine. So I can't get, what's wrong with that particular piece of XML. I'll paste it right here for convenience
<% [task[:design_front], task[:design_back]].compact.each do |img_data| %>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Arial" w:eastAsia="Times New Roman" w:hAnsi="Arial" w:cs="Arial" />
<w:noProof />
<w:sz w:val="18" />
<w:szCs w:val="18" />
<w:lang w:eastAsia="ru-RU" />
</w:rPr>
<w:drawing>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="<%= img_data[:width] * 7400 %>" cy="<%= img_data[:height] * 7400 %>" />
<wp:effectExtent l="0" t="0" r="0" b="0" />
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="0" />
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPicPr>
<a:picLocks noChangeAspect="0" noChangeArrowheads="0" />
</pic:cNvPicPr>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="<%= img_data[:id] %>" cstate="print">
<a:extLst>
<a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
<a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0" />
</a:ext>
</a:extLst>
</a:blip>
</pic:blipFill>
<pic:spPr bwMode="auto">
<a:xfrm>
<a:off x="0" y="0" />
<a:ext cx="<%= img_data[:width] * 7400 %>" cy="<%= img_data[:width] * 7400 %>" />
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst />
</a:prstGeom>
<a:noFill />
<a:ln>
<a:noFill />
</a:ln>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
</w:r>
<% end %>
I tried to compare recovered file with my file, but I didn't see any crucial differences. I don't have that diff right now, but I can reproduce it if necessary.
Can someone show me the way? :) What am I doing wrong?
UPDATE
I tried to make corrections, suggested by Martin P., but no luck. Here is a diff between my generated file and recovered version (recovered on the right)
As far as I see, you are missing two element and some attributes.
(1) The wp:inline needs to have a wp:docPr element containing an id, name, and descr attribute.
<wp:docPr id="<% id %>" name="<% picture_name %>" descr="<% full_file_path_to_the_picture %>"/>
(2) The pic:nvPicPr element needs to have a pic:cNvPr element containing the same attributes.
<pic:cNvPr id="<% id %>" name="<% picture_name %>" descr="<% full_file_path_to_the_picture %>"/>
Of course you have to insert the missing variables (<% .. %>).
Here I marked the line where to insert the elements using comments:
<% [task[:design_front], task[:design_back]].compact.each do |img_data| %>
<w:r>
<w:rPr>
<w:rFonts w:ascii="Arial" w:eastAsia="Times New Roman" w:hAnsi="Arial" w:cs="Arial" />
<w:noProof />
<w:sz w:val="18" />
<w:szCs w:val="18" />
<w:lang w:eastAsia="ru-RU" />
</w:rPr>
<w:drawing>
<wp:inline distT="0" distB="0" distL="0" distR="0">
<wp:extent cx="<%= img_data[:width] * 7400 %>" cy="<%= img_data[:height] * 7400 %>" />
<wp:effectExtent l="0" t="0" r="0" b="0" />
<!-- insert wp:docPr here -->
<wp:cNvGraphicFramePr>
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="0" />
</wp:cNvGraphicFramePr>
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:nvPicPr>
<pic:cNvPicPr>
<!-- insert pic:cNvPr here -->
<a:picLocks noChangeAspect="0" noChangeArrowheads="0" />
</pic:cNvPicPr>
</pic:nvPicPr>
<pic:blipFill>
<a:blip r:embed="<%= img_data[:id] %>" cstate="print">
<a:extLst>
<a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
<a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0" />
</a:ext>
</a:extLst>
</a:blip>
</pic:blipFill>
<pic:spPr bwMode="auto">
<a:xfrm>
<a:off x="0" y="0" />
<a:ext cx="<%= img_data[:width] * 7400 %>" cy="<%= img_data[:width] * 7400 %>" />
</a:xfrm>
<a:prstGeom prst="rect">
<a:avLst />
</a:prstGeom>
<a:noFill />
<a:ln>
<a:noFill />
</a:ln>
</pic:spPr>
</pic:pic>
</a:graphicData>
</a:graphic>
</wp:inline>
</w:drawing>
</w:r>
<% end %>
If you look at your diff, you may see those elements added.
The fact that MS Office Word replaced the value of r:embed suggests that there was no definition of #Id="image_1" in the relationships file of this document. The relevant relationships file is probably word/_rels/document.xml.rels.
After many hours of debugging the answer is found.
The last part of this puzzle was the file [Content_Types].xml. It contained the line <Default Extension="jpeg" ContentType="image/jpeg" />, but my images have .jpg extension. I changed Extension attribute to jpg and error was gone.
However, the additions suggested by Martin P. are necessary too (how can I credit him by the way?), because without them the resulting file remains corrupted, but with an another error message.
Thanks to everybody, who tried to help me. I hope, this answer will help someone in the future.

JSF: Update and add new request params

I have a page with the following params:
<f:metadata>
<f:event type="preRenderView" listener="#{busquedaBean.init}" />
<f:viewParam name="k" value="#{busquedaBean.keyword}" />
<f:viewParam name="categoryId" value="#{busquedaBean.categoryId}" />
<f:viewParam name="minprice" value="#{busquedaBean.minPrice}" />
<f:viewParam name="maxprice" value="#{busquedaBean.maxPrice}" />
</f:metadata>
All of them are optional. I need to do 2 things, which I wasn't able to do so far:
1) Add new params (keeping the previous params). This is what I tried for adding price params:
<h:outputText value="Precio diario" />
<o:form includeRequestParams="true">
<h:outputText value="min: " />
<p:inputText id="min" value="#{busquedaBean.minPrice}" />
<h:outputText value="max: " />
<p:inputText id="max" value="#{busquedaBean.maxPrice}" />
<p:commandButton icon="ui-icon-search" ajax="false">
<f:param name="minprice" value="#{busquedaBean.minPrice}" />
<f:param name="maxprice" value="#{busquedaBean.maxPrice}" />
</p:commandButton>
</o:form>
This basically works but the problem is that the URL is not updated. if the params in the URL were ?minprice=10&maxprice=200 and I update those values, the url remains the same. if these params were not included in the url, they won't be added and the filter won't work.
2) Updating the value of a param:
When categoryId is not empty, I want to show a button that will clear this param. This is what I tried:
<p:button outcome="/busqueda" includeViewParams="true" >
<f:param name="categoryId=" value="" />
</p:button>
But this button makes a GET to this URL: /busqueda/?categoryId=%3D&categoryId=1
The categoryId param appears twice. How can I just update the existing param?
I'm using MyFaces 2.1.14, Tomcat 7, Primefaces 4.0, Omnifaces
Thanks!
I was looking at this in the wrong way. includeViewParams=true will make the request include all the params declared in f:metadata with the current values. if such value is null, then the parameter is not included.
So.. to add price params:
<h:form >
<h:outputText value="$ " />
<p:inputText id="min" value="#{busquedaBean.minPrice}"/>
<h:outputText value=" a $ " />
<p:inputText id="max" value="#{busquedaBean.maxPrice}"/>
<p:commandButton icon="ui-icon-search" ajax="false" action="/busqueda?faces-redirect=true&includeViewParams=true" />
</h:form>
And to remove a param:
<p:commandButton action="#{busquedaBean.removeCategory}" ajax="false" icon="ui-icon-close" />
In the backing bean:
public String removeCategory() {
categoryId = null;
return "/busqueda?faces-redirect=true&includeViewParams=true";
}

External xml file for joomla! template parameters

I have the below code in templateDetails.xml file, in a sample custom Joomla! 2.5.x template.
<config>
<fields name="params">
<fieldset name="advanced" addfieldpath="/plugins/system/framework/elements">
<field name="elements" type="elements" label="" addfieldpath="/plugins/system/framework/elements" />
</fieldset>
</fields>
</config>
I want to have an external .xml file with options like below?
<?xml version="1.0" encoding="utf-8"?><form name="template-options">
<fieldset name="toolbar-panel" label="TOOLBAR">
<field name="presets" type="preset" mode="scroller" default="preset1" setbyurl="true" setinoverride="false" panel_position="left" show_label="false"/>
</fieldset>
I dont'want to add the fieldset inside templateDetails.xml, I want it external.
Is that possible?
Thank you.

Change the selection state of the litstbox item when a user clicks on a button (ZK 3.6.4)

I'm working in a project with ZK 3.6.4. but I have a problem, I want to change the selection state of the litstbox item when a user clicks on a button inside the same listbox ( same listitem)., because I want to know the selectedItem. I was reading zk documentation and I can do it , but with Zk version 5.0.5+ (nonselectableTags). But I cannot change for this version for project rules. So, there are a way to emulate this behavior with 3.6.4? or what kind of advices can you give me to do this? I really appreciate your help.
Here the code that I have.
<listbox
id="listDocAcads" mold="paging" pageSize="2"
model="#{win$composer.academicCollections}"
selectedItem="#{controller.docEntAcad}" >
<listhead>
<listheader
width="30%" label="Name" />
<listheader
width="15%" label="amount" />
<listheader
width="15%" label=" delivered?" />
<listheader
width="20%" label="Importance" />
<listheader
width="20%" label="Document" />
</listhead>
<listitem
self="#{each='docAcad'}" value="docAcad"
style="border:none;">
<listcell
label="#{docAcad.colleByProcess.oDocument.name}" />
<listcell
label="#{docAcad.colleByProcess.amount}" />
<listcell>
<spinner
width="60%" value="#{docAcad.amount}" />
</listcell>
<listcell
label="#{docAcad.colleByProcess.oImportance.name}" />
<listcell ><button id="btnUploadDocument" label="Upload"/> </listcell>
</listitem>
</listbox>
if you want to ignore button and input's u can do this.
nonselectableTags="button, input".
<listbox nonselectableTags="button, input">
<listitem><listcell><textbox/></listcell></listitem>
<listitem><listcell><button label="button"/></listcell></listitem>
<listitem><listcell><h:input xmlns:h="native"/></listcell></listitem>
<listitem><listcell><datebox/></listcell></listitem>
</listbox>
the values to nonselectableTags should be HTML tags separated by comma.
Hope this helps!

Resources