Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

displaying parent and child images from database based on roleid

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 74371
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am afraid I can’t understand the problem from the few details you have supplied.
 
niks singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the parent_id link to? are you asking for help with the sql for the select?
 
niks singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are you writing a web application or a swing/awt. as you mentioned javascript?
 
niks singh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya web app

any solution???
 
Wendy L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic