Solved

How to do the dropdown with previos and next functionalities ?

Posted on 2010-09-11
10
557 Views
Last Modified: 2013-11-24
How to create custom component in dorpdown ? requirment is dropdown with next and previous functionalities.

dropdown have list, we choose the list as well using next and previous button choose list from drop down.

this is jsf dropdown , how to implement the next and previous functions in the dorpdown.

(previous)<   (dropdown)    >(next)  

dropdown.JPG
0
Comment
Question by:Rose_Taylor
  • 4
  • 4
  • 2
10 Comments
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 33655874
I have question here ?
if user press next button means what will happen ??
next value in the dropdown value will populate or ??
example i think ...
950612135195
950612135196
950612135197
 if i press next means you want to populate 950612135197 value correct ??  
0
 
LVL 20

Assisted Solution

by:Sathish David Kumar N
Sathish David  Kumar N earned 100 total points
ID: 33655883
use javascript while click next nutton
u can call some funtion
you can get the value of dropdown and add the one more value one set the value in drop down ! thats it ...
 
0
 

Author Comment

by:Rose_Taylor
ID: 33658324
Your correct, but this logic can able to do in the java ?
0
 

Author Comment

by:Rose_Taylor
ID: 33658328
I am using JSF so here i am having event handling method.So need the logic for next and previous values in the dropdown.
0
 
LVL 3

Expert Comment

by:prakash_parvath
ID: 33659897
Hi Rose

Hope this works,


YourJSP

<%
FacesContext myJSFContext = FacesContext.getCurrentInstance();
NamingContainerComponent component = new NamingContainerComponent();
String namingSpaceId = component.getClientId(myJSFContext);	

%>



<script>
var index=0;
var namingSpaceId = "<%=namingSpaceId %>"; 
onclickNext(){
index=index+1;
// You can have conditions to prevent next, previous based on max availability of items in dropdown

var selObj = document.getElementById(namingSpaceId+':yourform:YourDropDown');
	selObj.selectedIndex = index;

}

</script>

<jsf-naming:namingContainer id="myJSFContainer">

<h:form id="yourform" ...>
<h:selectOneMenu id="yourDropDown" ...
></h:selectOneMenu>
</h:form>

</jsf-naming:namingContainer>

Open in new window

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 3

Expert Comment

by:prakash_parvath
ID: 33659902
all you have to do is create two links next, previous and link the above JavaScript method to next, and create / reuse the method for Previous but with an index=index-1

and also you can put some if condition to not to exceed your list size.

Hope this helps
0
 

Author Comment

by:Rose_Taylor
ID: 33678913
Is it possiable to do in java ?
0
 
LVL 3

Expert Comment

by:prakash_parvath
ID: 33679452
Yes, you can do it in java (JSF) using RichFaces / A4J . in that case an ajax call is sent to the server and your components prev, next links, dropdown will update the state after ajax response.

in the background it still works based on JavaScript (generated by A4J / Richfaces) , the above solution is bit complex comphared the one with simple custom JS.

share your thoughts !
0
 
LVL 3

Accepted Solution

by:
prakash_parvath earned 400 total points
ID: 33679459
and also please note that above solution may need you to add additional libraries to your application
-jars and dependencies for A4J / RichFaces
0
 

Author Closing Comment

by:Rose_Taylor
ID: 34294824
good
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mergeTwo  challenge 13 72
for i loop in grovy 1 32
Unable to start eclipse ? 17 86
JList custom Cell Renderer refresh 15 43
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now