How to add URL fragment HtmlOutcomeTargetLink? - jsf-2

I would like to add an URL fragment #top to a HtmlOutcomeTargetLink, but cant figure out how. For an HtmlOutputLink I just use the following:
HtmlOutputLink link = new HtmlOutputLink();
String urlWithFragment = url + "#top";
link.setValue(urlWithFragment);
How to acomplish this for a HtmlOutcomeTargetLink?
Unfortunately the following does not work:
HtmlOutcomeTargetLink link = new HtmlOutcomeTargetLink();
String urlWithFragment = context.getViewRoot().getViewId() + "#top";
link.setOutcome(urlWithFragment);
Thanks for your help!

The outcome of HtmlOutcomeTargetLink (the <h:link>) only takes navigation case outcomes, not URLs. The navigation case outcomes do not support URL fragments. Those needs to be set as a separate fragment attribute.
link.setFragment("top");
See also:
<h:link> tag documentation
Update: wait, there's no setter for that on the UIOutcomeTarget parent class. I suspect an oversight in the generated code (funnily it's mentioned here in Mojarra snapshot docs and here in a MyFaces testcase). You should be able to set it directly on the attribute map:
link.getAttributes().put("fragment", "top");

Related

Umbraco - Trim last five characters in current page url

Im getting the url of the current page using #CurrentPage.Url
It returns http://hostname/abcdefgh/
I wanted to trim out the last 5 characters of the URL
Req. URL http://hostname/abcd as the last five characters 'efgh/' is removed.
I tried using #umbraco.library.TruncateString(testString,-5,"") property to trim, but was unsuccessful.
Im new to umbraco. Any help would be highly appreciated.
I'd be interested to know the reason for doing this. Using the Remove method worked for me:
#{
string url = CurrentPage.Url;
url = url.Remove(url.Length - 5);
}

Prestashop all translatable-field display none for product page

