Adding a badge to an xpages applayout title bar node item - xpages

Is it possible to add a simple badge to a title bar node item? Each tab in my layout represents a separate application. My users would like to see a number next to the name on the tab to indicate whether there are documents in that application needing their attention. If no documents, then no badge, just the application name by itself. If there are documents, then display the application name and a badge for the number. I'm not finding a way to include the span tag in a PageLinkNode or BasicLinkNode.

PageLinkNode (xe:pageTreeNode) label can only be plain text.
You can use the image property though:
<xe:this.titleBarTabs>
<xe:pageTreeNode
page="..."
label="Application A"
image="#{javascript: var nr = 5;
nr > 0 ? ('badge' + Math.min(nr, 10) + '.gif') : ''}">
</xe:pageTreeNode>
Add to Resources/Images ten pictures badge1.gif, badge2.gif, ... badge10.gif with the numbers as pictures. badge10.gif would be a 9+ picture.
As an alternative, you could provide the number of documents as part of the label (e.g. "Your Application Name [23]") and convert it on client side onClientLoad event to HTML label + badge-span.

Related

I need help in Python with displaying the contents of a 2D Set into a Tkinter Textbox

Disclaimer: I have only begun to learn about Python. I took a crash course just to learn the very basics about a month ago and the rest of my efforts to learn have all been research thru Google and looking at solutions here in Stack Overflow.
I am trying to create an application that will read all PDF files stored in a folder and extract their filenames, page numbers, and the contents of the first page, and store this information into a 2D set. Once this is done, the application will create a tkinter GUI with 2 listboxes and 1 text box.
The application should display the PDF filenames in the first listbox, and the corresponding page numbers of each file in the second listbox. Both listboxes are synched in scrolling.
The text box should display the text contents on the first page of the PDF.
What I want to happen is that each time I click a PDF filename in the first listbox with the mouse or with up or down arrow keys, the application should display the contents of the first page of the selected file in the text box.
This is how my GUI looks and how it should function
https://i.stack.imgur.com/xrkvo.jpg
I have been successful in all other requirements so far except the part where when I select a filename in the first listbox, the contents of the first page of the PDF should be displayed in the text box.
Here is my code for populating the listboxes and text box. The contents of my 2D set pdfFiles is [['PDF1 filename', 'PDF1 total pages', 'PDF1 text content of first page'], ['PDF2 filename', 'PDF2 total pages', 'PDF2 text content of first page'], ... etc.
===========Setting the Listboxes and Textbox=========
scrollbar = Scrollbar(list_2)
scrollbar.pack(side=RIGHT, fill=Y)
list_1.config(yscrollcommand=scrollbar.set)
list_1.bind("<MouseWheel>", scrolllistbox2)
list_2.config(yscrollcommand=scrollbar.set)
list_2.bind("<MouseWheel>", scrolllistbox1)
txt_3 = tk.Text(my_window, font='Arial 10', wrap=WORD)
txt_3.place(relx=0.5, rely=0.12, relwidth=0.472, relheight=0.86)
scrollbar = Scrollbar(txt_3)
scrollbar.pack(side=RIGHT, fill=Y)
list_1.bind("<<ListboxSelect>>", CurSelect)
============Populating the Listboxes with the content of the 2D Set===
i = 0
while i < count:
list_1.insert(tk.END, pdfFiles[i][0])
list_2.insert(tk.END, pdfFiles[i][1])
i = i + 1
============Here is my code for CurSelect function========
def CurSelect(evt):
values = [list_1.get(idx) for idx in list_1.curselection()]
print(", ".join(values)) ????
========================
The print command above is just my test command to show that I have successfully extracted the selected item in the listbox. What I need now is to somehow link that information to its corresponding page content in my 2D list and display it in the text box.
Something like:
1) select the filename in the listbox
2) link the selected filename to the filenames stored in the pdfFilename 2D set
3) once filename is found, identify the corresponding text of the first page
4) display the text of the first page of the selected file in the text box
I hope I am making sense. Please help.
You don't need much to finish it. You just need some small things:
1. Get the selected item of your listbox:
selected_indexes = list_1.curselection()
first_selected = selected_indexes[0] # it's possible to select multiple items
2. Get the corresponding PDF text:
pdf_text = pdfFiles[first_selected][2]
3. Change the text of your Text widget: (from https://stackoverflow.com/a/20908371/8733066)
txt_3.delete("1.0", tk.END)
txt_3.insert(tk.END, pdf_text)
so replace your CurSelect(evt) method with this:
def CurSelect(evt):
selected_indexes = list_1.curselection()
first_selected = selected_indexes[0]
pdf_text = pdfFiles[first_selected][2]
txt_3.delete("1.0", tk.END)
txt_3.insert(tk.END, pdf_text)

PHPWord Footer Position

Does anyone know if it is possible to re-position (or set the height of) a footer using PHPWord?
I have a footer exactly as required in terms of text.
$footer = $section->addFooter();
$textrun = $footer->addTextRun();
$textrun->addText('My Footer Text');
However, what I'd like to achieve is to:
Reduce the height of the footer or set the distance from bottom of the page.
There in an option in Word365 called "Footer from bottom", there are also similar options in older versions of Word.
I've tried adjusting the page margins but these appear to be separate from the footer (and header) positioning.
I managed to find a solution by reviewing the GitHub repo.
This commit provides a solution: Added support for page header & page footer height
You can pass the attributes "headerHeight" & "footerHeight" when you create the section that contains your header and footer.
// Adding an empty Section to the document...
$section = $this->_phpWord->addSection(array(
'headerHeight' => 300,
'footerHeight' => 50)
);
$footer = $section->addFooter();
$textrun = $footer->addTextRun();
$textrun->addText('My Footer Text');
There are also some public methods for setting these values after you've created your section, these are: setFooterHeight() and setHeaderHeight().
$section->setHeaderHeight(300);
$section->setFooterHeight(50);

SharePoint Hiding fields in newform, dispform, editform

I have a task here when I need some assistance. what I am trying to accomplish is the follow..
Hide some fields on the newform, editform and dispform with in SharePoint (2013)
The field I am trying to hide is ONLY the input/textbox field not the whole column/heading associated with it. Basically I have a form with a heading and an associated textbox(single line of text) next to it, what I would like to do is hide the textbox only.
I have used the F12 IE tools to select the text box to which displays the following souce code:
<input title="Travel" class="ms-long ms-spellcheck-true" id="Travel_f6801fb9-c4ff-4109-acb9-f7dd63c1d98a_$TextField" type="text" maxlength="255" value="">
(the textbox is associated with my "Travel" column)
Now when I use the F12 tools while selecting this, I added some css(from that I can tell) under the "inline Style" top heading which was "display=none" and bingo it works!.
Now what I cant do here is add this to the forms permanently. I have tried to google this by adding a Content web part to the form and try some CSS/Java script but I simply do not have the skills in this area.. does this make sense?
examples:
any help would be great
Cheers!
In SharePoint 2013 was introduced Client Side Rendering (aka CSR) which is used for rendering list views, list forms and search results. For a more details follow SharePoint 2013 Client Side Rendering: List Forms article.
The following JavaScript template demonstrates how to hide field controls in List Form pages:
SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() {
SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
OnPostRender: hideFieldControls
});
});
function getFieldControlId(field){
return field.Name + '_' + field.Id + '_$' + field.Type + 'Field';
}
function hideFieldControl(field){
var fieldControlId = getFieldControlId(field);
var fieldControl = document.getElementById(fieldControlId);
fieldControl.style.display = "none";
}
function hideFieldControls(ctx){
var fieldNamesToHide = ['JobTitle','WorkPhone']; //<- set field names to hide here
if(fieldNamesToHide.indexOf(ctx.ListSchema.Field[0].Name) > -1) {
hideFieldControl(ctx.ListSchema.Field[0]);
}
}
How to apply changes
Open List Form page in edit mode
Add Script Editor web part on the page
Insert the specified JavaScript template by enclosing it using
script tag Note: specify field names to hide via fieldNamesToHide variable
Save page
Results
Pic 1. Original New Form page
Pic. 2 Customized New Form (field controls for Job Title and Business Phone are hidden)

