how to convert the this jsp code to thymeleaf - thymeleaf

can any body help me I want to change this code to thymeleaf ?

You shouldn't need ${contextRoot} anymore.
<a th:href="#{/show/category/{id}(id=${category.id})}"></a>

Sometimes it is a good practise to use a variable that stores the root-location. Think of a service that runs e.g. on localhost port 8080 BUT is accessible from the web over nginx behind the URL me.com/myService/ (port 80). In this use case # or contextRoot produces dead-links for end users since Thymeleaf doesn't know anything about that. My solution is to store e.g. "me.com/myService/" in the application properties and add this attribute by default to the model and build links like:
<a th:href="|${myRoot}/show/category/${category.id}|"></a>
If you don't need to handle things like that go with Metroids' answer, it's a good answer.

Related

How can I replace a search ?athing=something with /athing/something?

On scratch.mit.edu, they use scratch.mit.edu/projects/projectID to display dynamic pages. I am working on a Scratch redesign and am wondering how to do this without doing something like scratchredesign.com/projects?id=382. And if you don't know how to not use ?=, how would I use it?
Basically, how can I make a website when if you go to scratchredesign.com/projects/352 it will show an embed of a Scratch project with the ID of 352, and this will work for any ID like scratchredesign.com/projects/4019271 or scratchredesign.com/projects/53234.
(I know you use avascript, I don't know if PHP though.)
You can use .htaccess mod_rewrite if you are running on apache or Create NGINX Rewrite Rules if on Nginx
Basically, if you are accessing the site's URLs like scratchredesign.com/projects/352, then you can try setting the iframe source according to window.location.pathname which would return "/projects/352" as a string for you to use. You can then easily set the src attribute for the iframe dynamically with a script at the bottom of the body.
The iframe:
<iframe name="site" id="site" height="900" width="750"></iframe>
The script at the end of the body, say loadIframe.js:
document.getElementById("site").src = "http://scratch.mit.edu" + window.location.pathname;

Using "ddclient" with a custom URL (php-Script on my Server)

Is it possible to use ddclient on a raspberry pi for updating a custom host?
I use a own PowerDNS-Server that is being updated by a URL:
https://domain.tld/index.php?domain=<domain>&ipaddr=<ipaddr>&passwd=<pass>&ip6addr=<ip6addr>
When I try to configure ddclient I'm not quite able to implement this unique URL. I am only able to set the basic parameters:
protocol=dyndns2
usev6=if, if=eth0
if-skip=Scope:Link
ssl=yes
server=server.tld
login=username
password=topsecret
domain.tld
Obviously, this is not working with my URL.
Might it work if I change my variables in my URL to a ddclient compliant? From domain to host, e.g.?
What other ideas are there to make that work? I just need that link to being accessed by ddclient.
Thanks!
you can use script option in ddclient.conf file specifying the script (the part between the server and domain=<domain>&ipaddr=<ipaddr>&passwd=<pass>&ip6addr=<ip6addr>)
script=/index.php
Hope this helps

With the Orbeon Proxy Portlet is there a way to enable form selection via Inter Portlet Communication?

The Orbeon Proxy Portlet allows form selection via URL parameters. It would be preferable if the parameters were not included in the URL. I thought I might be able to use a public render parameter as described in the Liferay documentation but it looks like the proxy portlet isn't configured that way.
Looking at OrbeonProxyPortlet.scala I see this method is used to retrieve the URL parameters:
private def portalQuery(request: PortletRequest) =
collectByErasedType[String](request.getAttribute("javax.servlet.forward.query_string")) map decodeSimpleQuery getOrElse Nil
Could this method be modified to combine that map with the map returned by PorletRenderRequest.getParameterMap() or PorletRenderRequest.getPublicParameterMap()?
Or perhaps there could be another init-param like enable-url-parameters, for example, enable-inter-portlet-parameters?
This would also require the following configuration in the portlet.xml:
<supported-public-render-parameter>orbeon-app</supported-public-render-parameter>
<supported-public-render-parameter>orbeon-form</supported-public-render-parameter>
<supported-public-render-parameter>orbeon-document</supported-public-render-parameter>
<supported-public-render-parameter>orbeon-page</supported-public-render-parameter>
As you noticed, currently this is not implemented, and I don't think there is a way without modifying the code of OrbeonProxyPortlet.scala. But yes, it would make sense to make this work, and in fact the option was considered in issue #1850.

Create external link in Asp.Net MVC3

I know there are a lot of utility and helper classes/methods for generating URLs and links from internal routes and controllers. But how would you tackle the below in MVC 3?
In a razor file someone has defined this:
Website
ExternalURL in this instance will hold values like www.yoursite.com, without any prefixes. Hard-coding an http:// at the start is an obvious no-no but how best to handle this?
It's not so bad to hardcode http:// in your case, but if you want to avoid it, I see few options, but maybe most correct will be to extend your model with property #Model.Details.ExternalUrlLink or something like that. In getter you can do any logic what you want over original value, e.g. concatenate http:// prefix if it's not presented

Rails Absolute URL for public directory

What is the method I need to call to find the root URL for a rails application. For example, I have a site where the address is "https://host:1234/foo/app-main".
What method should I be using to get "https://host:1234/foo/images" to get the absolute url for images in the public url?
image_path(image_name)
Edit: Steve has a good point, this will only get you part of the way there. To get the rest you must be inside of a request (you probably are)
In that case though, you can combine the above with Justice's approach,
"#{request.scheme}://#{request.host_with_port}/#{request.script_name}#{image_path(image_name)}"
This question makes sense only on a per-request basis, since your one process might easily be listening on multiple domain names and on multiple schemes.
"#{request.scheme}://#{request.host_with_port}#{request.script_name}"
See Rack::Request.

Resources