ICEFACES : Multiple Parameters in link - icefaces

I have a datatable with multiple rows, I want to put one link to redirect the values to one Servlet. The old call that I use is similar like this :
a onclick=openWindow('./Servlet?param1=xx&param2=xxx')
I'm newbie in ICEfaces... I need your help because I don't know how can I put one parameter only like this :
ice:outputLinktarget="mainFrame" value="./Servlet?param1=#{item.id}
but when I put two parameters, I got an errors in the code.
ice:outputLinktarget="mainFrame" value="./Servlet?param1=#{item.id}&param2=#{item.id}
Somebody knows how to do it?

The ampersand (&) is the culprit; you need to escape it or else IceFaces gets confused about the page structure.

Another way to do it:
<ice:outputLink target="mainFrame" value="./Servlet">
<f:param name="param1" value="#{item.id}"/>
<f:param name="param2" value="#{item.id}"/>
</ice:outputLink>
The f:param tags add the parameters to the base URL automatically.

You haven't said about what technology you use (jsp/jsf)?
For jsf try:
<ice:outputLinktarget="mainFrame" value="./Servlet>
<f:param name="param1" value="#{item.id}"/>
<ice:outputLinktarget=>

Related

Strip wicket tags, but keep wicket attributes

I'd like to strip special Wicket tags (e.g. wicket:panel, wicket:child, etc.) from the output in development mode, but keep the wicket:id attribute.
In the WebApplications init one can set getMarkupSettings().setStripWicketTags(true); thus removing the special tags and attributes.
Is it possible to extend / modify Wicket at some point to keep the attribute when stripSpecialTags is set to true?
This is not possible at the moment.
Please file a ticket for improvement at https://issues.apache.org/jira/browse/WICKET!
Thank you!
Why do you want to keep the wicket:id attribute? For testing/selenium? Then you can use the DebugSettings::setComponentPathAttributeName method to output the wicket component path, which is usable in selenium.

Set class or ID on <h:inputHidden> in JSF