ExtJs layout + Window

While adding component dynamically, 'this.container is null' is displayed in firebug.
I have a window with some combo boxes say combo1, combo2, combo3 and a label. Based on the selection value of combo3 the 'label' field is removed and replaced with combobox or text field. i do this my using
form.items.removeAt(4);
form.items.insert(4, newItem); #here newItem can be combox/textfield
form.doLayout();
The form resides inside a panel.
When above lines are execueted. 'this.container is null' is displayed and component fails to insert/add in appropiate position.
Any suggestions?
You should not be modifying the underlying items collection. Use the remove/insert methods on the container.
Try to comment those lines line-by-line to see which one produces error like
form.items.removeAt(4);
//form.items.insert(4, newItem); #here newItem can be combox/textfield
//form.doLayout();
form.items.removeAt(4);
form.items.insert(4, newItem); #here newItem can be combox/textfield
//form.doLayout();
form.items.removeAt(4);
form.items.insert(4, newItem); #here newItem can be combox/textfield
form.doLayout();
Your problem could take place because of inserted/replaced object is no yet prepared when you try to insert it. Give us your newItem initilization code.
Upd
Or you can wrap your changing components (label, combobox, textfields) in a panel with card layout. And on change of combo3 simply select exact card in that panel.

lwuit text area

I developed an RSS Application for two XML files and displayed it on two LWUIT Tabs. The problem is with my LWUIT TextArea, whenever I click on my ListForm (it contains titles from the RssFile), I need to display description information from the RSS File. First time I am able to display the description related to the title clicked in ListForm. If I click the ListForm the next time onwards I am able to display the same description again and again in the textarea..(Eventhough I am getting Related Description from RssFile)
Here is my Code:
private void displayCompleteNewsScreen(News detailNews) {
Label title = new Label(detailNews.getTitle());
form2.setTitleComponent(title);
String Description = detailNews.getDescription();
System.out.println("Description" + Description);//Here i am able to get different Description values Related to myList Screen but in text area it is displaying First one always
big = new TextArea();
big.setEditable(false);
big.setText(Description);
form2.addComponent(pubDate);
form2.addComponent(big);
form2.show();
}
As you are reusing form2 instance you should clear it in displayCompleteNewsScreen method. Call removeAll before calling setTitleComponent.
And don't forget to set form2 Commands again in displayCompleteNewsScreen.

Resources