Primefaces Treenode How to select father node only? - primefaces

Is there anyways to select father node without its children in Primefaces treenode?
I am using Primefaces treenode to display a product category, but not all products belong to children categories. For example, a product belongs to category 1.1.1, but another belongs to 1.1.
I want to update the product's category, but when I select father node, its nodes will be selected too.
This is when I select father category:
This is what I want it to be:
Please help me, thank you.
p/s: I want to use checkbox.

See the documentation: https://primefaces.github.io/primefaces/10_0_0/#/components/tree?id=tree
Look at the propagateSelectionUp and propagateSelectionDown properties. You want to turn them to false to get the behavior you want.

Related

XPath select parent element only if child element exists

<element_1>
<element_2>Text</element_2>
<element_3>
<element_4>
<element_5>Test Text</element_5>
</element_4>
<element_4>
</element_4>
</element_3>
<element_6>
<element_7>
<element_8>0</element_8>
How would I write xpath to find all instances of element_4 that contain an instance of element_5
Context
URL: https://www.amazon.com/b/ref=s9_acss_bw_cg_KOTHLPCG_1a1_w?node=565108&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=merchandised-search-6&pf_rd_r=PASRJV57NJ97XPYZW0GS&pf_rd_t=101&pf_rd_p=1e1598d2-28c3-4a64-91af-254d7a033ada&pf_rd_i=541966\
I am using selenium and I am trying grab the name of only the laptops that are on sale. The laptops that are on sale have an old price that is written with a strike through which is written underneath its current price. I want the names of only the laptops that have that strike through price in their listing.
Very new to Selenium and Xpath so I hope that made sense.
To complete, this will select laptop names on sale (works for all pages, featured items on page 1 excluded):
//span[#data-a-strike="true" or contains(#class,"text-strike")][.//text()]/preceding::h2[#class][1]

Microsoft Access using listbox with form value

I have been trawling the internet for a working solution to my immediate problem, and whilst I have found what appear to be solutions they don't actually work.
I have a member form "Members" from a members Table. I also have a Children table which list all children. The members table has a ID Number field and the children table has an Member_ID field.
What I want is when you show a member in the main form, the listbox shows all children for that member. The Row source for the listbox is
SELECT [Children Query].[Child Name], [Children Query].Child_Date_Of_Birth
FROM [Children Query]
WHERE ((([Children Query].[Member ID])=[Forms]![Members]![ID Number]));
All I seem to get is blanks. If I remove the WHERE then all children appear on all members.
I thought that maybe I need to refresh the query somehow every time I change members, but the first member to appear on opening the form has a child and even that one doesn't appear.
Any help would be appreciated as I'm fairly new to VB. I know this can be done but all of the site that I have found explain exactly what I am doing.
Thanks

Ontology: OWL - Creating connections between classes

