Issue with IF test on JSF xtml - if-statement

sorry i tried a lot of others replies, but still i can't use it:
i want to check the value of a bean in order to print html code or not but all the time i have FALSE condition:
here the code:
<tbody>
<ui:repeat value="${wasJvmInvbean.listWasJvmInv()}" var="jvm">
<tr>
<td>${jvm.jvmStatus}</td>
<td>${jvm.cellName}</td>
<td>${jvm.serverBean.hostname}</td>
<td>${jvm.jvmName}</td>
<td>${jvm.type}</td>
<td>${jvm.profilePath}</td>
<td>${jvm.wasVersion}</td>
<c:if test="${jvm.jvmName eq 'dmgr'}">
<td>webconsole http://xxxx:8080</td>
</c:if>
<c:if test="${jvm.jvmName ne 'dmgr'}">
<td>N.A.</td>
</c:if>
<td>${jvm.fid}</td>
<td>${jvm.heapMin}</td>
<td>${jvm.heapMax}</td>
<td>${jvm.wcDefaultType}</td>
<td>${jvm.wcHost}</td>
<td>${jvm.wcPort}</td>
</tr>
</ui:repeat>

FIXED following this as example … new code is
<h:outputLink value = "https://${jvm.serverBean.hostname}:${jvm.wcPort}/ibm/console" rendered="#{jvm.type eq 'DEPLOYMENT_MANAGER'}" target="_blank" >sffsd</h:outputLink>

Related

How can I build a complex e-mail - template plus content saved in a variable - using cfscript instead of cfmail?

