Adding Html tag into the title of the Tree query in Oracle APEX - html

I have a requirement to make few text in the title of my tree query in Oracle APEX to bold by adding b tag. But when i do that, the tag is displayed at the front end. My query is as mentioned below. I do not want to see the b tag, rather i want the text enclosed by b tag to be bold. Please help.
SELECT
CASE
WHEN CONNECT_BY_ISLEAF = 1 THEN 0
WHEN level = 1 THEN 1
ELSE -1
END
AS status,
level,
CASE
WHEN level = 1 THEN questions
ELSE '<b>' -- Comes in the front end which i do not want
|| flow_condition
|| '</b>'
|| ' - '
|| questions
END
AS title,
NULL AS icon,
question_id AS value,
NULL AS tooltip,
--null as link
apex_page.get_url(
p_page => 401,
p_items => 'P401_QUESTION_ID',
p_values => question_id,
p_clear_cache => 401
) AS link
FROM
(
SELECT
mmq.*,
mmm.flow_condition
FROM
msd_mc_questions mmq
LEFT OUTER JOIN msd_mc_par_chld_mapping mmm ON (
mmq.parent_id = mmm.parent_question_id
AND
mmq.question_id = mmm.child_question_id
)
)
START WITH
parent_id IS NULL
CONNECT BY
PRIOR question_id = parent_id
ORDER SIBLINGS BY questions

