On my HTML-page I have a link for saving recipe, example
addrecipe?id=607691&name=Soft-Bread-Salami-Rolls
It looks like the correct URL when I hold the mouse over the link,
but the browser(?) converts it to something like this
addrecipe?id=607691%26name%3DSoft-Bread-Salami-Rolls
I managed to put atleast id= in the html but I get error when trying to add name= also.
<a th:href="#{'/addrecipe'(id=${recipesinfo.link})}" th:text=Save></a>
Looking at the docs and assuming recipesinfo.link contains your 607691 ID (and nothing else), I think you should be using
<a th:href="#{/addrecipe(id=${recipesinfo.link},name='Soft-Bread-Salami-Rolls')}">Save</a>
If the name value comes from a variable (eg recipesinfo.name), then you would use name=${recipesinfo.name} instead of the string literal.
Related
I have a problem with tapestry5 t:Form component. I'd like to add my own html tag but do not how. I would like to have something like:
<t:form clientValidationEnabled="false" class="formclass" myTag="${tagValue}">
and render form should looks like:
<form clientvalidationenabled="false" class="formclass" myTag="value">
I tried to add theattribute with t prefix but does not help. I know it'd be parse as component property (#Parameter) but I don't know how to pass it through.
Is there any way how pass the attribute to the generated html element? (without js)
Thanks for any advice.
Ok, I answer my question. The solution with prefix works fine. So it should looks like:
<t:form clientValidationEnabled="false" class="formclass" t:myTag="${tagValue}">
My fault was the value of getTagValue() cause it was not set because inner component #SetupRender wasn't finished. So the value was empty and empty html tag is not rendered.
What is the difference between specifying the plid in the opening tag when creating a portlet url
<liferay-portlet:renderURL var="myurl" windowState="normal" plid="123456">
<liferay-portlet:param name="struts.portlet.action" value='/view/myAction' />
</liferay-portlet:renderURL>
and passing it as a param
<liferay-portlet:renderURL var="myurl" windowState="normal">
<liferay-portlet:param name="struts.portlet.action" value='/view/myAction' />
<liferay-portlet:param name="plid" value='123456' />
</liferay-portlet:renderURL>
I get different error messages when the plid doesn't exist so I was wandering what the difference was
Q: What is the difference between specifying the plid in the opening tag when creating a portlet url and passing it as a param
The main difference is:
for tag-attribute-plid it would check for the plid and change your URL accordingly for that layout (page).
and for request-param-plid it would simply append it to your URL (as a query-string) with proper namespace like other request params. Nothing special.
Now an example
If tag-attribute-plid is used as follows inside your my-portlet:
<liferay-portlet:renderURL var="myurl" windowState="normal" plid="123456">
<liferay-portlet:param name="struts.portlet.action" value='/view/myAction' />
</liferay-portlet:renderURL>
When you want to construct a URL on a page-x to go to another page-y. Suppose you are on page: Home and you want to go to the Help page or to Control Panel, then in the plid attribute you would pass pild of Help page or plid of the Control Panel.
So if I pass the plid of Control Panel then the final URL would look something like:
http://mylocalhost.com/group/control_panel/manage?p_p_auth=1g0RGj4L&p_p_id=my_WAR_myportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&_my_WAR_myportlet_struts.portlet.action=%2Fview%2FmyAction
The above is not achievable by passing the plid as a request param.
Q: I get different error messages when the plid doesn't exist so I was wandering what the difference was
Now you know what the difference is, so it might be easy to answer this.
If the tag-attribute-plid is incorrect it would create a URL something like this:
http://mylocalhost.com/c/portal/layout?p_l_id=123456&p_p_auth .....
And if request-param-plid is incorrect it would create a URL for current page and append the plid, something like this:
http://mylocalhost.com/web/guest/home?p_p_id=my_WAR_myportlet&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&_my_WAR_myportlet_struts.portlet.action=%2Fview%2FmyAction&_my_WAR_myportlet_plid=123456
Hope this helps.
What is the difference between specifying the plid in the opening tag and appending as request parameter when creating a portlet URL?
plid as tag-attribute: There are two certainties, if any layout (page)
for given plid is found on portal, then it will create URL specific to
that page, otherwise plid will be appended as a queryString parameter.
plid as request-parameter: In either case (correct / incorrect plid),
plid will be appended as a queryString parameter with current layout
URL with proper namespace of the portlet, which can be extracted from
request object.
I get different error messages when the plid doesn't exist.
Yes, certainly you will get, if there is no any layout / page found in your portal with the
given plid.
so I was wandering what the difference was.
The only difference can be the search for layout in case-1 before
appending it to the URL on creation of renderURL by tag. While in case-2, plid is simply passed a
request object that will be accessible in your portlet action.
So I have my JSTL tags like following
<a href="${urlHeader}hfv/${curRow.postTitle}">
</a>
If the curRow.postTitle is "TEST TEST" and when I click the link, the postTitle segment of the URL becomes "TEST%20TEST". What I want is "TEST_TEST" instead.
Does it have to be done before the data has been passed to the view or can you simply do it with an available JSTL or Spring tags?
Thanks.
There is a JSTL tag in "functions" called replace that you can use to do this. It works similarly to String.replace. As the example shows, you can do something like this:
${fn:replace(url, " ", "_")}
I have started using struts .I have hanged in a place ,Code is bellow
<st:submit src="getText('image.user.login')" type="image" height="21" width="44" </st:submit>
when i run this code , getText('image.user.login') message does return any value , But when i replace src="getText('image.user.login')" with value="getText('image.user.login')" than it returns value of "image.user.login" from property file.
What is reason for it , and how can i solve this issue ?
Thanks in advance
like this example illustrates in this reference submit reference struts
Render an image submit:
<s:submit type="image" value="%{'Submit'}" label="Submit the form" src="submit.gif"/>
src : Supply an image src for image type submit button. Will have no effect for types input and button.
AND
value : String Preset the value of input element.
this should answer your question if you use src you should assign a path and if you use value you can use a preset value
try this:
<st:submit key="image.user.login"/>
I have a page in my app with a dynamically-generated form, in which I need a number of <select> elements. Since I don't know in advance how many there will be, I need to put an ID number in the name attribute of each <select>. I'm trying to use the built-in #{select} tag (documentation here) like so:
#{ select 'select_' + ${IDnum}}
...options, etc...
#{/select}
When I do that I get a MissingMethodException:
No signature of method: Template_1009.$() is applicable for argument types:
(Template_1009$_run_closure1_closure2_closure3) values:
[Template_1009$_run_closure1_closure2_closure3#ad2388] Possible solutions:
_(java.lang.String), is(java.lang.Object), run(), run(), any(), get(java.lang.String).
When I instead do:
#{ select 'select_${IDnum}'}
the page renders correctly, but the select element renders like this in view-source:
<select name="select_${IDnum}" size="1" >
So, how do I get the value of ${IDnum} into the name attribute? I can do this with normal HTML <select> tags, but I'll need to write some Javascript to emulate Play's value:${x} functionality that I really don't want to bother with.
Thanks!
Try this :
#{select 'select_'+IDNum}