This is expanding a bit on a question I asked earlier. Server is CF2016. I'm saving a table of data using savecontent:
savecontent variable = 'mailBody' {
writeOutput('
<table width="99%" style="border-collapse:collapse;width:99%;">
<tr>
<td style="background-color:##09AFFF;color:##FFFFFF;width:30%;padding-left:3px;padding-top:5px;padding-bottom:5px;font-size:12px;font-weight:700;border-bottom:1px solid ##5B5B5B;text-align:left;">Name</td>
<td style="background-color:##09AFFF;color:##FFFFFF;width:15%;padding-top:5px;padding-bottom:5px;font-size:12px;font-weight:700;border-bottom:1px solid ##5B5B5B;text-align:center;">Class</td>
<td style="background-color:##09AFFF;color:##FFFFFF;width:30%;padding-top:5px;padding-bottom:5px;font-size:12px;text-align:left;font-weight:700;border-bottom:1px solid ##5B5B5B;">City,State,ZIP</td>
<td style="background-color:##09AFFF;color:##FFFFFF;width:15%;padding-right:5px;padding-top:5px;padding-bottom:5px;font-size:12px;text-align:left;font-weight:700;border-bottom:1px solid ##5B5B5B;">Amount</td>
</tr>
');
for ( qryPeople in queryPeople ){
writeOutput('
<tr>
<td style="font-size:12px;padding-left:3px;padding-top:3px;padding-bottom:4px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;">#qryPeople.p_first# #qryPeople.p_last#</td>
<td style="font-size:12px;padding-left:3px;padding-top:3px;padding-bottom:4px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;text-align:center;">#YEAR(qryPeople.p_graduation)#</td>
<td style="font-size:12px;padding-left:3px;padding-top:3px;padding-bottom:4px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;">#qryPeople.p_city# #qryPeople.p_state#</td>
<td style="font-size:12px;padding-top:3px;padding-bottom:4px;padding-right:5px;background-color:#thisBgColor#;border-bottom:1px solid ##5B5B5B;">#NumberFormat(qryValue.p_value,'99,999')#</td>
</tr>
');
};
writeOutput('
<tr>
<td colspan="5" style="font-size:11px;padding-left:5px;padding-top:5px;padding-right:5px;padding-bottom:7px;background-color:##09AFFF;color:##FFFFFF;font-style:italic;border-bottom:1px solid ##5B5B5B;">footer text</td>
</tr>
</table>
');
};//end savecontent
Works fine through here - I can output the variable mailBody and I see a styled table suitable for HTML email.
We have stock email templates that we use (.htm) files that are stored centrally. I'm trying to inject this content into one of these templates to be sent.
mailerService = new mail();
mailTemplate = fileRead(application.paths.physicalroot & '\email\project1\templates\people.htm');
mailerService.setTo("me#domain.com");
mailerService.setFrom("support#domain.com");
mailerService.setSubject("People Report");
mailerService.setType("html");
mailerService.send(body=mailTemplate);
In the .htm template file I have
<cfoutput>#mailBody#</cfoutput>
And it's giving me exactly that - #mailBody#. In less complex e-mails I have no problem using something like
<cfoutput>Welcome #qryPeople.p_first# #qryPeople.p_last#</cfoutput>
Or accessing other variables set on the cfscript template that drives the e-mail. But I can't figure out why my savecontent variable isn't working as expected.
SOLUTION - previously trying a savecontent include did not work, but that may have been on ACF 2010. This works on ACF2016.
mailerService = new mail();
savecontent variable="mailTemplate" {
include variables.templatePath & '\email\project1\templates\people.htm';
};
mailerService.setTo("me#domain.com");
People.htm is included and the other savecontent (mailbody) is rendered in the e-mail. Now to figure it out using the newer cfmail() script...
If you only have one "block" to be evaluated, I'd just replace it using a string function:
mailTemplate = fileRead(application.paths.physicalroot & '\email\project1\templates\people.htm');
mailTemplate = replaceNoCase(mailTemplate, "##mailBody##", mailBody, "one");
// continue with mailerService.* methods
Another option is to use include with a saveContent:
This may require that you rename your template from a *.htm to be *.cfm file.
// create mailBody first using your current saveContent
savecontent variable="finalBody" {
include "#application.paths.physicalroot#\email\project1\templates\people.cfm";
}
The variable finalBody should now contain the content from the mailBody variable.
If you can have CF markup in the templates you should be able to get the results you want with this:
<cfsavecontent variable="mailBody">
<cfinclude template="#application.paths.physicalroot#\email\project1\templates\people.htm">
</cfsavecontent>

Grails Update a List in GSP (View) and then submit with a button

Imagine you have a table displaying a list of books (like the index does) and you want to make changes in a column called "Sold" (a checkbox for example). So once you finish "Checking" the books you have sold, you click a Button to save! How do you send back that list to the controller and update it?
So, the code is something like this, in the controller:
def aMethod(){
...
[bookInstanceList: myBookList]
}
In the GSP:
<g:each in="${bookInstanceList}" status="i" var="bookInstance">
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td><g:link action="show" id="${bookInstance.id}">${fieldValue(bean: bookInstance, field: "author")}</g:link></td>
<td><g:checkBox name="sold" value="${bookInstance?.sold}" /></td>
<td>
</tr>
</g:each>
The idea is with the checkbox let the user change the "Sold" value from that book, and then make a submit with a Button. How can I save my new bookInstanceList?
Thank you very much
There is a simple sample app at https://github.com/jeffbrown/books which shows one way you could do this. Run the app, open the default index page, click on the link and that will take you to a page where you can click checkboxes and update the library of books.
Files of interest are https://github.com/jeffbrown/books/blob/master/grails-app/controllers/com/demo/BookController.groovy and https://github.com/jeffbrown/books/blob/master/grails-app/views/book/index.gsp.
I hope that helps.
I've removed some of the markup for brevity and to bring focus to the important bits. This is one way of doing it without relying on Javascript and what do you know, it is pure grails. Never say never, #rmlan.
<g:form action="updateSold" controller="book">
<table>
<tbody>
<g:each in="${bookInstanceList}" status="i" var="bookInstance">
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<td><g:link action="show" id="${bookInstance.id}">${fieldValue(bean: bookInstance, field: "title")}</g:link></td>
<td>
<g:checkBox name="sold" value="${bookInstance.sold}" />
<g:hiddenField name="id" value="${bookInstance.id}" />
</td>
</tr>
</g:each>
</tbody>
</table>
<g:submitButton name="updateSold" value="Update" />
</g:form>
This is the controller action:
def updateSold() {
def solds = params.list('sold')
def ids = params.list('id')
ids.eachWithIndex { id, idx ->
if (solds[idx]) {
// the book's sold has been checked, so update it to TRUE
} else {
// the books sold has not been checked, so update it to FALSE
}
}
}

CFdump and Bootstrap tooltips fight each other

I attach Bootstrap tooltips via
$("[title]").tooltip({ html: true });
When I use a <cfdump>, title tags are attached all over the place. The start of the <cfdump> html looks like this
<table class="cfdump_struct">
<tr><th class="struct" colspan="2" onClick="cfdump_toggleTable(this);" style="cursor:pointer;" title="click to collapse">struct</th></tr>
<tr>
<td class="struct" onClick="cfdump_toggleRow(this);" style="cursor:pointer;" title="click to collapse">Cause</td>
<td>
Is there a way to keep, the two from stepping on eachother?
You shouldn't care because cfdump shouldn't be used in production, however you could just reduce the array returned by the jQuery selector. Not sure if this is the best way to do it, but it works:
$("[title]").filter(function(){
return ($(this).closest(".cfdump_struct").length == 0);
}).tooltip({ html: true });
It runs the filter function for each item in the array returned by the selector. If it is within the CFDUMP table (signified by the .cfdump_struct class) it will not return it. You will have to extend this to other cfdump types (queries, etc) but this should get you started.
Again, it really shouldn't matter since you shouldn't be using cfdump in production code anyway.
You can see this in action here: http://jsfiddle.net/seancoyne/rc7TL/

if else statement in AngularJS templates

I want to do a condition in an AngularJS template. I fetch a video list from the Youtube API. Some of the videos are in 16:9 ratio and some are in 4:3 ratio.
I want to make a condition like this:
if video.yt$aspectRatio equals widescreen then
element's attr height="270px"
else
element's attr height="360px"
I'm iterating the videos using ng-repeat. Have no idea what should I do for this condition:
Add a function in the scope?
Do it in template?
Angularjs (versions below 1.1.5) does not provide the if/else functionality . Following are a few options to consider for what you want to achieve:
(Jump to the update below (#5) if you are using version 1.1.5 or greater)
1. Ternary operator:
As suggested by #Kirk in the comments, the cleanest way of doing this would be to use a ternary operator as follows:
<span>{{isLarge ? 'video.large' : 'video.small'}}</span>
2. ng-switch directive:
can be used something like the following.
<div ng-switch on="video">
<div ng-switch-when="video.large">
<!-- code to render a large video block-->
</div>
<div ng-switch-default>
<!-- code to render the regular video block -->
</div>
</div>
3. ng-hide / ng-show directives
Alternatively, you might also use ng-show/ng-hide but using this will actually render both a large video and a small video element and then hide the one that meets the ng-hide condition and shows the one that meets ng-show condition. So on each page you'll actually be rendering two different elements.
4. Another option to consider is ng-class directive.
This can be used as follows.
<div ng-class="{large-video: video.large}">
<!-- video block goes here -->
</div>
The above basically will add a large-video css class to the div element if video.large is truthy.
UPDATE: Angular 1.1.5 introduced the ngIf directive
5. ng-if directive:
In the versions above 1.1.5 you can use the ng-if directive. This would remove the element if the expression provided returns false and re-inserts the element in the DOM if the expression returns true. Can be used as follows.
<div ng-if="video == video.large">
<!-- code to render a large video block-->
</div>
<div ng-if="video != video.large">
<!-- code to render the regular video block -->
</div>
In the latest version of Angular (as of 1.1.5), they have included a conditional directive called ngIf. It is different from ngShow and ngHide in that the elements aren't hidden, but not included in the DOM at all. They are very useful for components which are costly to create but aren't used:
<div ng-if="video == video.large">
<!-- code to render a large video block-->
</div>
<div ng-if="video != video.large">
<!-- code to render the regular video block -->
</div>
Ternary is the most clear way of doing this.
<div>{{ConditionVar ? 'varIsTrue' : 'varIsFalse'}}</div>
Angular itself doesn't provide if/else functionality, but you can get it by including this module:
https://github.com/zachsnow/ng-elif
In its own words, it's just "a simple collection of control flow directives: ng-if, ng-else-if, and ng-else." It's easy and intuitive to use.
Example:
<div ng-if="someCondition">
...
</div>
<div ng-else-if="someOtherCondition">
...
</div>
<div ng-else>
...
</div>
You could use your video.yt$aspectRatio property directly by passing it through a filter, and binding the result to the height attribute in your template.
Your filter would look something like:
app.filter('videoHeight', function () {
return function (input) {
if (input === 'widescreen') {
return '270px';
} else {
return '360px';
}
};
});
And the template would be:
<video height={{video.yt$aspectRatio | videoHeight}}></video>
In this case you want to "calculate" a pixel value depending of an object property.
I would define a function in the controller that calculates the pixel values.
In the controller:
$scope.GetHeight = function(aspect) {
if(bla bla bla) return 270;
return 360;
}
Then in your template you just write:
element height="{{ GetHeight(aspect) }}px "
I agree that a ternary is extremely clean. Seems that it is very situational though as somethings I need to display div or p or table , so with a table I don't prefer a ternary for obvious reasons. Making a call to a function is typically ideal or in my case I did this:
<div ng-controller="TopNavCtrl">
<div ng-if="info.host ==='servername'">
<table class="table">
<tr ng-repeat="(group, status) in user.groups">
<th style="width: 250px">{{ group }}</th>
<td><input type="checkbox" ng-model="user.groups[group]" /></td>
</tr>
</table>
</div>
<div ng-if="info.host ==='otherservername'">
<table class="table">
<tr ng-repeat="(group, status) in user.groups">
<th style="width: 250px">{{ group }}</th>
<td><input type="checkbox" ng-model="user.groups[group]" /></td>
</tr>
</table>
</div>
</div>
<div ng-if="modeldate==''"><span ng-message="required" class="change">Date is required</span> </div>
you can use the ng-if directive as above.
A possibility for Angular:
I had to include an if - statement in the html part, I had to check if all variables of an URL that I produce are defined. I did it the following way and it seems to be a flexible approach. I hope it will be helpful for somebody.
The html part in the template:
<div *ngFor="let p of poemsInGrid; let i = index" >
<a [routerLink]="produceFassungsLink(p[0],p[3])" routerLinkActive="active">
</div>
And the typescript part:
produceFassungsLink(titel: string, iri: string) {
if(titel !== undefined && iri !== undefined) {
return titel.split('/')[0] + '---' + iri.split('raeber/')[1];
} else {
return 'Linkinformation has not arrived yet';
}
}
Thanks and best regards,
Jan
ng If else statement
ng-if="receiptData.cart == undefined ? close(): '' ;"

Fetch a list item to a MultiLine textBox

I have a question regarding how to fetch a value from list item to a MultiLine textBox.
I have tried alot. First time it gave the correct data.
and still it gives the correct data however it also fetches the div tags along with the data.
Any thoughts if any please help.
Here is my code:
Register.aspx
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Prerequisite"></asp:Label>
</td>
<td>
<asp:TextBox ID="TxtPrerequisite1" runat="server" TextMode="MultiLine" ReadOnly="true"></asp:TextBox>
</td>
</tr>
Register.aspx.cs
string oPrerequisite = null;
SPSite oSPSiteCollection = SPContext.Current.Site;
SPWeb oSPWeb = SPContext.Current.Web;
SPList oSPList1 = oSPWeb.Lists["Scheduled Courses"];
SPListItemCollection oItemCollectionCourse = oSPList1.Items;
foreach (SPListItem ospListItemCourse in oItemCollectionCourse)
{
oPrerequisite = ospListItemCourse["Prerequisite"].ToString();
TxtPrerequisite1.Text = oPrerequisite;
}
The actual out put i am getting is :
<div class="ExternalClassEAA502F55D7B4F9BBA347E2137621D8A"><p> Correct Value is here >div </p></div>
Where as the expected output is:
Correct Value is here
How can I remove the tag from the correct answer so I have only value.
Try SPHttpUtility.ConvertSimpleHtmlToText
TxtPrerequisite1.Text =
SPHttpUtility.ConvertSimpleHtmlToText(oPrerequisite, oPrerequisite.Length);