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.
Related
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.
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 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}
I have a t:inputFileUpload inside the form, in the html of the display page the id of this component is form:inputFile but when I tried to get the component from the view root using "form:inputFile" the return is null, but when the "form:" is removed the return is the component. The component don't set the value in my managed bean, someone have this problem?
EDIT:
<h:form id="form" enctype="multipart/form-data">
<t:inputFileUpload id="inputFile" size="40" value="#{managedBean.inputFile}"/>
</h:form>
In the managed bean:
private UploadedFile inputFile;
with the gets and sets provided by Eclipse.
//This method scans the view root and returns the component with the id passed as parameter
findComponentInRoot("form:inputFile");
This returns null, but when I use:
//This method scans the view root and returns the component with the id passed as parameter
findComponentInRoot("inputFile");
The return is the component I'm looking for, but when I use the View Source in Internet Explorer the id of this component is "form:inputFile".
I don't know if this is related, but the component don't set the value in my managed bean and it's strange the fact that the id of the component is different from the HTML source.
I'm using JSF 1.2 Mojarra. Someone else has this problem? Or know why this happens?
EDIT2:
Okay, I'm very stupid, aparently the build wasn't working correctly and when the build was changed to other task from the Ant it worked (still don't know why, but simply worked). Sorry for the trouble.
You should use component binding or UIViewRoot#findComponent(). But that won't solve the problem of the uploaded file not being set. To fix it, first step is to ensure that you definied and configured the ExtensionsFilter properly as per the Tomahawk documentation, since it is the one responsible for parsing the multipart/form-data request and putting all the parameters among with the uploaded file back in the request parameter map, so that the FacesServlet can apply them and update the model values.
I guess findComponentInRoot is this (a minor detail you should've shared).
Anyway, using findComponent(..) or getChildren(..) always return the id of the components as defined in the page. The html id is something different that consists of the naming container:id.
I'd like to be able to include the return value of a fmt tag in another tag:
<local:roundedBox boxTitle="<fmt:message key="somekey"/>">
content
</roundedBox>
I've run into this problem multiple times and it just seems like a stupid limitation of jsp. Is there a simple way around this?
Use an intermediate variable to store the result like this (code not tested)
<fmt:message key="somekey" var="formattedvarname" />
<local:roundedBox boxTitle="${formattedvarname}">
content
</roundedBox>