File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes displaying parent and child images from database based on roleid Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "displaying parent and child images from database based on roleid" Watch "displaying parent and child images from database based on roleid" New topic
Author

displaying parent and child images from database based on roleid

niks singh
Greenhorn

Joined: Dec 25, 2011
Posts: 16
Hii

I successfully display the parent and child images from database based on the role id but it doesn work for every role id. I am stuck here like i do not know how do I check for every roleid which are the images permitted to him. my logic somehow doesnt work here. kindly suggest what logic do i use here. I am also using javascript in which i write the code to display a particular window on clicking of a particular image. please help
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 26716
I am afraid I can’t understand the problem from the few details you have supplied.
niks singh
Greenhorn

Joined: Dec 25, 2011
Posts: 16
Ok il try to explain it in more detail.

I am suppose to display some icons/images whom i refer as menu here whose path i have stored in my database.

I have 3 tables in my database.

first table is the menu table. this stores my,menu_id(primary key),menu names, parent_id and the icon path.

second table is the role table which stores role_id(primary key) and the role names.

third table is menu_role_mapping table which has map_id(primary key), menu_id(foreign key) referencing the menu table and role_id( foreign key) referencing the role table.

I ask the user to enter his role_id and accordingly i have to display the icons(whichever icons/images is assigned to that particular role_id in mapping table).

also I have to take care of the child images if any.

so please help me with the logic part to succesfully display the parent and child images based on the roleid from the database.

Hope I am able to convey the problem clearly.

Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 774

what is the parent_id link to? are you asking for help with the sql for the select?
niks singh
Greenhorn

Joined: Dec 25, 2011
Posts: 16
parent_id column actully stores the menu_id which specifies the parent child relation.

that is if any menu has the corresponding parent_id as 2 that means it is a child of the menu with menu_id 2.

my sql query is working fine

it gives me the list of the all the menus assigned for a particular roleid

and using that list i have to display the icons accordingly which I am already doing.

till here everything is working fine.

but after displaying the icons if a user clicks on any particular icon, a particular window is to be displayed(I am getting stuck here).

there are different windows for different icons and each window has its separate id.

so how do i do this in javascript or any other way.





Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 774

are you writing a web application or a swing/awt. as you mentioned javascript?
niks singh
Greenhorn

Joined: Dec 25, 2011
Posts: 16
ya web app

any solution???
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 774

ok so now we know what the problem is... what have you tried so far?

or have you only got as far as drawing the images on the screen?
niks singh
Greenhorn

Joined: Dec 25, 2011
Posts: 16
I can succesfully display the icons based o the role id.

after dat wen i clik on any icon all the windows of all the icons get displayed at once.

and i want only particular window to be displayed on clik of a particular icon

niks singh
Greenhorn

Joined: Dec 25, 2011
Posts: 16
following is my java script code where i check for the icon by its id which is generated while i display it and after cheking i write the code to display the window.

but i have to chek it by hard coded path...which will make the code too lengthy if there are more icons added to my database.


is der some oder way to check and display accordingly



<SCRIPT type=text/javascript>




$(document).ready(function() {



//for parent menus
<%
int a=0;
while(a<size){
a++;
%>
$("#imageId<%=a%>").click(function(){
//alert("hello");

if($(this).attr("src")=="images/searchlnk.png" ){

$("#search").slideToggle("slow"); //window with id search will toggle
}

if($(this).attr("src")=="images/mnagelnk.png" ){

$(".managedivhid").slideToggle("slow"); //window with class managedivhid will toggle
}



if($(this).attr("src")=="images/reportlnk.png" ){

$("#rep").slideToggle("slow"); //window with id rep will toggle
}


});

<%}%>

//for child images
<%
int b=0;
while(b<size){
b++;
%>
$("#img<%=b%>").click(function(){
//alert("hiii");
if($(this).attr("src")=="images/custolnk.png" ){
$("#custo").slideToggle("slow"); //window with id custo will toggle

}

if($(this).attr("src")=="images/contink.png" ){
$("#content").slideToggle("slow"); //window with id content will toggle
}


if($(this).attr("src")=="images/branchlnk.png" ){
$("#branch").slideToggle("slow"); //window with id branch will toggle
}


});

<%}%>


Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 774

sorry, i don't actually know javascript, i am sure a moderator will move you to the appropriate thread, but you need to use code tags around that javascript
makes it much easier for everyone else to read.

highlight and press the code button
 
 
subject: displaying parent and child images from database based on roleid
 
Threads others viewed
Hibernate:Eager fetching
How to implement role based access previleges
Datable Problem !
Child window to Parent window
Dynamic dataTable Using JSF
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com