I have a JSF Renderer that uses responsewriter to generate a jsf page .
In this class I create a String that contains html code , something like this :
String s = "<b>hello</b> <i>world</i>" .
when I create a tinymce editor and set the value of it with responsewriter like this :
responseWriter.writeText(value, null);
it show exactly the same String (showing HTML tag) instead of HTML format of it.
I know it's Wrong to use writeText for writing HTML but I don't know what to use instead.
Try setContent.
responseWriter.setContent(s);
More information here: http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent
finally I solved my problem in this way :
I set the value in a hidden like this :
responseWriter.startElement("input", null);
responseWriter.writeAttribute("type", "hidden", null);
responseWriter.writeAttribute("id", "tinymcevalue" , null);
responseWriter.writeAttribute("name", "required-" + filerRichTextEditor.getSchemaName(), null);
responseWriter.writeAttribute("value", getDocumentFieldValue(filerUIComponent.getSchemaName()), null);
responseWriter.endElement("input");
and then I set it in my JSF :
tinyMCE.activeEditor.setContent(document.getElementById("tinymcevalue").value);
Related
I use Thymeleaf in frontend pages, and for some reason I have to deal with i18n by i18next.js instead of spring framework.
According to the i18next-jquery introduction - using options in translation function, I write like this:
<span data-i18n="myKey" data-i18n-options='{ "WHERE": "TW" }'></span>
And there is my language resource:
{ "myKey" : "User is from {{WHERE}}." }
And html is parsed and showed like this perfectly:
<span data-i18n="myKey" data-i18n-options='{ "WHERE": "TW" }'> User is from TW. </span>
But when I set {{WHERE}} dynamically by Thymeleaf attributes, it just can't be parsed anything.
I tried
th:attrappend="data-i18n-options='{WHERE: '+ ${country} +'}'" also
th:data-i18n-options="'{WHERE: '+ ${country} +'}'",
somehow it just end up like this:
<span data-i18n="myKey" data-i18n-options="{WHERE: TW}">User is from .</span>
So I wonder that is there any idea to parse json string in Thymeleaf attribute ?
Update:
I want to share my solution,and I hope it will save someone's time :)
th:attrappend='data-i18n-options=|{ "WHERE":"${country}"}|'
or
th:data-i18n-options='|{ "WHERE":"${country}"}|'
Please try these two:
th:attrappend='data-i18n-options=|{ "WHERE":"${country}"}|'
or
th:data-i18n-options='|{ "WHERE":"${country}"}|'
Can I create a HTML form through an apex String ? For instance, I want something like this.
String example = "<p> This is my example </p> <br/>";
But what it returns is " This is my example ", HTML tags does not have its real meaning in it. Is there any other way to achieve this ?
Thank You
What if you replace the html elements with their html entity counterparts:
String example = "<p> This is my example </p> <br/>";
I have a live template like this
<div>$name$: $id$</div>
Now I want to set the default value of $id$ to name + "_id".
But when I put the default value of $id$ as name + "_id", in the "Edit Template Variables Dialog", the autocomplete does not concatenate value of name and (string) "_id" together. It only uses the value of name and ignored the "_id" part (for default value of $id$).
How can I make the default value of $id$ as name + "_id" in my live templates?
You can try to create a variable and concat the values into it.
Something like:
#set( $your_var = $NAME + '_id')
<div>$name$: $your_var$</div>
Not sure about phpstorm, but I was just looking for the solution to this problem in webstorm and there is a concat(expressions...) function. So, solution to the problem could be to put in the 'Expression' field:
concat(name,"_id")
You can just do this:
<div>$name$: $name$_id</div>
I want to know how to use the attribute rendered in PrimeFaces.
Does this piece of code make any sense:
rendered="#{bean.user 1} and #{bean.user 2}"
The rendered attribute only accepts boolean values. It defines if a component will be created in your page DOM. If you set a component as rendered="false", it will not be visible in your website.
And answering your question: that piece of code only makes sense if user1 and user2 are boolean variables in your bean. Also, don't forget the getters and setters for those variables.
Rendered attribute can only accepts Boolean value, or if you use EL expression, it's expression must evaluate to Boolean value like
#{mBean.isTrue} , #{mBean.valueOne eq 1} , #{mBean.valueOne == 1} , #{mBean.stringValue == 'String'} , etc.
Hope it's help.
i have several strings that look like this:
contactBtn, programBtn, cartBtn.
How can i split these strings so that the "btn" gets discarted, so i keep contact, program, cart.
How would i achieve this?
The String class has a replace method:
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html
Check out the Replace() Section of the ActionScript 3.0 Documentation.
http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/String.html#match%28%29
var yourString:String = “contactBtn”
yourString= yourString.split(“Btn”).join(“”);
trace(yourString);
// Output : yourString = "contact"
You would just have to iterate through all of your buttons.
You can also use RegExp :
trace(/.+(?=btn$)/gi.exec("foobtn"));//foo
trace(/.+(?=btn$)/gi.exec("fooBTN"));//foo
trace(/.+(?=btn$)/gi.exec("barbtn"));//bar
trace(/.+(?=btn$)/gi.exec("bar"));//null