Struggled with this for hours but then found a solution via jQuery. Create a dynamic action that on page load and executes javascript. Find all items with class .a-TreeView-label (assuming that's the class name at runtime that you get as well - check to be sure) and loop over them and for each one, replace its text with itself. This forces it to re-render as HTML. My code in the javascript task:
$(".a-TreeView-label").each(function(index){
$(this).replaceWith($(this).text());
});

On the item attribute "Escape special characters" change to "No"

Related

How can I use Logical Operator between 2 Select Statements?

I have few tables which are joined by some conditions.
What I am trying to achieve is Combine 2 SELECT statements in such way where
If there is data in Condition 1 display them OR go to Condition 2 and display data
Condition 1 - I am getting record from table say for exampleA, B, C and D based on some conditions
Condition 2 - I am getting record from table say for example A, B, C and E based on some conditions
What is am trying to achieve is
Display record if it exists in Condition 1
OR
Display record if it exits in Condition 2
Condition 1/ Query 1 - Display data
async getData() {
try {
const data = await this._conn.query(`
select first_name.value_name,quiz_table.answer, windows,player,first_name.value_id,country_place,current_name, pet_name, marker, relations
from schema_name.plugin,schema_name.quiz_table,schema_name.first_name, schema_name.value_version, schema_name.relationss
where plugin.answer= quiz_table.answer
and quiz_table.windows=first_name.value_id
and marker is not null
and schema_name.value_version.value_id= schema_name.first_name.value_id
and schema_name.value_version.caste= schema_name.first_name.caste
and schema_name.value_version.value_name= schema_name.first_name.value_name
and schema_name.value_version.version_number= schema_name.first_name.version_number
and schema_name.relationss.value_id= schema_name.first_name.value_id
and schema_name.relationss.caste= schema_name.first_name.caste
and schema_name.relationss.value_name= schema_name.first_name.value_name
and schema_name.relationss.version_number= schema_name.first_name.version_number
and schema_name.quiz_table.windows= schema_name.first_name.value_id
and in_process='N'
}
OR
Condition 2/ Query 2 - Display data
select schema_name.relationss."relations", schema_name.quiz_table."answer", schema_name.quiz_table."windows", schema_name.quiz_table."in_process", schema_name.quiz_table."object_name", schema_name.quiz_table."processed_date", schema_name.quiz_table."player", schema_name.quiz_table."country_place", schema_name.tools."mesh_scope_note", schema_name.plugin."current_name", schema_name.plugin."pet_name"
from schema_name.quiz_table, schema_name.tools, schema_name.plugin, schema_name.relationss, schema_name.value_version
where (in_process = 'N'
and schema_name.quiz_table."windows" = schema_name.tools."value_id"
and schema_name.quiz_table."player" = schema_name.tools."language"
and schema_name.quiz_table."answer" = schema_name.plugin."answer"
and schema_name.relationss."language" = schema_name.quiz_table."player"
and schema_name.relationss."language" = schema_name.tools."language"
and schema_name.relationss."caste" = schema_name.tools."caste"
and schema_name.relationss."value_name" = schema_name.tools."value_name"
and schema_name.relationss."version_number" = schema_name.tools."version_number"
and schema_name.relationss."value_id" = schema_name.tools."value_id"
and schema_name.value_version."value_id" = schema_name.tools."value_id"
and schema_name.value_version."version_number" = schema_name.tools."version_number"
and schema_name.value_version."caste" = schema_name.tools."caste"
)
NOTE - 1-> I cannot use function or procedure here.
2-> Both the `Conditions` contains `different data`
The problem is, how will the computer choose which option to go to? A computer does not choose, it can't. You have to provide some metric for which to choose. The boolean operator || (or) is for checking if either is true (declarative-sorta), not for imperative. You can 'ask' "is a or b true?" but you can't tell a computer, "do this or that" without any weight to either one which would explain to the computer which to pick and when.
What would be possible is asking,
"If there is data in Condition 1 display them; if not, go to Condition 2 and display data".
If that suits your needs, this is how it could be coded (this is just the framework).
if (data1 != null) {
show data1
}
else {
show data2
}
Or your data could be non-null, but have no contents, in which you could try to get some data from it (say, getChildren() (totally random, I'm just making that up):
if (data1.getChildren() != null) {
show data1
}
else {
show data2
}
I hope you know that this is just pseudocode for the theory of it. show_ is not actual code, it's just the placeholder for whatever you would write. Would this work - checking if it is null and/or checking if its contents are null (i.e., it's empty/without data) and if so then going to the next dataset?
I don't know sql, but I thought that idea of check-null/check-contents-null might help.

Need guidance and tips on oxmlelement

I am currently manipulating a word document using Python-docx and I would like to standardize every table/figure caption to either match with their corresponding heading or just increment them based on user choice.
I am currently stuck with the field code as I need to also update the field automatically. Below is a sample field code which I have from the document and would like to achieve
Table { STYLEREF 1 \s }-{ SEQ Table \* ARABIC \s 1} Random Heading Name
I have referenced from this github link
paragraph = document.add_paragraph('Table ', style='Caption')
run = run = paragraph.add_run()
r = run._r
fldChar = OxmlElement('w:fldChar')
fldChar.set(qn('w:fldCharType'), 'begin')
r.append(fldChar)
instrText = OxmlElement('w:instrText')
instrText.text = ' STYLEREF 1 \s '
r.append(instrText)
fldChar = OxmlElement('w:fldChar')
fldChar.set(qn('w:fldCharType'), 'end')
r.append(fldChar)
instrText = OxmlElement('w:instrText')
instrText.set(qn('xml:space'), 'preserve') # sets attribute on element
r.append(instrText)
fldChar = OxmlElement('w:fldChar')
fldChar.set(qn('w:fldCharType'), 'begin')
r.append(fldChar)
instrText = OxmlElement('w:instrText')
instrText.text = ' SEQ Table \* ARABIC \s 1'
r.append(instrText)
fldChar = OxmlElement('w:fldChar')
fldChar.set(qn('w:fldCharType'), 'end')
r.append(fldChar)
I have tried using preserver and separate but they can't seem to get "-" which I need sitting in between the 2 field code.
So right now, my end product is:
Table { STYLEREF 1 \s }{ SEQ Table \* ARABIC \s 1} Random Heading Name

Compare index of 2 elements in a collection

Issue : I have some issues figuring out a way to select elements in my HTMLDocument which are under a certain point in the page.
In the following code sample, as you can see in the comments, I first select a part of them which respect my queryselector criteria
IEDoc.querySelectorAll("td[width='100'][class='ListMainCent'][rowSpan='1'][colSpan='1']")
In this example I have 10 elements in this collection. Each of this element in contained in a table which is its parent on the 7th degree.
MsgBox TypeName(IEDoc.querySelectorAll("td[width='100'][class='ListMainCent'][rowSpan='1'][colSpan='1']")(2).ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode) ' HTMLTable
Some of those elements are in the same table.
You can see here the form which contains all the tables .
Now, the thing is that I want to select the innerHTML of some of those elements only and not all of them. The criterion to know if I one of those 10 elements interests me or not is it's position on the webpage. I want all the elements which are under the message Part Usage. There is only one table containing the Part Usage text and so my idea was to see if the table in which are contained each element has a higher or lower index in the "form" collection.
If the index is higher I want this element, otherwise I discard it.
What I did for this is the following code :
I set the ID Bim to all the tables containing one or more
from the 10 elements.
For Each Element In IEDoc.querySelectorAll("td[width='100'][class='ListMainCent'][rowSpan='1'][colSpan='1']") ' here for all of the 10 numbers found with the queryselectorall we'll find their respective table in the collection (form) and set its Class as "Bim". But since some of the numbers are in the same table, we won't have 10 tables with a classname "Bim" at the end of the process. We'll have only x tables with the classname "Bim"
Element.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.ParentNode.Class = "Bim"
Next
I set the ID Stop to the table containing the text Part Usage
For Each Element In IEDoc.getElementsByClassName("SectionHead")
If Element.innerHTML = "Part Usage" Then
'MsgBox TypeName(Element.ParentNode.ParentNode.ParentNode)' HTMLTable
Element.ParentNode.ParentNode.ParentNode.ID = "Stop"
End If
Next
I check which tables with the Classname Bim are under (=higher index) the table with the ID Stop. For the table ( there is actually only one) matching the criterion of point 3 I apply IEDoc.querySelectorAll("td[width='100'][class='ListMainCent'][rowSpan='1'][colSpan='1']") inside of them so that I get all the elements in contains and more paricularly their innerHTML.
For Each Element In IEDoc.getElementsByClassName("Bim") ' Here we check all the x tables which have the Classname "Bim"
If Element.indexInTheWholeForm > IEDoc.getElementById("Stop").indexInTheWholeForm Then 'and compare somehow if their index in the (form) collection if higher than the table with the ID "Stop" ( this is similar to checking if the element if lower on the webpage in thic case) ( we only want the element which have a higher index aka under the Part Usage table)
For Each Element2 In Element.querySelectorAll("td[width='100'][class='ListMainCent'][rowSpan='1'][colSpan='1']") ' Now we are in the table which contains the part numbers and we'll look for all the part numbers it contains by applying the queryselectorall again, but this time only in this specific table
array_parts2(iteration2) = Element.querySelectorAll("td[width='100'][class='ListMainCent'][rowSpan='1'][colSpan='1']")(iteration2).innerHTML
ActiveWorkbook.Worksheets(1).Cells(iteration2 + 1, 19) = array_parts2(iteration2)
iteration2 = iteration2 + 1
Next
End If
Next
of course what doesn't work is the indexInTheWholeForm property which doesn't exist. Any ideas on how to do this ?
Thank for reaching that line :)
Untested but I would do something like this (assuming I understood you correctly)
Sub Tester()
Const S_MATCH As String = "td[width='100'][class='ListMainCent'][rowSpan='1'][colSpan='1']"
Dim e, tbl, bHit As Boolean
'...
'load page etc
'...
'get all the matching rows and cycle though them
For Each e In IEDoc.querySelectorAll(S_MATCH)
'did we get to the table of interest yet?
If Not bHit Then
Set tbl = e.ParentNode.ParentNode.ParentNode.ParentNode. _
ParentNode.ParentNode.ParentNode
If IsPartUsageTable(tbl) Then bHit = True
End If
If bHit Then
'we reached the table of interest, so
' do something with e
End If
Next
End Sub
Function IsPartUsageTable(tbl) As Boolean
Dim e, rv As Boolean
For Each e In tbl.getElementsByClassName("SectionHead")
If Element.innerHTML = "Part Usage" Then
rv = True
Exit For
End If
Next
IsPartUsageTable = rv
End Function
Ok, so as unexpected as it sounds, I think I found a solution to my own question. I will confirm you that it works as soon as I have the possibility to run it with my colleague.
So I keep point 1 and 2 from my initial post and I replaced point 3 with the following :
For i = 0 To IEDoc.getElementsByTagName("form")(0).getElementsByTagName("table").length
If IEDoc.getElementsByTagName("form")(0).getElementsByTagName("table")(i).ID = "Stop" Then
index_Part_Usage = i
Position_Part_Usage = index + 1
Exit For
End If
Next
'MsgBox Position_Part_Usage
For i = 0 To IEDoc.getElementsByTagName("form")(0).getElementsByTagName("table").length
If IEDoc.getElementsByTagName("form")(0).getElementsByTagName("table")(i).className = "Bim" Then
index = i
Position = index + 1
If index > index_Part_Usage Then
For Each Element2 In IEDoc.getElementsByTagName("form")(0).getElementsByTagName("table")(i).querySelectorAll("td[width='100'][class='ListMainCent'][rowSpan='1'][colSpan='1']") ' Now we are in the table which contains the part numbers and we'll look for all the part numbers it contains by applying the queryselectorall again, but this time only in this specific table
array_parts2(iteration2) = IEDoc.getElementsByTagName("form")(0).getElementsByTagName("table")(i).querySelectorAll("td[width='100'][class='ListMainCent'][rowSpan='1'][colSpan='1']")(iteration2).innerHTML
ActiveWorkbook.Worksheets(1).Cells(iteration2 + 1, 19) = array_parts2(iteration2)
iteration2 = iteration2 + 1
Next
End If
End If
Next i

Jython - anyone got an idea why this Action isn't doing what I want?

This is about unit testing (using Python's unittest module). I'm trying to implement, programmatically, the user's pressing "F2" to start editing the cell of a JTable.
The utility method "run_in_edt" wraps the passed method in a Runnable and then runs it using invokeAndWait, rather than invokeLater.
def test_can_edit_table_date(self):
main_frame = FTCase2.app.main_frame
dates_table = main_frame.dates_table
def start_editing():
dates_table.requestFocus()
f2_key_stroke = javax.swing.KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_F2, 0 )
im = dates_table.getInputMap( javax.swing.JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT )
action_value = im.get( f2_key_stroke )
self.assertEqual( action_value, 'startEditing' )
am = dates_table.actionMap
self.f2_action = am.get( action_value )
self.assertIsNotNone( self.f2_action )
sel_row = dates_table.selectedRow
self.assertNotEqual( sel_row, -1 )
self.assertTrue( dates_table.isCellEditable( sel_row, 0 ))
self.start_editing_action_event = java.awt.event.ActionEvent( dates_table,
java.awt.event.ActionEvent.ACTION_FIRST, 'X' )
self.f2_action.actionPerformed( self.start_editing_action_event )
# dates_table.editCellAt( sel_row, 0 )
# self.assertTrue( dates_table.editing )
_utils.run_in_edt( start_editing )
# time.sleep( 1 )
def write_string_in_cell_editor():
self.assertTrue( dates_table.editing )
cell_editor = dates_table.cellEditor
self.assertIsNotNone( cell_editor )
cell_value = cell_editor.cellEditorValue
cell_editor.component.text = "mouse"
self.f2_action.actionPerformed( self.start_editing_action_event)
_utils.run_in_edt( write_string_in_cell_editor )
The problem: "dates_table.editing" always comes out false... and getting the cell editor returns None. I have also tried putting a sleep between these two Runnables, just in case it was a question of "events having to bubble up/down"...
NB I also tried with a more sensible value as the 3rd param of ActionEvent, such as action_value (i.e. 'startEditing'). No joy.
I can of course do:
dates_table.editCellAt( sel_row, 0 )
... with this uncommented, what's interesting is that, in the second method here, I set the JTextField's ("editor delegate") text to "mouse", and then "press F2" by using the action.actionPerformed... and... it works, in the sense that in my table cell renderer I allow only dates values or None, not strings, so an AssertionError is raised. Meaning that I have managed to simulate an F2 key press (NB although the name of this action is "startEditing", it also stops an editing session, in real life as in testing).
... I could content myself with using editCellAt, and having ascertained that F2 has the right entry in the right InputMap, and that the value is pops out is an Action (could be checked) with the name "startEditing", which is proven to be capable of ending an edit, I could just content myself with that.
But I so hate it when my understanding is revealed to be less than good! I want to know WHY this doesn't work...
Found the answer and put it here for reference.
My requestFocus() action on the JTable did indeed leave selection on the right row, but without any selection of the (single) column. Even when running as normal (not testing) the JTable column did not initially respond to F2. It was puzzling to me why the cell was not initially surrounded by a heavy black border. The answer was therefore to put this line after the requestFocus line:
dates_table.setColumnSelectionInterval( 0, 0 )

Wait for a select_list to exist and then select a value

I am trying to select an option from a select list using page-object. I am using IE8(have to) which is very slow when interacting with page-object.
When /^the user selects the Test Region "([^"]*)"$/ do |regionname|
on_page(MyTestRegion) do |page|
page.region = /#{regionname}/ if regionname != "" && regionname != {}
end
end
I get Watir::Exception::UnknownObjectException: unable to locate element error.
I need to wait for the select_list element to load and then select a value.
I did try visible?, wait_until, wait_when_present, when_present but nothing so far seem to work... Is there an alternate way to wait until a element is loaded?