Jsf: column header not displayed if included - jsf-2

In a dataTable a column contains lots of images which are conditionally rendered one at a time. That content was common with other dataTables so I decided to move it in a separate file and now I have something like this:
<h:column><ui:include src="myFile,xhtml" /></h:column>
Inside the h:column tag there was also the following f:facet tag, which was moved with the rest of the code
<f:facet name="header">Status</f:facet>
Now the column content is correctly displayed but the header is empty. Why ?
Maybe the ui:include is evaluated after the column headers are created...in that case I would need to be pointed to a good documentation for gaining a better insight on how JSF builds and renders a dataTable.
I forgot to mention I'm using Mojarra 2.0/2.1.
Thanks
Filippo

Related

Use a html page as a custom section in Umbraco 7 without a tree

I have a HTML page that I want to show in a custom section in Umbraco 7.
I want to do this without having any tree within that section, as everything is already handled within the html file - It is being placed into the Umbraco back end for convenient access.
So far I have implemented IApplication which gets the section to show as expected. I did have a tree with a single node (Inheriting from BaseTree, making this a legacy section), however, I want to make full use of the space available and just load in my html file and have no tree showing.
Removing the nodes from the BaseTree Render method hides the panel that shows the tree, but I can't figure out how to load in the Html file as the default view for that section.
Is there an easy way to do this by essentially setting a default page to load when the user clicks into the section?
You can set the default view for a custom section in Umbraco 7 by adding a new section element to Dashboard.config as follows:
<section alias="StartupCustomDashboardSection">
<areas>
<area>custom</area>
</areas>
<tab caption="Get Started">
<control>/app_plugins/custom/defaultview.html</control>
</tab>
</section>
where the <area> element must contain the alias of your custom section, all in lower case.
The <control> element contains the path of the default html file.

How do I get Grails g:select with multiple-selection with all selections when returning from the controller

I have a page that is a report from a database and I'm working on modifying how the filtering works. The intention is to allow the user to select possible values form a list that will be used to filter the resulting report. There are too many values to do this with checkboxes. I'm defining a multiple selection list box with this:
<g:select name="country" from="${countryDataList.KOUNTRY}" value="${params.country}" multiple="true" />
countryDataList is a List<> of objects with a name and a value which I create in the controller. I'm able to get the selected counties and process them without an issue.
But when the page returns from the controller with the filtered report, only the first selection in the list is selected. It doesn't re-select all of the items that the user selected. I am passing the params.country object back from the controller as
country:params.country
I saw some posts about this not working, but they are all from several years ago. Am I missing a vital step?
Ahh sorry, I was reading it on the phone initially and missed the point.
So what you want is a way of sending a multiple select box to a confirmation page. If I understand correctly?
Anyways how many objects in the select are we talking massive or a dozen couple of dozen or so ?
What I did was use check boxes and did a confirmation which shows the selection ticked in check boxes.. So this is the confirmation page that loads in https://github.com/vahidhedayati/mailinglist/blob/master/grails-app/views/mailingListEmail/confirmcontact.gsp
this page which is where multiple attachments selected from the schedule re-appear...
https://github.com/vahidhedayati/mailinglist/blob/master/grails-app/views/mailingListAttachments/_mailerAttachmentsDisplay.gsp.
Please note advice below is all conceptual stuff and there may be easier ways than this
Other than that You could create a taglib call on the confirmation page https://github.com/vahidhedayati/ajaxdependancyselection/blob/master/grails-app/taglib/ajaxdependancyselection/AutoCompleteTagLib.groovy#L55 which takes in your arrayList you could probably convert it to JSON pass it into the javascript that you load in within the taglib (on mine further down it loads this page in)
https://github.com/vahidhedayati/ajaxdependancyselection/blob/master/grails-app/views/autoComplete/_selectJs1.gsp#L23
and look to reselect them using javascript... as I say I haven't tested the last bit, the first bit i.e. checkbox works it is/has been in use.
Years later from you I just had the same problem. What I figured out is: it happens when params.country is an array instead of a Collection (i.e. an ArrayList).
A workaround for this if you want to stick to the array type is at the value attribute of the tag doing this: params.country?.findAll().

How to supply hardcoded multiline content in h:inputTextarea