Just new in Prestashop (1.6.0.6), I've a problem with my product page in admin. All translatable-field are to display:none (I inspect the code with chrome).
So when I want to create a new product I can't because the name field is required.
I thought that it was simple to find the .js whose do that but it isn't.
If somebody could help me, I would be happy.
Thank you for your help
Hi,
I make some searches and see that the function hideOtherLanguage(id) hide and show translatable-field element.
function hideOtherLanguage(id)
{
console.log(id_language);
$('.translatable-field').hide();
$('.lang-' + id).show();
var id_old_language = id_language;
id_language = id;
if (id_old_language != id)
changeEmployeeLanguage();
updateCurrentText();
}
When I set the Id to 1 (default language), it works. It seems that when I load the page, the function is called twice and the last calling, the id value is undefined. So the show() function will not work.
If somebody could help me. Thank you.
In my console, I see only one error
undefined is not a function.
under index.php / Line 1002
...
$("#product_form").validate({
...
But I find the form.tpl template and set this lines in comment but nothing change.
EDIT: According to comment on this link http://forge.prestashop.com/browse/PSCFV-2928 this can possibly be caused by corrupted installation file(s) - so when on clean install - try to re-download and reinstall...
...otherwise:
I got into a similar problem - in module admin page, when creating configuration form using PrestaShop's HelperForm. I will provide most probable cases and their possible solutions.
The solution for HelperForm was tested on PS 1.6.0.14
Generally there are 2 cases when this will happen.
First, you have to check what html you recieve.
=> Display source code - NOT in developer tools/firebug/etc...!
=> I really mean the pure recieved (JavaScript untouched) html.
Check if your translatable-fields have already the inline style "display: none":
Case 1 - fields already have inline style(s) for "display: none"
This means the template/html was already prepared this way - most probably in some TPL file I saw codes similar to these:
<div class="translatable-field lang-{$language.id_lang}"
{if $language.id_lang != $id_lang_default}style="display:none"{/if}>
Or particularly in HelperForm template:
<div class="translatable-field lang-{$language.id_lang}"
{if $language.id_lang != $defaultFormLanguage}style="display:none"{/if}>
Case 1 is the most easy to solve, you just have to find, where to set this default language.
Solutions
HelperForm
Look where you've (or someone else) prepared the HelperForm object - something like:
$formHelper = new HelperForm();
...
Somewhere there will be something like $formHelper->default_form_language = ...;
My wrong first solution was to get default form language from context - which might not be set:
$this->context->controller->default_form_language; //THIS IS WRONG!
The correct way is to get the default language from configuration - something like:
$default_lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$formHelper->default_form_language = $default_lang->id;
...this particularly solved my problem...
Other form-creations
If there is something else than HelperForm used for form creations, the problem is still very similar.
You have to find where in files(probably tpls) is a condition for printing display:none for your case - then find where is the check-against-variable set and set it correctly yourself.
Case 2 - fields don't have inline style(s) for "display: none"
This means it is done after loading HTML by JavaScript. There are two options:
There is a call for hideOtherLanguage(), but there is wrongly set input language - that means no language will be displayed and all hidden.Solution for this one can be often solved by solving Case 1 (see above). In addition there can be programming error in not setting the after-used language id variable at all... then you would have to set it yourself (assign in JavaScript).
Some script calls some sort of .hide() on .translatable-field - you will have to search for it the hard way and remove/comment it out.
PS: Of course you can set the language to whatever you want, it is just common to set it to default language, because it is the most easier and the most clear way how to set it.

MvcSiteMapProvider issue when set route values for node with securityTrimmingEnabled is true

I have project with win auth and i use "securityTrimmingEnabled" option for detect to which parts of menu user have access.
I set site map node properties:
siteMapNode.ParentNode.Title = entity.Parent.Title;
siteMapNode.ParentNode.RouteValues["id"] = entity.Parent.Id;
And if "securityTrimmingEnabled" is false, everything is ok and i have correct url in map path(/portfolios/facility/57), if "securityTrimmingEnabled" is true, title of node is ok, but "id" param is not correct(/portfolios/facility/0)
How i can resolve this issue?
This is basically the same issue described here.
The AuthorizeAttributeAclModule is accessing the Url property and causing it to be request cached, so setting properties that affect the URL afterward (such as in a controller action) has no effect.
Option 1
Move the code that sets the RouteValues["id"] into a IDynamicNodeProvider implemenation. This will load the values into the shared cache at application startup (and when the cache expires), but it also loads them before the AuthorizeAttributeAclModule fires.
Option 2
Move the code that sets the values into the Application_BeginRequest event as described here.
Option 3
Create a custom implementation of RequestCacheableSiteMapNode that doesn't override the Url property and a custom SiteMapNodeFactory to provide instances of your new class, then inject them both with DI.
Option 4
Remove the request cache value for the Url property manually, so it can be regenerated the next time the Url property is accessed.
var parentNode = siteMapNode.ParentNode;
parentNode.Title = entity.Parent.Title;
parentNode.RouteValues["id"] = entity.Parent.Id;
var urlRequestCacheKey = "__MVCSITEMAPNODE_" + parentNode.SiteMap.CacheKey + "_" + parentNode.Key + "_Url_True_";
this.HttpContext.Items.Remove(urlRequestCacheKey);

OpenLayers print map

How can I print a map from the OpenLayers? I want to add print button in my OpenLayers page =) I have MapFish extension for my geoserver, but don`t know how to make request to it. Any other ideas are welcome) Help please.
I had a similar problem using a reverse proxy, because I discovered the answer from info.json contais local ip reference instead of the public url
to solve brutally i replaced the ip referenze with the public url in the ajax request (see the following code. I hope it can be usefull for others...
this.capabilities.createURL = this.capabilities.createURL.replaceAll("192.168.0.0:8080", "mypublicurl");
this.capabilities.printURL= this.capabilities.printURL.replaceAll("192.168.0.0:8080", "mypublicurl");
Ext.Ajax.request({
url:this.capabilities.createURL,
jsonData:jsonData,
success:function(response){
response.responseText = response.responseText.replaceAll("192.168.0.0:8080", "mypublicurl");
window.open(Ext.decode(response.responseText).getURL);
}
});
The simplest way is to use GeoExt.PrintMapPanel (geoext example). And be sure to read GeoServer Printing Module.
UPD GET request example. You must modify url, "baseURL", "layers". If you specify an existing layer, this request must return pdf file.
http://demo.opengeo.org/geoserver/pdf/print.pdf?spec={"units":"degrees","srs":"EPSG:4326","layout":"A4","dpi":75,"mapTitle":"Printing Demo","comment":"This is a simple map printed from GeoExt.","layers":[{"baseURL":"http://demo.opengeo.org/geoserver/wms","opacity":1,"singleTile":true,"type":"WMS","layers":["topp:tasmania_state_boundaries"],"format":"image/jpeg","styles":[""]}],"pages":[{"center":[146.56000000001,-41.56],"scale":8192000,"rotation":0}]}

Call javascript in sharepoint custom field

I am creating a custom field in SharePoint 2007. I have seen other solutions where the current site URL was default value of a text field.
How can I get this current site URL?
I have got one answer whiches states that I shall use JavaScript, but where do I put the script?
I hope you can help.
BR
To answer 1
I am new to SharePoint and am not quiet sure where to put the java script. Normaly i just give the initial value to the field in the FieldEditor.cs file but how can I do this with the javascript?
Here follows a picute of my files.
I have tried to put it into FiledEditor.cs but this results in the value of myString is written in the top of the web page.
Here is my current code:
string myScript = "var currentUrl = document.URL; LabelLookupFieldTargetURLText.Text = currentUrl;";
Page.ClientScript.RegisterClientScriptBlock(LabelLookupFieldTargetURLText.GetType(), "LabelLookupFieldTargetURLTextJavaScript", myScript);
I found the answer my self. I don't need to use a java script. I can just use SPContext.Current.Site.Url
use javascript:
var nowUrl = document.URL;
yourTextfiled.value = nowUrl;
you can read this:http://www.w3schools.com/jsref/dom_obj_document.asp

Resources