xp:text adds an unncessary parapgraph element - xpages

I have a computed text control:
<xp:text escape="false" tagName="span" contentType="html">
<xp:this.value><![CDATA[#{javascript:var msg = compositeData.msg;
if(compositeData.msgType.equals("text")){
return msg;
} else if (compositeData.msgType.equals("list")){
var text = "";
for (i = 0; i < msg.length; i++) {
text += "<li>" + msg[i] + "</li>";
}
return "<ul>" + text + "</ul>";
}}]]></xp:this.value>
</xp:text>
And when I apply an array of strings for it it generates the UL element BUT with an additional P element. How can I avoid that last one?
I also placed the xp:text control WITHIN a xp:panel element but the output is placed OUTSIDE this panel.
How can I fix this?
When I state that the output should be "text" the output is as expected.

sorry, the element that contains the xp:text can not contain lists.

Related

How to: page with 2 text fields, replace character when hitting button

I'm not a developer myself and even though html and css are kinda familiar to me, php and more advanced languages are not so please bear with me 😉
I want to have a simple html page (or php or whatever is necessary for this case) with 2 text fields and a button
What I want is to paste text into Field 1 and when I hit the Convert button, it will convert certain characters and show it in Field 2.
Example: I paste "I wanna go for a walk in the park" in Field 1. Hit Convert and Field 2 will show me "I w#nn# go for # w#lk in the p#rk"
(I know this is a silly example, but just so you can understand what I want to achieve).
I just need it to convert 1 single character at this point, so basically there's only 1 "variable".
Hope it makes and you guys can help me with it.
Thanks and stay safe!
Tiago 😊
html file
<input id="input_data" type="text">
<button id="convert">Convert</button>
<div>
<h1>Output</h1>
<p id="output"></p>
</div>
<script type="text/javascript">
document.getElementById("convert").onclick = function(){
var input = document.getElementById("input_data").value;
// your choice
var convert_from = "a";
var convert_to = "o";
var finalString = (input.split(convert_from.toUpperCase()).join(convert_to.toUpperCase())).split(convert_from).join(convert_to);
document.getElementById("output").textContent = finalString;
copyToClipboard(finalString);
}
// You can copy some text to clipboard only by selecting an element
function copyToClipboard(content){
// Create a textarea
var textHolder = document.createElement('textarea');
// Assign the value
textHolder.value = content;
// Appent the textarea to body
document.body.appendChild(textHolder);
// "Focus the action" on the textHolder
textHolder.select();
textHolder.setSelectionRange(0, 99999); /*For mobile devices*/
// Copy the content from selected element
document.execCommand('copy');
// Remove the textarea from body
document.body.removeChild(textHolder);
}
</script>
I hope it helps! ^_&

.focus and .trigger with text

I need help with my script. Need script working like this:
$(".Chat textarea").val(pQ); < .chat textarea [text place], pQ < my text
I want when text add in .chat textarea when add .focus() and press AUTO ENTER.
I think this script must look like:
var e = jQuery.Event("keypress");
e.which = 13; //choose the one you want
e.keyCode = 13;
$(".Chat textarea").val(pQ);$(".Chat textarea").focus();$(".Chat textarea".trigger(e);
I try this but this not work :/

JQVMAP Country Coloring

I am using JQVMAP at here. When I have a country that has members I desire to change that country's color without mousing over it, as the map is displayed.
I am using the following sql to get the countries and the number of their members. My question is what do I do, once I have a country, to change that countries map color? All countries will have the same color.
$result=mysql_query("SELECT COUNT(profile3.organizations) total_org, LEFT(countryCODEconversions.Code, 2) FROM profile3, countryCODEconversions WHERE TRIM(MID(countryCODEconversions.Code, 4, 147)) = profile3.country GROUP by profile3.country");
//if(mysql_num_rows($result)>0){
$counter = "";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
foreach ($line as $value) {
$counter += 1;
$value = stripslashes($value);
if ($counter == 1){$total = nl2br($value);}
if ($counter == 2){
$counter = 0;
$countryCode = strtolower($value);
?>
gdpOrgData['<?=$countryCode?>']=("<?=$total?>");
<?
Normaly, after loading the map you can set the color of countries that need a different color like this:
jQuery(document).ready(function() {
jQuery('#vmap').vectorMap('set', 'colors', {lt: '#8c9622',
sv: '#8c9622',
yr: '#8c9622'});
});
You could use PHP to generate the list in this script. Just make sure to load it after the map is loaded.
I hope this points you in the correct direction.

In a xe:dataView how to code the summary facet to show/hide the detail facet?

By default the summary column adds a link to open the underlying document as specified in the dataView's pageName property. I have a use-case where I want to keep the application in the dataView, and not open any "documentXPage".
I know this could be done in a repeat, but there are other parts/functionality of the dataView that work nicely for the application, so ideally I'm just looking to override the default behavior of the summaryColumn.
To override the link behavior I added the summary column as a facet, instead of a property, as in:
<xp:this.facets>
<xp:panel xp:key="summary" id="summaryPanel">
<xp:text escape="false" id="computedField3">
<xp:this.value><![CDATA[#{javascript:
var custName = viewEntry.getColumnValue("Customer");
return "<h4>"+custName+"</h4>"}]]>
</xp:this.value>
</xp:text>
</xp:panel>
<xp:panel xp:key="detail" id="detailsPanel" readonly="true">
<xp:text escape="true" id="computedField1">
<xp:this.value><![CDATA[{javascript:
viewEntry.getDocument().getItemValueString("Address") + ", " +
viewEntry.getDocument().getItemValueString("City") + ", " +
viewEntry.getDocument().getItemValueString("State")}]]>
</xp:this.value>
</xp:text>
</xp:panel>
<\xp:this.facets>
How do I code my summary facet to show/hide the details facet when clicked?
It depends on the setting detailsOnClient.
If that is set to true, you should be able to use CSJS to set display to "block" or "none" and you should be able to work out the ID of the element you need to change, using getComponent("dataView1").getRowIndex() (assuming your dataView has the ID dataView1)
This is also the key to doing the same if detailsOnClient is false. The following code will work.
var idex=getComponent("dataView1").getRowIndex();
getComponent("dataView1").toggleDetailVisible(#Text(idex+1));
You're basically getting a handle on the current rowIndex (which starts at 0), adding 1 to get the row to toggle and converting it to text. The DataView control has a method toggleDetailVisible(String) which is used to do the toggle.
As stated by #Mikael in Domino 9 the toggleDetailVisible function does not seem to work. Based on a suggestion from Brad Balassaitis I got it working by getting a handle to the twistie object and clicking it.
var myid = "#{id:link3}";
var parts = myid.split(":");
var outparts = [];
for(var idx=0; idx<parts.length-1; idx++){
outparts[idx] = parts[idx];
}
outparts[outparts.length-1] += "_shimg";
var bid = outparts.join(":");
var btn = document.getElementById(bid);
btn.click();

Flex Buttons from string

I have buttons with id's button1, button2, button3, etc.
I have a for loop that i need to loop starting with a number and i need to enable buttons based on my loop. I need help taking my string button1 and making that the id "button1" so i can use the button property's.
Any help would be greatly appreciated.
Thanks!
You should be able to iterate as such:
for (var i:uint = 1; i <= 3; i++)
{
var element:IVisualElement = this["group" + i];
}
You don't denote whether this Spark or Halo, but clearly substitute IVisualElement with the type of your choice. (Button, UIComponent, DisplayObject...)

Resources