I'm trying to set a class or id parameter on a <h:inputHidden> in JSF. The code looks like this:
<h:inputHidden value="#{getData.name}" class="targ" />
But in the browser, the class isn't set:
<input type="hidden" name="j_idt6" value="j_idt6">
I need to set a class to this parameter, because I have a JavaScript autocomplete function for a <h:inputText> that sets a value in the hidden input, which needs to be passed in the next page.
Any ideas? Thanks!
I know it's a little bit late, but it can help someone in the future.
As inputHidden shows nothing in the browser there's no sense to allow it to have a class.
You can use the Id but as the Id could change as you change the component parents using it would bring some headache.
I'd suggest as a workaround, you can give it a parent so you can manipulate it by javascript.
Exemple:
JSF
<h:panelGroup styleClass="someCssClass">
<h:inputHidden id="someId" value="someValue" />
</h:panelGroup>
Javascript (using jQuery, you could use pure javascript also)
$('.someCssClass input[type=hidden]').val('yourNewValue');
None of these answers here satisfied my needs (need the PrimeFaces component, need class not ID, wrapping is too much work), so here's what I came up with:
Use pass-through attributes: https://www.primefaces.org/jsf-2-2-pass-through-attributes
Use pass:hidden-class="blah" (in my case, it's xmlns:pass up top)
Use [attribute=value] selector:
https://www.w3schools.com/cssref/sel_attribute_value.asp
document.querySelector multiple data-attributes in one element
That basically boils down to using something like this (because h:inputHidden becomes a regular input): document.querySelector("input[hidden-class=" + blah + "]")
Please, see similar question - How can I know the id of a JSF component so I can use in Javascript
You can sed "id" property, but in final html code it can be not the same, but composite: for example, if your input with id="myhidden" is inside form with id="myform", final input will have id="myform:myhidden".
In the end, I used a standard HTML <input type="hidden"> tag, as I had no advantages for using the JSF one. If you're trying to set a value in a hidden input with JavaScript, I recommend using this workaround.

How to get the caller url in struts2?

I have a struts2 page which uses a shared action using <s:action> with executeResult="true" to add header contents to the page. However, there's some processing need to be done in the header action, which needs to retrieve the url of the actual page(aka the caller page). But if I use <s:url> within the header action's jsp, it only retrieve the url of the header action. So I would like to ask the experts here to enlighten me on how to achieve the result I want.
Thanks in advance.
I'm not sure I follow... so feel free to correct me if I'm not at all answering what you want.
But you should be able to use the <s:set> tag with the appropriate scope (probably request) before you call <s:action> to make the values you need available to the next action. See: http://struts.apache.org/2.2.1.1/docs/set.html
I would consider using the request object for this:
String referrer = request.getHeader("referer"); //referer spelling intentional
Do whatever you need with it via string manipulation.
So below is what I did to do it.
On the main page, use s:url and s:set to obtain the current url as well as parameters and save it in request scope
<s:set name="pageurl" scope="request">
<s:url includeParams="none" encode="true"/>
</s:set>
<s:set name="pageparams" scope="request" value="#parameters"/>
On the header page, you can retrieve them using below
<form action="<s:property value='#attr.pageurl'/>" >
<s:iterator value="#attr.pageparams" var="param">
<s:hidden name="%{#param.key}" value="%{#param.value}" id="_header_%{#param.key}"/>
</s:iterator>
</form>

Line breaks in Zend Navigation Menu labels

I have a need to create a <br/> tag in the display label for a menu item generated using Zend_navigation, but don't seem to be able to find a way to do so.
My navigation item is defined in the XML config as:
<registermachine>
<label>Register your Slitter Rewinder</label>
<controller>service</controller>
<action>register</action>
<route>default</route>
</registermachine>
I want to force a tag in the output HTML between 'your' and 'slitter', such that it appears on two line as below:
Register your
Slitter Rewinder
However, I can't seem to do it. obviously using in the XML breaks parsing, and using html entities means that the lable is displayed as:
Register your <br/>Slitter Rewinder
Has anyone had experience of this that can offer advice?
Thanks in advance!
there is no such option built-in you have to use a partial
$partial = array('menu.phtml', 'default');
$this->navigation()->menu()->setPartial($partial);
echo $this->navigation()->menu()->render();
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.navigation.menu
you may also try a hack with <label><![CDATA[Menu label<br/>Second line]]></label>
I found a (hacky) solution:
I updated my navigation.xml to use {br} tokens wherever a <br/> tag is required, and then amended the base Zend/View/Helper/Navigation/Menu.php file as follows:
within htmlify function, changed
$this->view->escape($label)
to
str_replace("{br}", "<br/>", $label)
I could (and probably will) override the Zend Library Menu View Helper with my own at some point, but this at least cover it for now.
there is a escapeLabels boolean used to convert html tags and it's true by default.
You can set your navigation like this
$this->navigation()
->menu()
->escapeLabels(false)
->...
http://framework.zend.com/apidoc/2.0/classes/Zend.View.Helper.Navigation.Menu.html#escapeLabels

zend form - Element Label in two line

I am extremely new to Zend Framework, In registration form, i need label text in two line. For Example:- In the case First name, I need to display like below:
First
Name:
How can i implement this? Please anyone help me!!!
By default, input fields labels are being escaped by Zend_View_Helper_FormLabel. However, you can easy switch this off:
$yourTextInputElement->getDecorator('label')->setOption('escape', false);
This way you can use labels as e.g. $yourTextInputElement->setLabel('First <br/> name');.
What about this nifty solution ?
http://jsfiddle.net/J67GD/
The best way is probably to use Description decorator, or subclass one of other standard ZF decorators.
Yanick's CSS solution might be a good choice too, depending what are you trying to do.