I'm using primefaces(3.0.M2) rich editor for receiving input from user. The restriction is 5000 characters. When user tries to copy from external sources or beautify the content additional tags are getting added to preserve the format.
Now to validate the max length of 5000, I need to strip out the tags and only count the characters length. How to get the characters alone from in managed bean for validation?
client side validation snippet:
<p:editor id="customerInfo" value="#{companyBean.body}"
required="false" requiredMessage="Info required" height="250" width="450"
validatorMessage="Only 5000 characters allowed">
<f:validateLength maximum="5000" />
</p:editor>
Just to help others like me, which tried to find some answer too!
You can user wigdteVar to access the editor value, like this:
<p:editor
id="iptTextoClausula"
widgetVar="wvMyEditor"
width="790"
height="200"
validator="clausulaEditorValidator"
value="#{clausulasContratadasBean.selectedClauseFull.dsTexto}" />
<script language="Javascript">
wvMyEditor.editor.doc.body.innerText
</script>
Related
Good day:
I am conducting a search using prettyFaces, style gmail.
When I do with gmail, space is replaced by a symbol "+". And in the box is not added the "+".
In my case, when I do the same, in other characters url as in my box are added.
Here the mapping code, and box:
<url-mapping id="search">
<pattern value="/buscar/#{ /.*/ searchBean.q}" />
<view-id value="/faces/reqs/search.xhtml" />
<action>#{searchBean.search}</action>
</url-mapping>
<div class="search">
<h:form id="searchForm">
<span class="button-group">
<p:inputText value="#{searchBean.q}" size="50"/>
<p:commandButton action="pretty:search"/>
</span>
</h:form>
</div>
Thanks for the help.
EDIT:
And if facebook would be because it is a parameter? and as it would be a solution to avoid aparesca special characters in the input?
This is expected behavior. In case of GMail the spaces are part of the "fragment" which is the part after the "#" character. In your PrettyFaces setup, the search term is part of the path.
There are different encoding rules for fragments and path parts of the URL. So PrettyFaces is handling this correctly.
I want to display the message with a jsp page in search container emptyResultsMessage.
Presently my code is:
<liferay-ui:search-container delta="10" emptyResultsMessage="There are no results." iteratorURL="<%=iteratorURL %>" deltaConfigurable="true" var="searchContainer" >
Now when I want to display
There are no results.+ button.jsp
in emptyResultsMessage.
In button.jsp I have a button. It has to display when emptyResultsMessage is empty.
Can any one tell me how to display it?
<liferay-ui:search-container delta="10" emptyResultsMessage="there were no courses found please <jsp:include page='subscribeSearch.jsp' /> with us" iteratorURL="<%=iteratorURL %>" deltaConfigurable="true" var="searchContainer" >
<liferay-util:buffer .../> is your friend. You don't seem to care for internationalization, so the easy approach is this: Construct the message before, then just use it:
(untested pseudocode, don't expect it to work out of the box)
<liferay-util:buffer var="emptyMessage">
there were no courses found please
<liferay-util:include
page="subscribeSearch.jsp"
/>
with us
</liferay-util:buffer>
<liferay-ui:search-container delta="10"
emptyResultsMessage="<%=emptyMessage%>"
iteratorURL="<%=iteratorURL %>"
deltaConfigurable="true"
var="searchContainer"
>
....
IMHO I'd construct the whole message on that jsp page rather than just fragments. But I'd also use proper i18n, but you get the basic idea from this.
Also, check if you need to escape the string (e.g. use <%=HtmlUtil.escape(emptyMessage)%>). I'm not sure which order the processing is done out of the top of my head (can't test currently)
I have been using display.none, for the hid-whens for example, all the hidden fields were kept in a section and section was hidden from web by using Display.none.
This is working for Internet Explorer till IE 9, but for IE 10 all the hidden fields are shown.
Can anyone help in this matter. Any alternative or approach.
Without seeing the page it sis very difficult to guess.
Try validating the html through one of the many online html validators as something may not be closed or Notes might have given you an unwanted code addition .
Try adding a background color to the css #wrapper to make sure the css is being called.
Take a copy of the form and start removing all other elements one section at a time to see if something else is causing the issue.
Add {meta http-equiv="X-UA-Compatible" content="IE=10;IE=9; IE=8; IE=7; IE=EDGE" /} as the very top meta tag and see if that fixes it. Replace the curly braces obviously.
All the best in finding the issue.
It sounds like just the section element is getting hidden. Without seeing the code I can't tell why that changes between ie 9 and 10 but ie is famous for having varying behavior between versions.
One alternative that comes to mind: You could wrap the section and the fields in a DIV element using pass thru HTML and set that div's style to display:none. That is pretty standard and should work across browsers.
Update: To give you an idea what I'm talking about, check out this jsfiddle.
HTML:
<form>
<div class="wrapper">
<input type="text" name="Field 1" /><br />
<input type="text" name="Field 2" /><br />
<input type="text" name="Field 3" />
</div>
<span>Some text that won't be hidden.</span>
</form>
CSS:
.wrapper {
#display:none;
}
You can remove the # next to the display:none and see the difference, even in IE 10.
You'll need to look closely at the HTML being rendered by Domino and make sure that in fact all the fields you are trying to hide are surrounded by the DIV that is hidden.
Deceptively simple question, but I'm at my wits' end here.
I have a document. It contains a form. Which contains a subform. Which contains a read-only text field. Here's the relevant part of the structure:
<tr:document ...>
<tr:form ....>
<tr:subform ...>
<div ...><div ...>
<tr:panelGroupLayout>
<tr:panelFormLayout>
<tr:inputText id="selectedAmount"
label="#{...}"
value="#{...}"
disabled="true" />
</tr:panelFormLayout>
</tr:panelGroupLayout>
</div></div>
</tr:subform>
</tr:form>
</tr:document>
(none of the attributes on the ... are setting style information.)
Why is it that MyFaces produces for the innermost element a div rather than input type="text"? I've seen forms with (apparently) this exact same structure that didn't have this problem.
The reason why this is silly and unacceptable is because the div, when empty, doesn't show as a box but as a single line (the border collapses since there is no content and no height style). Manually setting a height via css isn't acceptable either, because the font may vary from computer to computer. I really just wanted it to always render an input tag.
Any ideas? Feel free to ask for details if you want to confirm any suspicion. There's too many data for me to just dump everything in here.
In my ASP.NET 1.1 application, I am compressing and replacing the hidden Viewstate variable with an alternate compressed value, stored in a hidden field called __VSTATE. This works well but on a few occasions, submitting a page causes the common "potentially dangerous Request.Form value ..." error.
I examined the __VSTATE value and nothing seems to be potentially dangerous. I was able to reproduce the error with a completely stripped down version of the page and __VSTATE value as shown below. Pressing the submit button causes the error. The page works fine if I change the value to "".
<%# Page Language="vb" AutoEventWireup="false" Codebehind="Dangerous.aspx.vb" Inherits="Dynalabs.Dangerous" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<input type="hidden" id="__VSTATE" runat="server" value="Onw=" />
<asp:Button ID="btnSubmit" Runat="server" Text="Submit" />
</form>
</body>
</html>
Changing the field name to "MyHiddenWT" made no difference. Removing the runat="server" did stop the error but that just means that .NET only examines server side controls. I also tried some additional values and found that of the following:
"Anw=", "Bnw=", "Cnw=", ... "Nnw=", "Onw=", "Pnw=", ... "Znw=",
"Onw=" is the only one that causes the problem. Is the captial O being seen as an octal value somehow?
Can someone explain why this value is triggering the error message? I'm also looking for a solution but, please, do not tell me to remove page validation. That's the same as saying a car with bad brakes can be fixed by not driving the car.
Thank you in advance.
My first guess is that it looks like a "OnSomething=" javascript event declaration.
It's a little weird that only the capital O triggers the error, did you test on the lowercase o as well?
Can you try these: "OnClick=", "abc OnClick=", "onclick=", "abc onclick=", "anw=", "bnw=", ...
If "OnSomething=x" javascript is a problem, then simply adding another character to your values should do the trick. Maybe a simple 'v' should do.
<input type="hidden" id="__VSTATE" runat="server" value="vOnw=" />
And then on submit, you remove the extra character before decoding.
Or better yet, upgrade to 2.0.
You've got the essence of the reason. Here's the best link in a response I got from another site:
http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet.security/browse_thread/thread/d91d89511401e979