How to get the property name of a srop down menu in the Actiion Class
Hi All!
I am trying to build two drop down menu in the jsp!When the page first loads the first menu is populated with the data from the database.Depending on the choise made in the first menu the second gets populated!
As of now I am using these codes!
The JSP contains:
function getCorrespondingSkills(obj)
document.forms[0].target="_self";
document.forms[0].action='<%=request.getContextPath()%>/jsp/resume/Skill.do?method=getSkillsList&technologyId='+obj.value+'&selectedField='+obj.property;
document.forms[0].submit();
function submitTechSkills(obj)
document.forms[0].target="_self";
document.forms[0].action='<%=request.getContextPath()%>/jsp/resume/Skill.do?method=getSkillsValue&skillId='+obj.value;
//document.forms[0].submit();
<td class="brdrInput">
<%--<html:select name="SkillsForm" property="technologies1" onchange='getCorrespondingSkills(this)'>--%>
<html:select name="SkillsForm" property="technologies1"onchange='getCorrespondingSkills(this)'>
<html:optionsCollection property="technologyList" value="technologyId" label="technology" />
</html:select>
</td>
<td class="brdrInput">
<html:select name="SkillsForm" property="skills1"onchange='submitTechSkills(this)' >
<html:optionsCollection property="skillList" value="skillId" label="skill" />
</html:select>
</td>The action class is something like this:
public ActionForward unspecified(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
HttpSession session=request.getSession();
String str=(String)session.getAttribute("employeeId");
System.out.println("this is the employeeId"+str);
SkillsForm formObject=(SkillsForm)form;
List technologyList;
technologyList=(List)TechnologyDelegate.getTechnologyFromDB();
for (Iterator iter = technologyList.iterator(); iter.hasNext();) {
Technology tech= (Technology) iter.next();
System.out.println("Technology"+tech.getTechnology());
System.out.println("TechnologyId"+tech.getTechnologyId());
formObject.setTechnologyList(technologyList);
//Populate a Skills drop menu corresponding to the first technologyId
int var=1;
Integer var1=new Integer(var);
List skillsList;
skillsList=(List)SkillsDelegate.getSkillFromDB(var1);
formObject.setSkillList(skillsList);
System.out.println("associated Skills"+formObject.getSkillList().size());
System.out.println("=============>");
session.setAttribute("employeeId",str);
return mapping.findForward("skillsPopulation");
public ActionForward getSkillsList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
HttpSession session=request.getSession();
SkillsForm formObject=(SkillsForm)form;
List technologyList;
technologyList=(List)TechnologyDelegate.getTechnologyFromDB();
for (Iterator iter = technologyList.iterator(); iter.hasNext();) {
Technology tech= (Technology) iter.next();
System.out.println("Technology"+tech.getTechnology());
System.out.println("TechnologyId"+tech.getTechnologyId());
formObject.setTechnologyList(technologyList);
Integer techId=new Integer(formObject.getTechnologyId());
String technologyId=formObject.getTechnologyId();
List skillsList;
skillsList=(List)SkillsDelegate.getSkillFromDB(techId);
//All the skillList being set along with the one that has to be!
formObject.setSkillList(skillsList);
//the SkillLsit that is being used to populate the drop down is being reset
//every time a new technology is set!
//to overcome this we need to define seperate SkillList for each row!
List var=formObject.getSkillList();
for (Iterator iter = var.iterator(); iter.hasNext();)
Skills vari= (Skills) iter.next();
System.out.println("SKILLS IDSFASDFGAGFG "+vari.getSkillId());
System.out.println("skillsList"+skillsList.size());
System.out.println("associated Skills"+formObject.getSkillList().size());
session.setAttribute("employeeId",session.getAttribute("employeeId"));
session.setAttribute("technologyList",technologyList);
session.setAttribute("technologyId",technologyId);
System.out.println("TECHNOLOGY ID"+technologyId);
System.out.println("TECHNOLOGY ID"+techId);
return mapping.findForward("refreshAgain");
}* The first function id used to populate the form with the first technology in the databse and its corresponding skills! The second function fetches the skills wrt the selected technology!
My prob is that when ever I change the technology in the dropdown My all skills menu gets populated with the skills associated with the selected technology!
I have 5 rows of such tech and skills columns! And the prob is that if I select tech inthe 2nd row then all the skills rows gets changed! all I want is that the 2nd row only be populated!
Is there a way in which I can know in my action class ,'which row has been selected'.
I am a newbie to Java and am just learning things!
Pls do help! I am desperate!!!!!!!1
So far as I'm aware, you can't get metadata information about the underlying tables in a query from Oracle and/or the Oracle drivers. I suspect, in fact, that the driver would have to have its own SQL parser to get this sort of information.
I'm curious though-- how do you have application logic that depends on the name of the source table but not know in the application what table is involved? Could you do something "cheesy" like
SELECT 'tbl_customerRegistration' AS tbl1_name,
tbl_customerRegistration.*
...Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
Similar Messages
-
How to get the object class field value in CDHDR table for vendor
hi
how to get the object class field value in CDHDR table for vendorTry KRED/KRED_N as object class in CDHDR for Vendor.
-
How to get all property names and values of an bean instance at runtime?
How can I get all property names and values of an bean instance at runtime?
(The class of the bean instance is dynamic and I can not know before I write the code .)Look at Class. It has a way to get at all public methods and attributes.
If you need to get to private attributes you can do what the Introspector does and expect the methods to follow the Bean pattern and pull the attributes out based upon that. Privates are all hidden from direct access but through the Bean Pattern they can be figured out. -
How to get the current class name in static method?
Hi,
I'd like to get the current class name in a static method. This class is intended to be extended. So I would expect that the subclass need not to override this method and at the runtime, the method can get the subclass name.
getClass() doesn't work, because it is not a static method.
I would suggest Java to make getClass() static. It makes sense.
But in the mean time, does anybody give an idea to work around it?
Thank you,
BillWhy not create an instance in a static method and use getClass() of the instance?
public class Test {
public static Class getClassName() {
return new Test().getClass(); -
How to get the root class in call heirarchy
Hi,
Is anybody have some idea regarding the getting name of a class whose, main method was called at the time of begining. In other words if we say, how can we get the invoker class of a java program with multiple level of inheritence.
RegardsDocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder db=factory.newDocumentBuilder();
Document doc=db.parse(new File(ur xml file"));
Element root=doc.getDocumentElement();
System.out.println("root "+root.getNodeName()); -
How to get permission list name by page wise or menu-wise
Hi,
I want to know that permission list associated to a specific page or menu. Please help me how to get thatCheck the following on the internet regarding the authorizedaction field, which contains the information you need.
http://peoplesoftwiki.blogspot.nl/2009/12/finding-barname-itemname-and-all-about.html
you mean to hide the PeopleTools menu? If so, mke sure (s)he does not have the permision list that grants the pemission you don't want him/her to have. -
How to get the child class in inheritance?
hi,
if I have a store for renting videos .. and I have Video class (parent) and two (child) classes DVD and Cassete which they are extend the video class.
And the user wants to rent a DVD which is the child, how do I do that? can I write just getDVD() as simple as that or maybe I need to use a keyword like "getinstance of DVD " or something I don't know how to do this.
class Video have attributes like title, date of production and director.
I'm not good in inheritance help please.
thanksgeorgemc wrote:
DrLaszloJamf wrote:
Post a SSCCE: http://mindprod.com/jgloss/sscce.html
You're not the boss of me ;-)Actually, I haven't stopped to count, but most of the time the poster never bothers to write a sample program. If fact, if I weren't such a softie, I would make that an absolute requirement for any further help. Too often, you are just shooting in the dark and 50 replies later the question is still vague. -
How to get the viewrow value by string
Using Jdev11.1.1.5.0-adfbc-ireport3.0.0
here i'll describe: what i did.
am using jsff(dynamic region) while hitting the af:tree nodes it will opens. ok fine
i had somevo with manually wroten query. and query is fine no problem with that
here i give sample not a original query
select * from sometable where acctid = :pacctidi drag and drop the pacctid from corresponding execute params vo as selectoncechoice
static vo
Data value - account payable , advance
Data Name - ap,ad
in that jsff
*page representation*
account type : account payable (ap) - select one choice type
advance (ad) - select one choice type
like this some select once choice and some inputs.
Run report - command button
.jsff code
<af:selectOneChoice value="#{bindings.ACCT_TYPE.inputValue}"
label="Account Type"
shortDesc="#{bindings.ACCT_TYPE.hints.tooltip}"
id="soc3" required="true"
autoSubmit="true"
binding="#{backingBeanScope.SUP1040V.soc3}"
valuePassThru="true"
valueChangeListener="#{backingBeanScope.SUP1040V.ValueChangeListener1}">
<f:selectItems value="#{bindings.ACCT_TYPE.items}" id="si3"/>
</af:selectOneChoice>
<af:commandToolbarButton text="Export in pdf" id="ctb2">
<af:fileDownloadActionListener method="#{backingBeanScope.SUP1040V.Report}"
/>
</af:commandToolbarButton>.java
//while hitting the button following logs are appeared i show it as commented format.
public void Report(FacesContext context, OutputStream out) throws IOException,Exception
FacesContext ctx = FacesContext.getCurrentInstance();
HttpServletRequest request =
(HttpServletRequest)ctx.getExternalContext().getRequest();
HttpServletResponse response =
(HttpServletResponse)ctx.getExternalContext().getResponse();
BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();
System.out.println("print binding" +bindings1 );
//while using sop i get this in my log : : print binding ReportsPageFragments_SUP1040VPageDef_WEB_INF_TaskFlows_SUP1040_V_TF_xml_SUP1040_V_TF
JUCtrlListBinding listBinding1 = (JUCtrlListBinding)bindings1.get("ACCT_TYPE");
System.out.println("print list bindings" +listBinding1 );
//while using sop i get this in my log : : print list bindings0
Object selectedValue1 = listBinding1.getSelectedValue();
System.out.println("print selected value" + selectedValue1);
//while using sop i get this in my log : : print selected valueViewRow [oracle.jbo.Key[AP ]]
request.setAttribute("ACCT_TYPE", //here i want the value "AP" in String );
if i use like this means
request.setAttribute("ACCT_TYPE", soc1.getValue() ); i get the index value.
i need the dataname "ap" so i go above method which say wrotes ...
request.getRequestDispatcher(response.encodeURL("/sup1040servlet")).forward(request,response);
System.out.println("hihihihih");
response.flushBuffer();
ctx.responseComplete();
public void ValueChangeListener1(ValueChangeEvent valueChangeEvent) {
// Add event code here...
String AcctType = valueChangeEvent.getNewValue().toString();
System.out.println("AcctType" + AcctType);
FacesContext contxt = FacesContext.getCurrentInstance();
valueChangeEvent.getComponent().processUpdates(contxt);
BindingContainer bindings1 =
BindingContext.getCurrent().getCurrentBindingsEntry();
// Get the sepecific list binding
JUCtrlListBinding listBinding1 =
(JUCtrlListBinding)bindings1.get("ACCT_TYPE");
// Get the value which is currently selected
Object selectedValue1 = listBinding1.getSelectedValue();
System.out.println(selectedValue1);
}if i get ap means my report runs. or else it will shows empty page.
how to get the viewrowimpl class value as string.
Edited by: ADF7 on Mar 24, 2012 7:27 AMADF7,
I'm not sure I understand what you are up to.
As far as I understand you want to get the display value instead of the index
I use this code
public void StatusChangedListener(ValueChangeEvent valueChangeEvent)
BindingContext lBindingContext = BindingContext.getCurrent();
BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry();
JUCtrlListBinding list = (JUCtrlListBinding) lBindingContainer.get("Status");
int newindex = (Integer) valueChangeEvent.getNewValue();
Object row = list.getDisplayData(); // Wichtig um die liste zu laden!!!!
Row lFromList = (Row) list.getValueFromList(newindex);
Object lAttribute = lFromList.getAttribute("Value");
String newVal = (String) lAttribute;
}to get the value from a selectOneChoice component...
Timo -
How to get the profile object in simple java class (Property accessor)
Hi All,
Please guide me how to get the profile object in simple java class (Property accessor) which is extending the RepositoryPropertyDescriptor.
I have one requirement where i need the profile object i.e i have store id which is tied to profile .so i need the profile object in the property accessor of the SKU item descriptor property, which is extending RepositoryPropertyDescriptor.
a.I dont have request object also to do request.resolvename.
b.It is not a component to create setter and getter.It is simple java class which is extending the RepositoryPropertyDescriptor.
Advance Thanks.Iam afraid you might run into synchronization issues with it. You are trying to get/set value of property of a sku repository item that is shared across various profiles.
Say one profile A called setPropertyValue("propertyName", value).Now another profile B accesses
getPropertyValue() {
super.getPropertyValue() // Chance of getting value set by Profile A.
// Perform logic
There is a chance that profile B getting the value set by Profile A and hence inconsistency.
How about doing this way??
Create PropertyDescriptor in Profile (i.e user item descriptor), pass the attribute CustomCatalogTools in userProfile.xml to that property.
<attribute name="catalogTools" value="atg.commerce.catalog.CustomCatalogTools"/>
getPropertyValue()
//You have Profile item descriptor and also storeId property value.
// Use CustomCatalogTools.findSku();
// Use storeId, profile repository item, sku repository item to perform the logic
Here user itemdescriptor getPropertyValue/setPropertyValue is always called by same profile and there is consistency.
-karthik -
How to get the Text name to pass in the parameter header in save_text
Hi,
I am trying to change the long text of operation for historical order by using the flat file.I am using the save_text to do this.I would like to know how to get the text name in order to pass the parameter header in save_text.
I went to the tcode iw62 to get the header information of the long text.300100000009200000001
i would like to know what this 1000000092 indicates and where is this value updated in the table so that i can link it thru the order no to get the link and pass it in the text_name.
can anyone help me out?
krishnanHi,
Your query is.
I went to the tcode iw62 to get the header information of the long text.300100000009200000001
i would like to know what this 1000000092 indicates
In above number
300 - Client
1000000092 - AUFPL - Routing number of operations in the order (You can fetch this from table HIVG)
00000001 - APLZL - General counter for order ( You can fetch this from table HIVG).
BR,
Vijay -
Dear Expert,
I have one requirement like to read the selected workset name in portal by the current user.I have read two documents regarding how to retrieve the PCD contents (iViews, Pages, Worksets and Roles) and its properties like Created by, Changed by, Last changed by and others using PCD API.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6112ecb7-0a01-0010-ef90-941c70c9e401?overridelayout=true
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/508baf88-9335-2d10-efa6-c6ad61e5fc4b?quicklink=index&overridelayout=true
But I am not able to understand how to get the specific name of the workset which is currently selected by the user.Can you please help me.
I am using portal 7.0.
Thanks & Regards,
PatralekhaHi Expert,
I found that we can use Interface INavigationHelperService to read Portal Role selected by user at runtime from http://scn.sap.com/thread/52194
But this class is available in SAP NetWeaver 7.30 Enterprise Portal .
But in SAP NetWeaver 7.0 Enterprise Portal that interface is not available.
INavigationService is available there.
But didn't get any proper discussion on this interface for the same requirement.
Can you please help me.
Thanks & Regards,
Patralekha -
How to get the current schema name
Hi,
Can anybody please tell me how to get the current schema name, there is some inbuilt function for this,but i am not getting that. Please help me.
Thanks
Jogeshok folks, I found the answer at Tom's as usual.
http://asktom.oracle.com/tkyte/who_called_me/index.html
I rewrote it into a function for kicks. just pass the results of DBMS_UTILITY.FORMAT_CALL_STACK to this function and you will get back the owner of the code making the call as well some extra goodies like the name of the code and the type of code depending on the parameter. This ignores the AUTHID CURRENT_USER issues which muddles the schemaid. Quick question, does the average user always have access to DBMS_UTILITY.FORMAT_CALL_STACK or does this get locked down on some systems?
cheers,
paul
create or replace
FUNCTION SELF_EXAM (
p_call_stack VARCHAR2,
p_type VARCHAR2 DEFAULT 'SCHEMA'
) RETURN VARCHAR2
AS
str_stack VARCHAR2(4000);
int_n PLS_INTEGER;
str_line VARCHAR2(255);
found_stack BOOLEAN DEFAULT FALSE;
int_cnt PLS_INTEGER := 0;
str_caller VARCHAR2(30);
str_name VARCHAR2(30);
str_owner VARCHAR2(30);
str_type VARCHAR2(30);
BEGIN
str_stack := p_call_stack;
-- Loop through each line of the call stack
LOOP
int_n := INSTR( str_stack, chr(10) );
EXIT WHEN int_cnt = 3 OR int_n IS NULL OR int_n = 0;
-- get the line
str_line := SUBSTR( str_stack, 1, int_n - 1 );
-- remove the line from the stack str
str_stack := substr( str_stack, int_n + 1 );
IF NOT found_stack
THEN
IF str_line like '%handle%number%name%'
THEN
found_stack := TRUE;
END IF;
ELSE
int_cnt := int_cnt + 1;
-- cnt = 1 is ME
-- cnt = 2 is MY Caller
-- cnt = 3 is Their Caller
IF int_cnt = 1
THEN
str_line := SUBSTR( str_line, 22 );
dbms_output.put_line('->' || str_line);
IF str_line LIKE 'pr%'
THEN
int_n := LENGTH('procedure ');
ELSIF str_line LIKE 'fun%'
THEN
int_n := LENGTH('function ');
ELSIF str_line LIKE 'package body%'
THEN
int_n := LENGTH('package body ');
ELSIF str_line LIKE 'pack%'
THEN
int_n := LENGTH('package ');
ELSIF str_line LIKE 'anonymous%'
THEN
int_n := LENGTH('anonymous block ');
ELSE
int_n := null;
END IF;
IF int_n IS NOT NULL
THEN
str_type := LTRIM(RTRIM(UPPER(SUBSTR( str_line, 1, int_n - 1 ))));
ELSE
str_type := 'TRIGGER';
END IF;
str_line := SUBSTR( str_line, NVL(int_n,1) );
int_n := INSTR( str_line, '.' );
str_owner := LTRIM(RTRIM(SUBSTR( str_line, 1, int_n - 1 )));
str_name := LTRIM(RTRIM(SUBSTR( str_line, int_n + 1 )));
END IF;
END IF;
END LOOP;
IF UPPER(p_type) = 'NAME'
THEN
RETURN str_name;
ELSIF UPPER(p_type) = 'SCHEMA.NAME'
OR UPPER(p_type) = 'OWNER.NAME'
THEN
RETURN str_owner || '.' || str_name;
ELSIF UPPER(p_type) = 'TYPE'
THEN
RETURN str_type;
ELSE
RETURN str_owner;
END IF;
END SELF_EXAM; -
How to get the current function name in java
How to get the current function name in java.
In c it is done as
printf("%s",__func__);
Thanx in advance.j0o wrote:
System.out.println("Class Name: " + new Exception().getStackTrace()[0].getClassName() +
"/n Method Name : " + new Exception().getStackTrace()[0].getMethodName() +
"/n Line number : " + new Exception().getStackTrace()[0].getLineNumber());
I pointed the OP at this approach yesterday in one of his multi-posts. I still have not been given my Dukes! -
How to get the pull path name from a file upload window
Hello everyone!
I have encountered the following problem with the following JSP code:
<form method="post" action="filename.jsp">
Upload JAVA program:
<input type=file size=20 name="fname" accept="java">
<input type=submit value="go">
</form>
<%
String s = "";
if (request.getParameter("fname") != null)
s = request.getParameter("fname")
%>
The value of s is alway the filename. However I want to get the full path in addition to the filename, so that I can read the file. Does anyone know how to get the pull name of the file?
thanks a lot in advance,Dear Sir,
thanks a lot for your reply. Please let me explain what I intended to do: I want to upload a file from the local machine and then read the content of the file. Therefore I need to the fullpath of the filename like /var/local/file.java instead of file.java. The latter is what I got.
The problem I have with your code is that the function like "request.getServerScheme()" is not recognized. Maybe is it because I didn't install servelet package? I only installed javax package btw. Also my application runns on Tomcat server if this could give you some information. The error message I had is as follows:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 36 in the jsp file: /addExercise.jsp
Generated servlet error:
[javac] Compiling 1 source file
/usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:133: cannot resolve symbol
symbol : method getServerScheme ()
location: interface javax.servlet.http.HttpServletRequest
url = request.getServerScheme()
^
An error occurred at line: 36 in the jsp file: /addExercise.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:136: cannot resolve symbol
symbol : method getServerScheme ()
location: interface javax.servlet.http.HttpServletRequest
+ ((("http".equals(request.getServerScheme()) && request.getServerPort() != 80)
^
An error occurred at line: 36 in the jsp file: /addExercise.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:137: cannot resolve symbol
symbol : method getServerScheme ()
location: interface javax.servlet.http.HttpServletRequest
||("https".equals(request.getServerScheme()) && request.getServerPort() != 443))
^
An error occurred at line: 36 in the jsp file: /addExercise.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:139: cannot resolve symbol
symbol : method getServletConfig ()
location: interface javax.servlet.http.HttpServletRequest
+ "/" + request.getServletConfig().getServletName()
^
An error occurred at line: 36 in the jsp file: /addExercise.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:140: cannot resolve symbol
symbol : variable path
location: class org.apache.jsp.addExercise_jsp
+ "/" + path
^
5 errors
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:413)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856) -
How to get the full path instead of just the file name, in �FileChooser� ?
In the FileChooserDemo example :
In the statement : log.append("Saving: " + file.getName() + "." + newline);
�file.getName()� returns the �file name�.
My question is : How to get the full path instead of just the file name,
e.g. C:/xdirectory/ydirectory/abc.gif instead of just abc.gif
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.filechooser.*;
public class FileChooserDemo extends JFrame {
static private final String newline = "\n";
public FileChooserDemo() {
super("FileChooserDemo");
//Create the log first, because the action listeners
//need to refer to it.
final JTextArea log = new JTextArea(5,20);
log.setMargin(new Insets(5,5,5,5));
log.setEditable(false);
JScrollPane logScrollPane = new JScrollPane(log);
//Create a file chooser
final JFileChooser fc = new JFileChooser();
//Create the open button
ImageIcon openIcon = new ImageIcon("images/open.gif");
JButton openButton = new JButton("Open a File...", openIcon);
openButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int returnVal = fc.showOpenDialog(FileChooserDemo.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
//this is where a real application would open the file.
log.append("Opening: " + file.getName() + "." + newline);
} else {
log.append("Open command cancelled by user." + newline);
//Create the save button
ImageIcon saveIcon = new ImageIcon("images/save.gif");
JButton saveButton = new JButton("Save a File...", saveIcon);
saveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int returnVal = fc.showSaveDialog(FileChooserDemo.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
//this is where a real application would save the file.
log.append("Saving: " + file.getName() + "." + newline);
} else {
log.append("Save command cancelled by user." + newline);
//For layout purposes, put the buttons in a separate panel
JPanel buttonPanel = new JPanel();
buttonPanel.add(openButton);
buttonPanel.add(saveButton);
//Explicitly set the focus sequence.
openButton.setNextFocusableComponent(saveButton);
saveButton.setNextFocusableComponent(openButton);
//Add the buttons and the log to the frame
Container contentPane = getContentPane();
contentPane.add(buttonPanel, BorderLayout.NORTH);
contentPane.add(logScrollPane, BorderLayout.CENTER);
public static void main(String[] args) {
JFrame frame = new FileChooserDemo();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
frame.pack();
frame.setVisible(true);simply use file.getPath()
That should do it!Thank you !
It takes care of the problem !!
Maybe you are looking for
-
Hi, I got Technical Specs from my company to create DSO , so here in Technical Specs under Data Fields Coloumn some are Characteristics and some Keyfigures. but what i know Data Fields should only contains Keyfigures? Need Clarification. Thanks and R
-
Help Needed : Setting JDBC Datasource in Crystal XI using Sybase 12.5??
All, We are migrating our systems to the Crystal XI from Crystal 9 Reporting Servers. I need some technical assistance on the Java API ( use of the Datasources) . Problem: Currently in Crystal 9 we are using OLEDB datasources to connect to various Sy
-
Invoicing plan for purchase order
Hi experts There is invoicing plan facility in SAP. Can we use it in following scenario. We have a separate type of purchase order for services. On daily basis we prepare the service entry sheet against the said purchase order as and when service is
-
I have many Java POJOs imported as facts. In each of these POJOs there is at least 1 date property. How am I to use these dates in my rules. for example: pojo.date > '08/22/06' pojo.date < today println(pojo.date) Although I have imported the java da
-
From what I have read there is no support for pasting anything else than text from the system clipboard to a Java application, however in my case I need to get hold of an image in the system clipboard. The application will only need to run on Windows