How to access list box variable in jsp
hi.......I'm new to jsp ...pls help me with the following.....i've created a form with some list boxes ,text boxes and radio buttons.....now i need to access the variables of these elements in order to validate and display them.....what is the syntax in jsp for accessing the list box variable(or txt box or radio button)
tnx in advance.....
You normally use a Servlet class for this. You can get request parameters by HttpServletRequest#getParameter() or #getParameterValues() then.
This is fairly trivial though. Please go through a decent JSP/Servlet book/tutorial first.
Similar Messages
-
How to access the hidden variable in jsp
hi all,
i need help to know how to access the hidden variable in the same jsp.
Following is the code snippet just have a look at that.
ArrayList arrRankingSummary = (java.util.ArrayList)session.getAttribute("arrRankingSummary");
<logic:iterate id="rankingSummary" name="arrRankingSummary">
<input type="hidden" name="allApplicantID" value='<bean:write name="rankingSummary" property="APPLICANTID"/>' />
<input type="hidden" name="allAdmissionRank" value='<bean:write name="rankingSummary" property="ADMISSIONRANK"/>' />
</logic:iterate>
<input type="hidden" name="applicantID" value='<bean:write name="rankingSummary" property="APPLICANTID"/>' />
<TD align=center><Input type=Text name="admissionRank" class=Textverysmall size=2 value='<bean:write name="rankingSummary" property="ADMISSIONRANK"/>' maxlength="10" /> </TD>
I want to remove the element from arraylist on these condition
if(allApplicantID.value ==applicantID.value){
arrRankingSummary .remove("admissionRank");
Now the pbm is i m not getting how to access the hidden variable in jsp or how to use the values of hidden variable for the condition.
Pls help me out.
Thanks in adv.
Regards,
Rituhi ram,
as i mentioned i m creating hidden variables & i m doing some validation on form submit.
The following is js code snippet for validation.
for (var i = 0; i < document.forms[0].admissionRank.length; i++)
admissionRank = document.forms[0].admissionRank.value;
for(var j = 0; j < document.forms[0].allAdmissionRank.length; j++)
//alert ("admissionRank : " + admissionRank + " document.forms[0].allAdmissionRank[" + j + "].value : " + document.forms[0].allAdmissionRank[j].value + "\ndocument.forms[0].allApplicantID[" + j + "].value : " + document.forms[0].allApplicantID[j].value + " document.forms[0].applicantID[" + i + "].value : " + document.forms[0].applicantID[i].value);
if(admissionRank == document.forms[0].allAdmissionRank[j].value && document.forms[0].allApplicantID[j].value != document.forms[0].applicantID[i].value && admissionRank != "" && document.forms[0].allAdmissionRank[j].value != "")
flag = false;
document.forms[0].admissionRank[i].focus();
document.forms[0].admissionRank[i].select();
break;
if (flag == false)
break;
In this validation i want admissionRank to be removed from the original arraylist if following condition gets satisfied
"(document.forms[0].allApplicantID[j].value == document.forms[0].applicantID[i].value )"
Thanks in adv
Ritu -
How can I assign javascript variables to jsp or java variables.?
How can I assign javascript variables to jsp or java variables.?
See I have generated some variables in the javascript which is on the jsp page. I want to assgin these variables to the jsp vaiables. Or how can I access javascript variables from jsp on the same jsp page.
-
How to populate list box in module pool program
How to populate list box in module pool program.
Please give me reply as soon as posible
regards,
Venu.hi,
go thrugh the folling code .
TABLES sdyn_conn.
DATA ok_code TYPE sy-ucomm.
Global data
TYPES: BEGIN OF type_carrid,
carrid type spfli-carrid,
carrname type scarr-carrname,
END OF type_carrid.
DATA itab_carrid TYPE STANDARD TABLE OF type_carrid.
*& Processing Blocks called by the Runtime Environment *
Event Block START-OF-SELECTION
START-OF-SELECTION.
CALL SCREEN 100.
Dialog Module PBO
MODULE status_0100 OUTPUT.
SET PF-STATUS 'SCREEN_100'.
ENDMODULE.
Dialog Modules PAI
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'SELECTED'.
MESSAGE i888(sabapdocu) WITH sdyn_conn-carrid.
ENDCASE.
ENDMODULE.
Dialog Module POV
MODULE create_dropdown_box INPUT.
SELECT carrid carrname
FROM scarr
INTO CORRESPONDING FIELDS OF TABLE itab_carrid.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'CARRID'
value_org = 'S'
TABLES
value_tab = itab_carrid
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
ENDMODULE.
the following code should be included in flow logic of screen
process on value-request.
field scarr-carrname module create_dropdown_box.
in module pool select list box.
hope it is useful.
regards,
sreelakshmi. -
How to apply List box for multiple selection of rows in ALV report ?
Hi Exprots,
1: How to apply List box for multiple selection of rows in ALV report ?
Thanking you.
Subashhi,
check the below program.
REPORT zalv_dropdowns.
*Type pools declarations for ALV
TYPE-POOLS : slis.
*data declarations for ALV container,ALV grid, Fieldcatalogues & layout
DATA: g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo.*INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
wa_outtab TYPE t517a.
START-OF-SELECTION.*Call to ALV
CALL SCREEN 600.*On this statement double click it takes you to the screen painter SE51.
*Create a Custom container and name it CCONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.
PBO of the actual screen , Here we can give a title and customized menus
Here we also call the subroutine for ALV output.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
PERFORM alv_output.
ENDMODULE. "pbo OUTPUT
MODULE PAI INPUT *
MODULE pai INPUT.
ENDMODULE. "pai INPUT
*& Form BUILD_FIELDCAT
FORM build_fieldcat.
DATA ls_fcat TYPE lvc_s_fcat.
*Build the field catalogue
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'T517A'
CHANGING
ct_fieldcat = gt_fieldcat.
To assign dropdown in the fieldcataogue
LOOP AT gt_fieldcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'SLART'.
*is the first list box
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
is the second list box
WHEN 'ABART'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
ENDCASE.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form ALV_OUTPUT
FORM alv_output .*Create object for container
CREATE OBJECT g_custom_container
EXPORTING container_name = 'CCONT'.
*create object for grid
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
Build fieldcat and set column
*Assign a handle for the dropdown listbox.
PERFORM build_fieldcat.
*Build layout
PERFORM build_layout.
Define a drop down table.
PERFORM dropdown_table.
*fetch values from the T517A table
SELECT * FROM t517a INTO TABLE gt_outtab.
*Display ALV output
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab.ENDFORM. "ALV_OUTPUT
*& Form dropdown_table
text
--> p1 text
<-- p2 text
FORM dropdown_table.*Declarations for drop down lists in ALV.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
First SLART listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = '01 Primary school'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '1'.
ls_dropdown-value = '02 Lower Secondary'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '1'.
ls_dropdown-value = '03 Upper Secondary'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '04 Professional School'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '05 College'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '06 University'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '09 Other Establishment'.
APPEND ls_dropdown TO lt_dropdown.* Second ABART listbox (handle '2'). ls_dropdown-handle = '2'.
ls_dropdown-value = '10 Primary School certificate'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '20 Lower secondary/Junior high'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '30 High school diploma(B-levels)'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '2'.
ls_dropdown-value = '31 Vocational'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '32 Matriculation'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '40 Specialist vocational certificate'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '50 College degree Level1'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '51 College degree Level2'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '52 Masters degree'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '60 Univ Degree level1'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '61 Bachelors degree'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '62 Masters degree'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '63 Licenciate'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '64 Doctors Degree Ph.D'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '89 None'.
APPEND ls_dropdown TO lt_dropdown. ls_dropdown-handle = '2'.
ls_dropdown-value = '90 Unknown'.
APPEND ls_dropdown TO lt_dropdown.*method to display the dropdown in ALV
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.ENDFORM. " dropdown_table
*& Form build_layout
text
*layout for ALV output
FORM build_layout . gs_layout-cwidth_opt = 'X'.
gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
gs_layout-no_toolbar = 'X'.ENDFORM. " build_layout
endform.
Edited by: S.r.v.r.Kumar on Jun 1, 2009 2:48 PM -
How to use list box parameter in crystal Reports
Hi Experts,
How to acheive list box parameter in sap B1 crystal reports.
Regards
VinothHi,
check this thread
Crystal Report Drop Down Selection List
Drop down list parameter
https://scn.sap.com/thread/1782598 -
How to access a javascript variable from Java?
Here is my code:
function validateLoginForm() {
var username = document.getElementById('un');
setCookie('un', username, 3650);
//etc.
<%
HttpSession httpSession = request.getSession();
httpSession.setMaxInactiveInterval(30 * 60); //30 minutes
httpSession.setAttribute("un", username); //!prob here - cannot resolve 'username'
%>
}...but how do I access the javascript variable 'username' from the Java code?
Thanks,
JamesThe only way to pass values between JavaScript and JSP is through cookies. It sucks, I know, but right now that is the only option.
You already are creating a cookie in JavaScript. So go ahead and read it in Java:
Cookie[] cookies = request.getCookies();
for(int i = 0; i < cookies.length; i++) {
Cookie c = cookies;
if (c.getName().equals("un")) {
// Do what you need here. -
Handling List box element in JSP
Hi,
I have a List box which gets populated on the client side, depending on the user's activity on a form, when i finally submit the form, i want the list box with all the values to go to the server, Can anyone help me with the code on the server-side (JSP Scriplet) about how i can do this?
Thanks
VaradarajAssuming that by list box, you mean an HTML element using <select ...> tag,...
Only the currently selected values get submitted to the server. If thatis where you got kind of stuck. -
How to access a session variable just before rendering a JSF page???
Dear Sirs...
i am using jdeveloper 10.1.3.2 with JSF and ADF faces. i want to access a session variable and perform some processing just before rendering a page. how can i achieve this????
i am a little new to jsf, so i feel a little lost
thanks for any help in advance, and best regards<p>
Hi,
</p>
<p>
See example 60 "<strong>Triggering OnPageLoad-Style Code in a JSF Backing Bean Using ADF PagePhaseListener or PageController</strong>" on Steve's Muench blog.
</p>
<p>
Kuba
</p> -
How to access the int variable in the inner class
hi all,
i can't access the int variable in the inner class. can any one help me
int count = 0;
MouseMoveListener mouseMove = new MouseMoveListener() {
public void mouseMove(MouseEvent e) {
count1++;
System.out.println(count);
};how to access count variable
thanksfor this how can i access the countIf the count variable is a local variable you can't access it from within the
inner class. Make it a member variable of the outer class instead:public class Outer {
private int count;
MouseMoveListener mouseMove= new MouseMoveListener() {
public void mouseMove(MouseEvent me) {
count++;
System.out.println(count);
}Alternatively, if you don't need that count variable anywhere else, you
could simply make it a member variable of the inner class itself:public class Outer {
MouseMoveListener mouseMove= new MouseMoveListener() {
private int count;
public void mouseMove(MouseEvent me) {
count++;
System.out.println(count);
}kind regards,
Jos -
Accessing list-backed properties in JSP
Hello guys,
I am trying to generate a dynamic form using the list-backed properties following the guide in
http://struts.apache.org/struts-action/userGuide/building_controller.html#map_action_form_classes
It works as a map but can't make it work as a list
here is my jsp
<html:form action ="/addTemplate.do">
<%List attributesList = (List) request.getAttribute("attributesList");
Integer count = new Integer(attributesList.size());
session.setAttribute("count", count);
session.setAttribute("attributesList", attributesList);
for (int i = 0; i <= count; i++) {
String name = "value(addTemplate-" + i + ")";
%>
<!--make a list-->
Attribute<%=i%>
<html:text property="<%= name %>"/>
<br/>
<%}%>
<html:submit/>
</html:form>and my bean
public class AddTemplateForm extends ActionForm {
private final Map values = new HashMap();
public void setValue(String key, Object value) {
values.put(key, value);
public Object getValue(String key) {
return values.get(key);
}when I am trying to use a list , obviously modifying the bean and my jsp to
String name = "value[" + i + ")";I am getting
javax.servlet.ServletException: Exception thrown by getter for property value[0] of bean org.apache.struts.taglib.html.BEANusing a map I don;t really know how to get the properties values in the Action class
Any help is appreciatedtry this.
<html:select property="selectedCountries" multiple="true" size="4">
<html:optionsCollection property="availableCountries" label="name" value="id">
</html:select>
public OptionsRecord
// make corresponding setters and getters
private String name;
private String id;
// constructor
public OptionsRecord(String nm, String idd)
name = nm;
id = idd;
----- Form class ----
public TestForm extends ActionForm
// make setters and getters for the following.
private String[] selectedCountries = new String[0];
private Collection availableCountries = new LinkedList();
init()
availableCountries.add(new OptionsRecord("Australia", "001"));
availableCountries.add(new OptionsRecord("Burma", "002"));
availableCountries.add(new OptionsRecord("USA", "003"));
Don't forget to reset selectedCountries to a new object.
----- -
JSP: How do display list of objects in jsp table?
sorry that my question my confuse you, let me explain more.
in my java class, have method : public List retrieveAllVacancies(); and it returns a list of available vacancies.
on my jsp page, i want to display the vicancies in the table have 3 rows:
vacancy title | location | contract type
should i use some form of for loop or iterator to get the vacancies in the list? how does the jsp page get the list of objects?
anyone can help me? thanksi found out the actual thing i look for is how to pass the vector to the jsp page.
<table>
<%
Vacancy vacancy= new Vacancy();
Vector allVacancies = new Vector();
*//allVacancies = (java.util.Vector)request.getAttribute("allVacancies");*
if(allVacancies.size() == 0)
out.print("<br><br><br> There are no vacancies available!!");
else
%>
<tr>
<td>Vacancy Title</td>
<td>Contract Type</td>
<td>Location</td>
</tr>
<%
for (int i=0;i<allVacancies.size();i++)
vacancy = (Vacancy)allVacancies.get(i);
%>
<tr>
<td><% out.print(vacancy.getVacancyTitle());%></td>
<td><% out.print(vacancy.getContractType());%></td>
<td><% out.print(vacancy.getVacancyLocation()); %></td>
</tr>
<%
%>
</table>*//allVacancies = (java.util.Vector)request.getAttribute("allVacancies");*
if i have this line, when i open the jsp page it will gives NullPoniterException.
the following was what i found for the similar problem,
You can add the Vector to the HttpSession with_
session.setAttribute(String name, Object value)_
or to the ServletRequest with_
request.setAttribute(String name, Object value)._
In the other JSP, retrieve the value with_
session.getAttribute(String name)_
or to the ServletRequest with_
request.getAttribute(String name)._
but i tried to do in this way it didn't work. for sure i didn't do it correctly. could anybody give bit more explanation about how to pass the Vector to the jsp page?
any help would be appreciated. -
Hi gurus
I have set list box value through vrm_set_value and in the screen level it's working fine
In the custom program I need to fetch data from table using that selected list box value , but its always coming blank .
please help me how to catch that list box value in the program .
ThanksThis is the code
*************SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS : P_bukrs TYPE bukrs OBLIGATORY , " Company Code
p_psc TYPE psc_name OBLIGATORY ,
p_monat TYPE MONAT AS LISTBOX VISIBLE LENGTH 5 OBLIGATORY , " Quarter
p_gjahr TYPE gjahr DEFAULT sy-datum+0(4) OBLIGATORY . " Year
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS : P_KIND AS CHECKBOX USER-COMMAND abc , " Check Box
P_prcent(6) TYPE P DECIMALS c_val_three , " Take in kind percentage
p_prod TYPE PSA_PRODUCT AS LISTBOX VISIBLE LENGTH 10 . " Take in kind product
SELECTION-SCREEN END OF BLOCK b2.
A T S E L E C T I O N S C R E E N *
AT SELECTION-SCREEN on BLOCK b1 .
Validate Company Codes.
PERFORM sub_validate_com_code.
Validate PSC
AT SELECTION-SCREEN on VALUE-REQUEST FOR p_psc .
PERFORM sub_validate_psc.
Validate Quarter
PERFORM sub_validate_quarter .
AT SELECTION-SCREEN on BLOCK b2 .
Validate Take in kind percentage
PERFORM sub_validate_percnt .
Validate Take in kind Percentage
PERFORM sub_prod_disp .
form sub_prod_disp .
populated internal table lt_prod_val .
LOOP AT SCREEN.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'p_prod'
values = lt_prod_val
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
in start of selection the p_prod is always coming initial . -
How to Create a Session variable in JSP?
How to create a session variable and add attributes to it?
For example i want to create a session variable called "name" and add value "user" to it? if i try to do it with setAttribute(), it is giving error as both is of type string? how to do it? kindly help meThis is variable what is working in my aplication
String variable;
if(user == null){
user=new String("");
}//if you don'y do this you will have null pointer exception
session.setAttribute("user",user);//put value
String name=(String)session.getAttribu("user"); //get value;
I hope this will help -
How to find list box field from recording
Dear All,
My requirement is to close all POs whose delivery date is overdue by 6 months. this can be accomplished by setting the delivery indicator in ME22N. I want to do this by BDC.
I have the list of all purchase doc numbers and item numbers whose delivery date satisfies the condition given.
Through Recording I want to find the fields getting effected. The delivery inidcator has to be set automatically by choosing the appropriate item from the dropdown list box. Choosing th eitem from dropdon list box was not found by me. Can anybody help me in this regard? Its very urgent. Thanks in advanceHi,
Here is the sample code.
TYPE-POOLS: vrm.
DATA: name TYPE vrm_id,
list TYPE vrm_values,
value LIKE LINE OF list.
PARAMETERS: ps_parm(10) AS LISTBOX VISIBLE LENGTH 10.
AT SELECTION-SCREEN OUTPUT.
name = 'PS_PARM'.
value-key = 'Line 1'.
value-text = 'Line 1'.
APPEND value TO list.
value-key = 'Line 2'.
value-text = 'Line 2'.
APPEND value TO list.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING id = name
values = list.
START-OF-SELECTION.
WRITE: / 'Parameter selected in List box:', ps_parm.
Kindly reward points if it helps.
Maybe you are looking for
-
Tuner not working on my TouchSmart 300
Situation: Brand new TouchSmart with tuner not working out of the box. Driver appears to be installed and working, but tuner will not pick up any channels. Both ATSC(antenna) and NTSC(converter box used) were scanned and nothing picked up in either
-
Error ORA12154 Database in NT and Linux
I did not connected with my client WindowsNT with Oracle on linux. My NT is 4.0 (Oracle 805NT) and My linux RH5.2 (Oracle 805). I try connect NT in Linux and occur this error: ORA 12154 TNS: could not resolve this service name Thanks for all help. Gh
-
Infopackages missing in BI content
I am installing BI content for BIW 7.0. Many times I get a list of errors saying that 0PAK************* infopackage object not available. Or some times I get an error saying process variant not found. What do I do? should I go ahead with installation
-
Hi, I installeed 11.2g and when I try login I have got error TNS error adapter. My file tnsname # tnsnames.ora Network Configuration File: F:\app\Mariano\product\11.2.0\dbhome_1\network\admin\tnsnames.ora # Generated by Oracle configuration tools. OR
-
Help finding OS-level database object names
Hello all... I need to perform an online reorganization of some tables on my QAS system. However, some of the tables have more than 8 characters on SAP and I need to know what's the corresponding object name on the database library at OS level, so I