Using Apex:Variable with $CurrentPage.parameters in Visualforce - salesforce

I have a very simple piece of code that I'm trying.
<apex:variable var="startUrl" value="{!$CurrentPage.parameters.startURL}" />
{!startUrl}
The above code generates an Unknown property 'startUrl' when trying to compile.
<apex:variable var="startUrl" value="{!$CurrentPage.Name}" />
{!startUrl}
Above code works just fine and the below code works fine.
{!$CurrentPage.parameters.startURL}
Also the first set of code above that fails, will compile fine if I remove the "{!startUrl} line.
I'm not sure why it is failing.

Related

Checkbox ajax event not triggerd

I have the following code that is not working.
<p:selectManyCheckbox id="make" value="#{priceList.searchMakeId}" >
<p:ajax event="click" process="#form" update="recordCountPanel" immediate="true" listener="#{priceList.reCountRecords}" />
<f:selectItems value="#{priceList.vehicleMakeItems}" />
</p:selectManyCheckbox>
Bean method
public void reCountRecords() throws MWSException {
The method is never called. When I replace the p:selectManyCheckbox with h:electManyCheckbox or with p:selectManyMenu Then when clicking/changing these components, the bean method is called.
I can't find in the generated shtml source any onlclick or onchange event on the primefaces checkbox.
So I'm guessing something is not rendered correctly when I use p:selectManyCheckbox
But since I don't have any errors on my server or in browsr javascript I'm clueless of what is causing the problem.
I tried with primefaces 6.0 6.1.6 and 6.1.8 . All the same result.
Any ideas?
I found out one of my collegues wrote a custom rendere for the selectManyCheckbox. But did it for PF 3 (some issues with responsive designs) And it was never updated and since I updated to PF6 it caused problems. Removing the custom rendere fixed the issue I had and also fixed the problem with the responsive design.

Decompile angular elements

We have a angular grid written by some guys here at work, the entire company uses it.
A td-cell could look like this
<td typeahead-cell="location as location.Name for location in getApiLocations($viewValue, mapping)" ng-model="mapping.selectedLocation">
{{mapping.getLocationNames()}}
</td>
The typeahead-cell directive will execute some custom code on the td, what it does is hookup some code so that if you double click or write in the cell it will go from display only to (in this case) typeahead. It does this by taking the html in the td cell (The td cell is already compiled by angular), wrap it with some custom code that does above functioanlly and then call $compile on the entire thing. This works with expressions above like {{mapping.getLocationNames()}} because they do not change when compiling so it can be compiled any number of times.
The problem I face now is that I try to use a more complex expression with ng-repeat. Problem is the first compile (Done directly by angular-core) will change html from example
from
<span ng-repeat="location in mapping.locations">...</span>
to
<!-- ngRepeat: location in mapping.locations -->
Then when our custom grid code executs it will try to compile the code above which will result in an empty since it compiles against a html comment.
This is the code that breaks
$element.html($compile(displayElement.html($element.html()))($scope));
$element is the td-cell that contains my orignal code that, when doing $element.html() it will take compiled code and try to use that. Wont work. Displayelement is a wrapper that will show when we are in displaymode.
I either need to decompile $elementbefor edoing $element.html or somehow move the content of the $element (td cell) compiled and hooked up.
Any ideas?
edit: I have somewhat solved it, doing this
$element.children().appendTo(displayElement);
displayElement.appendTo($element);
This will take the children from the td-cell and add them to the displayElement without actually breaking the original $compile. jQuery.children cant move <!-- comment --> elements so if you have an expression with ng directives like my repater above you need to wrap it in a dummy element like
<span><span ng-repeat="location in mapping.locations">...</span></span>
Any workaround for this?
Instated of that line if you can check with this
//Store it first on a variable if blank
var html;
if(!html) html = displayElement.html($element.html());
$element.html($compile(html)($scope));
Hopefully it will work. May be you need to manage the scope of the variable.
Final solution is this
$element.contents().appendTo(displayElement);
displayElement.appendTo($element);
It's very important to use contents and not children because childrenwill ignore text nodes which will not include the comments generated by ng-repeat directive.

Odd issue with ng-show always evaluating to true

I had a bit of code in my view that would only show up when a particular value was true. Lt looked like this:
button type="button" ng-click="attachBarCode('enter')" ng-show="barcodeAllowed.status">Foo</button>
This was working until recently. My controller had some logic where, based on Ajax data, it would set $scope.barcodeAllowed.status to true. All of a sudden though, the button was always showing up. To help debug the issue, I added some additional tests to my view:
first test, <span ng-show="!barcodeAllowed.status">DONT SHOW</span><br/>
second test, <span ng-show="barcodeAllowed.status">DONT SHOW</span><br/>
test -{{barcodeAllowed.status}}-end -{{!barcodeAllowed.status}}- -{{barcodeAllowed | json}}-<br/>
test if <span ng-if="barcodeAllowed.status"> if was true</span><p>
Here is where things got crazy. Both "DONT SHOWS" rendered in my view, even though it seems as if that would be impossible. When I output the values in the third line, I saw false and true, as I expected.
Finally - the ng-if? It worked perfectly! The value did not show up.
I've heard folks mention that ngShow can have scope issues inside a ngif, but my code isn't inside an ngif.
So, you won't believe what it was. I was using a Content Security policy in my app and on a whim, I disabled it. As soon as I did, it began working. I played around a bit and discovered that I needed to add 'unsafe-eval' to the to the script-src area of my CSP in order for Angular to be able to apply the styles.
The Ng-show/Ng-hide directives needs a css-class to show/hide, since it just adds a class to your element when the scope-variable is truthy/falsy.
Ref: https://docs.angularjs.org/api/ng/directive/ngShow

angucomplete-alt unable to type in textbox

Simple problem here - but cant seem to find answer. I have added the angucomplete-alt to my project - I believe that I have added it all correctly - meaning, registering it and having the js file available when the page loads. But for some reason when I click on the input and start to type - nothing happens. I am unable to type in the textbox/input. below is my code for the control. - im double checking how things are wired up on the back end. - thanks in advance.
and this exact code works in another project - configured differently - but the markup for the control is the same
<angucomplete-alt id="searchGroupsAutoComplete"
placeholder="{{searchPlaceholder}}"
pause="400"
text-searching="{{searchingText}}"
selected-object="selectedAnObjectFn"
remote-url="/api/search/SearchByQueryStrings"
remote-url-request-formatter="formatSearchDataFn"
remote-url-response-formatter="formatReturnDataFn"
remote-url-data-field="Content"
title-field="Name"
description-field="EntityType"
image-field="ThumbnailUrl"
minlength="1" />
Remove maxlength="{{maxlength}}" of INPUT tag in $templateCache.put(TEMPLATE_URL,..... (angucomplete-alt.js)
so it worked, but I don't known why.

JSTL on AppEngine - tags not working

I want to use JSTL in my AppEngine JSP to render data. I have completed the Guestbook demo, which works fine for me, including the JSTL calls like this one (from the linked example):
<blockquote>${fn:escapeXml(greeting_content)}</blockquote>
However, I then tried to use JSTL through tags, e.g. this:
<fn:out value="greeting_content" />
or just
<fn:out value="" />
I get a 500 error and an exception stack trace saying:
org.apache.jasper.JasperException: /guestbook.jsp(80,4) No tag "out" defined in tag library imported with prefix "fn"
The JSTL library is imported at the top of the file as in the example, i.e.
<%# taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
And as expected, if I remove that line the ${fn:something} calls stop working.
Does anyone have an idea why that is? JSTL is supposed to work that way, isn't it? I feel like I'm missing something fundamental here, but I just can't find what it is.
You should use <c:out value=""/> for output.

Resources