In HTML I can do:
<textarea>
line 1
line 2
line 3
</textarea>
However, the same thing doesn't work with the JSF <h:inputTextarea>, as I have to specify the value attribute instead of the body. Is there a way that I can specify a multiline value? Ideally I would like to be able to do it as seamlessly as in HTML, ie with no \n and actually putting it onto multiple lines, for easy readability.
You could try this :
<h:outputFormat escape="false" value="Line 1<br/>Line 2" />
Which would render:
Line 1
Line 2
Note:The escape="false" means you can embed html, like lists etc...
or else we can even try like this:
Alternatively you could set readonly to true on the inputTextArea and set the rows attribute.
I Hope this will help you
Well, I couldn't find a way to include the textarea content directly into the .xhtml, while keeping the content on several lines. There's probably a way with some javascript by using a different tag and then copying it in or something, but I wanted to keep it fairly clean.
What I ended up doing was using the value attribute of h:inputTextarea and I populated it from my managedBean. I created text files of the content I wanted (they were quite big files) and loaded them into the managedBean property using a FileReader. When you assign them to the value of the h:inputTextArea, the \n etc are respected, so that it gives you the identical effect to if you had hardcoded the text into the .xhtml between textarea tags.

multi line tag in grails or html

With a grails app and from a local database, I'm returning some text in a xml format.
I can return it well formed in a <textarea></textarea> tag with the correct indenting (tabulation, line return,...etc.)
I want to go a bit further. In the text I'm returning, there are some <img/> tags and I'd like to replace those tag by the real images themselves.
I searched around and found no solution as of now. I understood that you can't add an image to a textarea (other then in a background), and if I choose a div tag, I won't have the indenting anymore (and therefore, harder to read)
I was wondering if using a <g:textField/> or an other tag from the grails library will do the trick. And if so, How can I append them to a page using jquery.
For example, how to append a <g:textField/> in jquery. It doesn't interpret it and I get this error
SyntaxError: missing ) after argument list [Break On This Error]...+doc).append("<input type="text" id="FTMAP_"+nb_sec+"" ...
And in my javascript file, I have
$("#FTM_"+doc).append("<g:textField id='FTMAP_"+nb_sec+"' ... />
Any possible solutions ?
EDIT
I did forget to mention that my final intentions are to be able to modify the text (tags included) and to have a nice and neat indentation so that it is the easiest possible for the end user.
You are asking a few different questions:
1. Can I use a single HTML tag to include images inside pre-formatted text.
No. You will have to parse the text and translate it into styled text yourself.
2. Is there a tag in the grails standard tags to accomplish this for me?
No.
3. How can I add grails tags from my javascript code.
Grails tags are processed on the server-side, and javascript is processed on the client. This means you cannot directly add grails tags via javascript.
There are a couple methods that can accomplish the same result, however:
You can set a javascript variable to the rendered content of a grails tag. This solution is good for data that is known at the time of the initial request.
var tagOutput = "${g.textField(/* etc */)}";
You can make an ajax request for the content to be added. Then your server-side grails code can render the tags you need. This is better for realtime data, or data that will be updated more than once on a single rendered page.

GSP Access to Controller Results

I am using the Dojo plugin for Grails to populate a dojox.grid.DataGrid object. Right now my controller action associated with this grid renders the JSON that defines the grid contents. That works just fine as long as I predefine the columns in the GSP. However, my application needs to be able to set the number of columns (and their associated names) dynamically based on some database query results. The JSON format for this grid does not include the column names so I cannot use a g:each tag in my GSP to iterate through the names.
I wanted to do something like this but am unable to do so:
<dojo:grid controller='foo' action='getGridData' ...>
<g:each in=${columns}>
<dojo:col width="15%" name="{it}" field="{it}">{row.{it}}<dojo:col/>
</g:each>
</dojo:grid>
I gave the specific example of the Dojo plugin for background but I would like to extend this to a more general question about Grails. If I am constructing a GSP element by a controller action that renders JSON how do I access other things in the controller for the construction of nested elements? Is this even possible? I am still new to web development so I am sure I am misunderstanding some of the glue between these components.
The main thing I see wrong with your code is you're trying to reference the columns data incorrectly.
<g:each in="${columns}">
<dojo:col width="15%" name="${it}" field="${it}">{row.{it}}<dojo:col/>
</g:each>
Note the quotes around the in= value and the dollar sign used to reference the it variable.
Regarding the last bit
{row.{it}}
I'm unclear on what row is in this case. So I'm not sure how that needs to be fixed, but maybe this gets you moving in the right direction.
You generally don't render a GSP and construct JSON in one request. What will happen here is you render your GSP which takes all your taglib code and produces HTML/JavaScript. Then, once the browser renders it, an AJAX call takes place to fetch the JSON.
Remember that by the time the GSP reaches the browser, it is just HTML.

Resources