I ve got an Ontology written in OWL with Protege. But I don't find a solution for creating relations between Classes. Of course, there is a "subclass" relation, but I want to define my own relations. So I have a class hierarchy (which consists out of "subclass"-relations) but I want to create a relation, i.e. "has_Relation", to connect two classes.
My aim is to write a java programm in which I can get the information "which class is parentclass of a class?" and "to which class is a has_Relation connection?"
(I am not talking about individuals - I'm just talking about classes)
Thank you very much for your help in advance!
Best Regards
Natan
The simplest way to do this is to use an annotation property. In Protégé, select the class you want to relate to another class, then click the + beside "Annotations" in the Annotations tab. Then add the has_Relation property with the second button on the top left of the window. Then select the Entity IRI tab and the Classes subtab, select the other class you want to relate to and you're done.
However, you should rather not do this if has_Relation is an object property or a datatype property. If such is the case, you can use "punning", that is, you can make new individuals in the Individuals tab with the same names as the classes you want to relate. Then you relate them as if they were normal individuals. Note that this is allowed and valid in OWL 2 DL.
a bit late, but:
You can also go to the tabs menu and active the object properties tab
(Window> Tabs -> Object Properties )
Then you can create your own object property and assign its domain and range to which ever classes you want ( Description area of the individual property ).

How to control column headings in the NEW/EDIT views based on the CATEGORY selected from a drop-down list. Ruby on Rails w/ MYSQL

Two models:
category has_many: components
component belongs_to: category
The CATEGORY table defines variable names for different component types:
TYPE, VAR1, VAR2, VAR3, ...
Insulator, Voltage, Height, Material, ...
Current Transformer, Voltage, Ratio, Indoor, ...
In the NEW/EDIT views for the COMPONENT model, the user will first section the CATEGORY from a drop-down list. Based on the CATEGORY selected the column headings and field labels in the form(s) need to dynamically update to indicate the variable names associated with the selected CATEGORY.
i.e. IF the user selects CATEGORY = Insulator THEN the field labels for VAR1 ... VAR3 are Voltage, Height, Material, etc.
I assume this will be controlled in the _form.html.erb of a typical scaffold. I am looking for a recommended technique.
Thanks in advance any information.
Changing a form in response to a user selecting a different option in a select tag is probably best done by Javascript. This allows for execution on the client side, which will be faster than a trip back to the server.
I would recommend placing the different form fields inside a div tag that is hidden when the page loads. Each of the combinations of categories can be toggled to show in the form by binding to the Javscript onChange event on the select tag.
Here is more information on the select tag: http://www.w3schools.com/jsref/event_onchange.asp

Handling Multiple Images with ColdFusion and MySQL

This is an architecture question, but its solution lies in ColdFusion and MySQL structure--or at least I believe so.
I have a products table in my database, and each product can have any number of screen-shots. My current method to display product screen-shots is the following:
I have a single folder where all screen-shots associated with all products are contained. All screen-shots are named exactly the same as their productID in the database, plus a prefix.
For example: Screen-shots of a product whose productID is 15 are found in the folder images, with the name 15_screen1.jpg, 15_screen2.jpg, etc...
In my ColdFusion page I have hard-coded the image path into the HTML (images/); the image name is broken into two parts; part one is dynamically generated using the productID from the query; and part two is a prefix, and is hard-coded. For example:
<img src"/images/#QueryName.productID#_screen1.jpg">
<img src"/images/#QueryName.productID#_screen2.jpg"> etc...
This method works, but it has several limitations the biggest listed bellow:
I have to hard-code the exact number of screen-shots in my HTML template. This means the number of screen shots I can display will always be the same. This does not work if one product has 10 screen shots, and another has 5.
I have to hard-code image prefixes into my HTML. For example, I can have up to five types of screen-shots associated with one product: productID=15 may have 15_screen1.jpg, 15_screen2.jpg, and 15_FrontCover.jpg, 15_BackCover.jpg, and 15_Backthumb.jpg, etc...
I thought about creating a paths column in my products table, but that meant creating several hundreds of folders for each product, something that also does not seem efficient.
Does anyone have any suggestions or ideas on the correct method to approach this problem?
Many thanks!
How about...
use an Image table, one product to many images (with optional sortOrder column?), and use imageID as the jpeg file name?
update:
Have a ImageClass table, many Image to one ImageClass.
Image
-----
ID
productID
imageClassID (FK to ImageClass)
Use back-end business logic to enforce the some classes can only have one image.
Or... if you really want to enforce some classes can only one image, then can go for a more complex design:
Product
------
ID
name
...
frontCoverImageID
backCoverImageID
frontThumbImageID
backThumbImageID
Image
-----
ID
productID
isScreenShot (bit) // optional, but easier to query later...
However, I like the first one better since you can have as many classes you see fit later, without refactoring the DB.
Keeping information on how many and what images in the database is definitely the way to go.
Barring that, if you want to use naming conventions to associate images with products, and the number of images is arbitrary, then it's probably a better idea to create one folder per product:
/images/products/{SKU1}/frontview.jpg
/images/products/{SKU1}/sideview.jpg
/images/products/{SKU2}/frontview.jpg
and so forth. Then use <cfdirectory> to collect the images for a given product. You might also want to name your images 00_frontview.jpg, 01_sideview.jpg and such so that you can sort and control what order they'll display on the page.
use the cfdirectory tags to inspect the filesystem:
<!--- get a query resultset of images in filesystem --->
<cfdirectory action="list" name="images" directory="images">
<!--- get images for specific product --->
<cfquery name="productImages" dbtype="query">
select *
from images
where name like '#productid#%'
</cfquery>
<cfoutput query="productImages">
<img src="#productimages.directory#/#productimages.name#" />
</cfoutput>
You could even try using the filter attribute to cfdirectory to try and omit the QoQ