Actions calling methods?
Alright, so what you see below is a piece of my attempt to pop up a gui after having parsed a word file.
In this word file, there are variables being defined, and i am trying to use this code to replace some of the variables that have been hard coded into the text file
at the top of the class we have:
private static JFrame makeYourChoice;
private static Map<String, VariableDefinition> defaults;
private static List<List<VariableDefinition>> userSelected = new ArrayList<List<VariableDefinition>>();
private static List<VariableDefinition> tempListToBuildUsrSel = new ArrayList<VariableDefinition>();
the Variable definition Class pretty much contains a scope and a string
What I would like to know, is, down on the line near the bottom, where VariableDefinition vd is defined, why is it telling me that the empty constructor is undefined for the Variable Definition. It is, but I fail to see how that has any relevance since i am defining it from a Map....
Thanks for your Help,
--Russ
________________________________________________BELOW IS CODE_______________________________________________________________________
private JFrame addVariableFrame( JFrame jF, GridBagConstraints template, VariableDefinition vd, int whichVariableAreWe )
JPanel variableDefinition = new JPanel();
GridBagConstraints setPositioning = (GridBagConstraints)template.clone();
cellSpan(setPositioning, 2, 1);
moveTo(setPositioning, 0, whichVariableAreWe);
JLabel name = new JLabel( vd.getIdentifier().getRawData() );
setPositioning = (GridBagConstraints)template.clone();
cellSpan(setPositioning, 1, 1);
moveTo(setPositioning, 0, 0);
name.setFont( new Font("Header", Font.BOLD, 14) );
variableDefinition.add(name, setPositioning);
JTextField value = new JTextField( vd.getValue().getRawData() );
setPositioning = (GridBagConstraints)template.clone();
moveTo(setPositioning, 1, 0);
value.setFont( new Font("Header", Font.BOLD, 14) );
variableDefinition.add(value, setPositioning);
jF.add( variableDefinition );
return jF;
final Action proceedCLICK = new AbstractAction("Proceed")
@Override
public void actionPerformed( final ActionEvent ae )
for ( Component c : makeYourChoice.getComponents() )
if ( c instanceof JPanel)
JLabel jL = (JLabel)c.getComponentAt(0, 0);
JTextField jTF = (JTextField)c.getComponentAt(0, 1);
VariableDefinition vd = defaults.get(jL.getText());
VarIdentifier name = new VarIdentifier( jL.getText(),vd.getIdentifier().getScope() );
ParseTreeElement value = new VarIdentifier( jTF.getText(), vd.getValue().getScope());
String rawData = jL.getText() + "=" + jTF.getText();
vd = new VariableDefinition( rawData, vd.getChildren(), vd.getScope(), name, value );
tempListToBuildUsrSel.add(vd);
private static final long serialVersionUID = 10400001L ;
};
I don't know about anyone else, but I'm having a difficult time understanding the gist of your problem here. If you don't get a decent answer soon, I recommend several things in order to perhaps better communicate what is not working for you:
1) Create a small program that compiles and demonstrates your problem. This will necessarily mean that you will have to isolate the problem first, but this is a good thing as the isolation process often leads you to a solution. It is called creating and posting an [SSCCE.|http://sscce.org] Please see the link for further detail.
2) Use code tags to help your code retain its formatting and allow others to more easily read your code. Also spaces work better here in the forum than tabs for code indentation.
3) Don't paraphrase errors / exceptions but post the actual error messages, and
4) Go into more detail on just what your problem is.
Best of luck.
edit, as an example of code tags, check out your code when these are used:
private JFrame addVariableFrame( JFrame jF, GridBagConstraints template, VariableDefinition vd, int whichVariableAreWe )
JPanel variableDefinition = new JPanel();
GridBagConstraints setPositioning = (GridBagConstraints)template.clone();
cellSpan(setPositioning, 2, 1);
moveTo(setPositioning, 0, whichVariableAreWe);
JLabel name = new JLabel( vd.getIdentifier().getRawData() );
setPositioning = (GridBagConstraints)template.clone();
cellSpan(setPositioning, 1, 1);
moveTo(setPositioning, 0, 0);
name.setFont( new Font("Header", Font.BOLD, 14) );
variableDefinition.add(name, setPositioning);
JTextField value = new JTextField( vd.getValue().getRawData() );
setPositioning = (GridBagConstraints)template.clone();
moveTo(setPositioning, 1, 0);
value.setFont( new Font("Header", Font.BOLD, 14) );
variableDefinition.add(value, setPositioning);
jF.add( variableDefinition );
return jF;
final Action proceedCLICK = new AbstractAction("Proceed")
@Override
public void actionPerformed( final ActionEvent ae )
for ( Component c : makeYourChoice.getComponents() )
if ( c instanceof JPanel)
JLabel jL = (JLabel)c.getComponentAt(0, 0);
JTextField jTF = (JTextField)c.getComponentAt(0, 1);
VariableDefinition vd = defaults.get(jL.getText());
VarIdentifier name = new VarIdentifier( jL.getText(),vd.getIdentifier().getScope() );
ParseTreeElement value = new VarIdentifier( jTF.getText(), vd.getValue().getScope());
String rawData = jL.getText() + "=" + jTF.getText();
vd = new VariableDefinition( rawData, vd.getChildren(), vd.getScope(), name, value );
tempListToBuildUsrSel.add(vd);
private static final long serialVersionUID = 10400001L ;
private JFrame addVariableFrame( JFrame jF, GridBagConstraints template, VariableDefinition vd, int whichVariableAreWe )
JPanel variableDefinition = new JPanel();
GridBagConstraints setPositioning = (GridBagConstraints)template.clone();
cellSpan(setPositioning, 2, 1);
moveTo(setPositioning, 0, whichVariableAreWe);
JLabel name = new JLabel( vd.getIdentifier().getRawData() );
setPositioning = (GridBagConstraints)template.clone();
cellSpan(setPositioning, 1, 1);
moveTo(setPositioning, 0, 0);
name.setFont( new Font("Header", Font.BOLD, 14) );
variableDefinition.add(name, setPositioning);
JTextField value = new JTextField( vd.getValue().getRawData() );
setPositioning = (GridBagConstraints)template.clone();
moveTo(setPositioning, 1, 0);
value.setFont( new Font("Header", Font.BOLD, 14) );
variableDefinition.add(value, setPositioning);
jF.add( variableDefinition );
return jF;
final Action proceedCLICK = new AbstractAction("Proceed")
@Override
public void actionPerformed( final ActionEvent ae )
for ( Component c : makeYourChoice.getComponents() )
if ( c instanceof JPanel)
JLabel jL = (JLabel)c.getComponentAt(0, 0);
JTextField jTF = (JTextField)c.getComponentAt(0, 1);
VariableDefinition vd = defaults.get(jL.getText());
VarIdentifier name = new VarIdentifier( jL.getText(),vd.getIdentifier().getScope() );
ParseTreeElement value = new VarIdentifier( jTF.getText(), vd.getValue().getScope());
String rawData = jL.getText() + "=" + jTF.getText();
vd = new VariableDefinition( rawData, vd.getChildren(), vd.getScope(), name, value );
tempListToBuildUsrSel.add(vd);
private static final long serialVersionUID = 10400001L ;
private JFrame addVariableFrame( JFrame jF, GridBagConstraints template, VariableDefinition vd, int whichVariableAreWe )
JPanel variableDefinition = new JPanel();
GridBagConstraints setPositioning = (GridBagConstraints)template.clone();
cellSpan(setPositioning, 2, 1);
moveTo(setPositioning, 0, whichVariableAreWe);
JLabel name = new JLabel( vd.getIdentifier().getRawData() );
setPositioning = (GridBagConstraints)template.clone();
cellSpan(setPositioning, 1, 1);
moveTo(setPositioning, 0, 0);
name.setFont( new Font("Header", Font.BOLD, 14) );
variableDefinition.add(name, setPositioning);
JTextField value = new JTextField( vd.getValue().getRawData() );
setPositioning = (GridBagConstraints)template.clone();
moveTo(setPositioning, 1, 0);
value.setFont( new Font("Header", Font.BOLD, 14) );
variableDefinition.add(value, setPositioning);
jF.add( variableDefinition );
return jF;
final Action proceedCLICK = new AbstractAction("Proceed")
@Override
public void actionPerformed( final ActionEvent ae )
for ( Component c : makeYourChoice.getComponents() )
if ( c instanceof JPanel)
JLabel jL = (JLabel)c.getComponentAt(0, 0);
JTextField jTF = (JTextField)c.getComponentAt(0, 1);
VariableDefinition vd = defaults.get(jL.getText());
VarIdentifier name = new VarIdentifier( jL.getText(),vd.getIdentifier().getScope() );
ParseTreeElement value = new VarIdentifier( jTF.getText(), vd.getValue().getScope());
String rawData = jL.getText() + "=" + jTF.getText();
vd = new VariableDefinition( rawData, vd.getChildren(), vd.getScope(), name, value );
tempListToBuildUsrSel.add(vd);
private static final long serialVersionUID = 10400001L ;
};
Similar Messages
-
Action Listener Method called multiple times
I have a page (fragment .jsff), containing a simple input text and a button called "search". When I click on "Search" the action listener is triggered multiple times. (The results are displayed in a table inside a panel collection).
The results are actually coming back ok.
When I debug the code, I can see the action listener method called twice.
Do you know why is that?
What should I be taking care of?
This is my code :
*** Fragment ****
<af:commandButton text="#{identityBundle.search_label}" id="cb1"
actionListener="#{UserDetailsBean.searchUsersListener}"
disabled="#{!bindings.searchUsers.enabled}"/>
*** Managed bean ***
public void searchUsersListener(ActionEvent actionEvent) {
// Add event code here...
DCBindingContainer bindings = (DCBindingContainer)getBindings();
DCIteratorBinding iter = bindings.findIteratorBinding("userIterator");
DCDataRow row = (DCDataRow)iter.getCurrentRow();
User user = (User)row.getDataProvider();
boolean isSearchCriteriaPresent = false;
if(user != null){
String fn = user.getFirstname();
if(fn != null && !fn.trim().equals("")){
isSearchCriteriaPresent = true;
user.setLastname(fn);
user.setNonMTUserLogin(fn);
try {
Map <Object, Object> userMap = PropertyUtils.describe(user);
for(Map.Entry<Object, Object> entry: userMap.entrySet()){
if(entry.getKey() != null && entry.getValue() != null && !entry.getKey().toString().equalsIgnoreCase("class")){
isSearchCriteriaPresent = true;
break;
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
if(!isSearchCriteriaPresent){
user.setFirstname("*");
OperationBinding opBinding = (OperationBinding)bindings.getOperationBinding("searchUsers");
opBinding.getParamsMap().put("user", user);
opBinding.execute();
AdfFacesContext adfFacesCtx = AdfFacesContext.getCurrentInstance();
Map<String, Object> scopePageFlowScopeVar= adfFacesCtx.getPageFlowScope();
scopePageFlowScopeVar.put("userSearchCriteria", user);
ADFContext adfCtx = ADFContext.getCurrent();
Map sessionScope = adfCtx.getSessionScope();
sessionScope.put("userSearchCriteria", user);
setUserSearchCriteria(user);
if(selectedUserID != null){
selectedUserID.setValue(null);
RichTable table = getUserResultsTable();
DCIteratorBinding searchUsersIterator = (DCIteratorBinding)bindings.get("searchUsersIterator");
Row[] rows = searchUsersIterator.getAllRowsInRange();
if(rows.length > 0){
RowKeySetImpl rks = new RowKeySetImpl();
ArrayList keyList = new ArrayList();
keyList.add(rows[0].getKey());
rks.add(keyList);
table.setSelectedRowKeys(rks);
table.setDisplayRowKey(keyList);
refreshState(table);
if(!isSearchCriteriaPresent){
user.setFirstname(null);
else{
deleteUserButton.setDisabled(true);
resetPasswordButton.setDisabled(true);
enableUserButton.setDisabled(true);
disableUserButton.setDisabled(true);
Thanks in advance for your helpHi,
Can you try this?
1. set partialSubmit=true for the "search" button
2. set "search" button id as partialTrigger in your result table
-Prasad -
Jsf command button action bean method call from text fox
Hai Friends,
I want call the command button action bean method from textbox entry time.
because i develop login form that time user enter user name and password if he press enter from password component that time i want to use the commandbutton actionWhat's the problem exactly? Won't the commandbutton action be invoked when you press [enter] in the textbox?
-
Is there any way to call methods of one view from another
Hi experts,
I am new to webdynpro.I am having some requirement in which I need to call methods of one view from some other view of same component .So is there any way to do this.Dear Pradeep,
This will solve your problem......( plz 1st read everything ..)
There are 2 views :
i) Mandatory Attributes ' view(V1)
ii) Button' s View..(V2)
1. Create a method in Component Controller.( M1).
2. Goto V2 . In the Action Handler method of Button , call method M1 of component controller.
3. Write your Code in M1 instead of V2 method.
4. Create an EVENT ( E1 ) in component controller.
5. Fire this event from M1 before executing Action Code.
6. Now Add the event handler method of E1 in V1 ( i.e. Mandatory attributes view. ) ..........clear????? .. set "METHOD TYPE" = Event Handler. instead of Method.
7. In this event handler method in V1 , write the "check_mandatory_attribute_view" method.
8. use necessary flags..
Regards ,
Aditya. -
Call methods (which are in the servlet) in my response page
Hello !
I want to call methods which are in the servlet ( its name is ServletRecap) BUT the call is made in the response page which is generated by the servlet ServletRecap !
I just want to allow the user to update his choice in the response page.
example: i choice A in the initial form but i change my mind and now i want to choice B in the response page : the choice have to be update in the database.
the insertion in the DB is made by a method in the servlet : so i have to recall the method in the response page!
Please, anybody have an idea ?
my servlet :
public class ServletRecap extends HttpServlet {
// param�tres d'instance
private String urlErreurs = null;
private ArrayList erreursInitialisation = new ArrayList<String>();
private String[] param�tres = {"urlFormulaire", "urlReponse", "urlControleur", "lienRetourFormulaire"};
private Map params = new HashMap<String, String>();
// init
@SuppressWarnings("unchecked")
public void init() throws ServletException {
// on r�cup�re les param�tres d'initialisation de la servlet
ServletConfig config = getServletConfig();
// on traite les autres param�tres d'initialisation
String valeur = null;
for (int i = 0; i < param�tres.length; i++) {
// valeur du param�tre
valeur = config.getInitParameter(param�tres);
// param�tre pr�sent ?
if (valeur == null) {
// on note l'erreur
erreursInitialisation.add("Le param�tre [" + param�tres[i] + "] n'a pas �t� initialis�");
} else {
// on m�morise la valeur du param�tre
params.put(param�tres[i], valeur);
// l'url de la vue [erreurs] a un traitement particulier
urlErreurs = config.getInitParameter("urlErreurs");
if (urlErreurs == null) {
throw new ServletException(
"Le param�tre [urlErreurs] n'a pas �t� initialis�");
@SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
// on v�rifie comment s'est pass�e l'initialisation de la servlet
if (erreursInitialisation.size() != 0) {
// on passe la main � la page d'erreurs
request.setAttribute("erreurs", erreursInitialisation);
request.setAttribute("lienRetourFormulaire", "");
getServletContext().getRequestDispatcher(urlErreurs).forward(
request, response);
// fin
return;
// on r�cup�re la m�thode d'envoi de la requ�te
String m�thode = request.getMethod().toLowerCase();
// on r�cup�re l'action � ex�cuter
String action = request.getParameter("action");
// action ?
if (action == null) {
action = "init";
// ex�cution action
if (m�thode.equals("get") && action.equals("init")) {
// d�marrage application
doInit(request, response);
return;
if (m�thode.equals("post") && action.equals("validationFormulaire")) {
// validation du formulaire de saisie
doValidationFormulaire(request, response);
return;
if (m�thode.equals("post") && action.equals("enregistrementFormulaire")) {
// enregistrement du formulaire de saisie
doEnregistrementFormulaire(request, response);
return;
if (m�thode.equals("post") && action.equals("retourFormulaire")) {
// retour au formulaire de saisie
doRetourFormulaire(request, response);
return;
// autres cas
doInit(request, response);
// validation du formulaire
void doValidationFormulaire(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
// on r�cup�re les param�tres
String nomCentre = (String) request.getParameter("nomCentre");
String idCentre = (String) request.getParameter("idCentre");
String nomPreleveur = (String) request.getParameter("nomPreleveur");
String datePrelev = (String) request.getParameter("datePrelev");
String numFinFiche = (String) request.getParameter("numFinFiche");
// qu'on m�morise dans la session
HttpSession session = request.getSession(true);
session.setAttribute("nomCentre", nomCentre);
session.setAttribute("idCentre", idCentre);
session.setAttribute("nomPreleveur", nomPreleveur);
session.setAttribute("datePrelev", datePrelev);
session.setAttribute("numFinFiche", numFinFiche);
// v�rification des param�tres
ArrayList<String> erreursAppel = new ArrayList<String>();
// le nom doit �tre non vide
nomCentre = nomCentre.trim();
idCentre = idCentre.trim();
nomPreleveur = nomPreleveur.trim();
datePrelev = datePrelev.trim();
numFinFiche = numFinFiche.trim();
if (nomCentre.equals("")) {
erreursAppel.add("Le champ [nomCentre] n'a pas �t� rempli");
if (idCentre.equals("")) {
erreursAppel.add("Le champ [idCentre] n'a pas �t� rempli");
if (nomPreleveur.equals("")) {
erreursAppel.add("Le champ [nomPreleveur] n'a pas �t� rempli");
if (datePrelev.equals("")) {
erreursAppel.add("Le champ [datePrelev] n'a pas �t� rempli");
if (!numFinFiche.matches("^\\s*\\d+\\s*$")) {
erreursAppel.add("Le champ [numFinFiche] est erron�");
// des erreurs dans les param�tres ?
if (erreursAppel.size() != 0) {
// on envoie la page d'erreurs
request.setAttribute("erreurs", erreursAppel);
request.setAttribute("lienRetourFormulaire", (String) params.get("lienRetourFormulaire"));
getServletContext().getRequestDispatcher(urlErreurs).forward(
request, response);
return;
// les param�tres sont corrects - on envoie la page r�ponse
request.setAttribute("nomCentre",nomCentre);
request.setAttribute("idCentre",idCentre);
request.setAttribute("nomPreleveur",nomPreleveur);
request.setAttribute("datePrelev",datePrelev);
request.setAttribute("numFinFiche",numFinFiche);
request.setAttribute("lienRetourFormulaire", (String) params.get("lienRetourFormulaire"));
getServletContext().getRequestDispatcher((String) params.get("urlReponse")).forward(request,
response);
return;
//enregistre dans la base de donn�e les variables
void doEnregistrementFormulaire(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
String nomCentre = (String) request.getParameter("nomCentre");
String idCentre = (String) request.getParameter("idCentre");
String nomPreleveur = (String) request.getParameter("nomPreleveur");
String datePrelev = (String) request.getParameter("datePrelev");
String numFinFiche = (String) request.getParameter("numFinFiche");
String nEtude = datePrelev + "." + idCentre + "." + numFinFiche;
// qu'on m�morise dans la session
HttpSession session = request.getSession(true);
session.setAttribute("nomCentre", nomCentre);
session.setAttribute("idCentre", idCentre);
session.setAttribute("nomPreleveur", nomPreleveur);
session.setAttribute("datePrelev", datePrelev);
session.setAttribute("numFinFiche", numFinFiche);
Connexion com = new Connexion();
try{
//serveur,login,pwd,database
com.loadDriverAndConnect("127.0.0.1","3306","root","root","");
com.execute("USE BIOTECH");
com.execute("INSERT INTO RECAP (NEtude,NomCentre,idCentre,nomPreleveur,datePrelev) " +
"values ('"+nEtude+"','"+nomCentre+"','"+idCentre+"','"+nomPreleveur+"','"+ datePrelev + "')") ;
com.close();
catch(Exception ex) {
System.err.println("\n*** SQLException caught in main()");
request.setAttribute("urlAction", (String) params.get("urlControleur"));
getServletContext().getRequestDispatcher((String) params.get("urlReponse")).forward(request,
response);
return;
// affichage formulaire pr�-rempli
void doRetourFormulaire(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
// on r�cup�re la session de l'utilisateur
HttpSession session = request.getSession(true);
// on pr�pare le mod�le du formulaire
// nom pr�sent dans la session ?
String nomCentre = (String) session.getAttribute("nomCentre");
if (nomCentre == null) {
session.setAttribute("nomCentre", "");
String idCentre = (String) session.getAttribute("idCentre");
if (idCentre == null) {
session.setAttribute("idCentre", "");
String nomPreleveur = (String) session.getAttribute("nomPreleveur");
if (nomPreleveur == null) {
session.setAttribute("nomPreleveur", "");
String datePrelev = (String) session.getAttribute("datePrelev");
if (datePrelev == null) {
session.setAttribute("datePrelev", "");
String numFinFiche = (String) session.getAttribute("numFinFiche");
if (numFinFiche == null) {
session.setAttribute("numFinFiche", "");
// urlAction
request.setAttribute("urlAction", (String) params.get("urlControleur"));
// on affiche le formulaire
getServletContext().getRequestDispatcher((String) params.get("urlFormulaire")).forward(
request, response);
return;
// post
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
// on passe la main au GET
doGet(request, response);
my initial form:%
// on r�cup�re les param�tres dans la session
String nomCentre=(String)session.getAttribute("nomCentre");
String idCentre= (String)session.getAttribute("idCentre");
String nomPreleveur = (String)session.getAttribute("nomPreleveur");
String datePrelev=(String)session.getAttribute("datePrelev");
String numFinFiche=(String)session.getAttribute("numFinFiche");
String urlAction=(String)request.getAttribute("urlAction");
%>
<html>
<head>
<title>Fiche répitulative - formulaire</title>
</head>
<body>
<center>
<img src="logoBiotech.jpg" align="left" alt="logo Biotech-Germande" width="5%"></img>
<h2>Fiche répitulative - formulaire</h2>
<br>
<hr>
<form action="<%= urlAction %>" method="post">
[... page setting: made by html language ...]
<td><input type="submit" name="action" value="validationFormulaire"></td>
<td><input type="reset" value="Rétablir"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
my response page:<%
// on r�cup�re les donn�es
String nomCentre=(String)session.getAttribute("nomCentre");
String idCentre= (String)session.getAttribute("idCentre");
String nomPreleveur = (String)session.getAttribute("nomPreleveur");
String datePrelev=(String)session.getAttribute("datePrelev");
String numFinFiche=(String)session.getAttribute("numFinFiche");
String urlAction=(String)request.getAttribute("urlAction");
%>
<html>
<head>
<title>Fiche répitulative - formulaire</title>
</head>
<body>
<form action="<%= urlAction %>" method="post">
[... page setting: made by html language ...]
<br><br>
<td><input type="submit" name="action" value="enregistrementFormulaire"></td>
<td><input type="submit" name="action" value="retourFormulaire"></td>
</body>
</html>
my web.xml:<!-- Servlets -->
<!--Servlet Fiche Recapitulative-->
<servlet>
<servlet-name>FicheRecap</servlet-name>
<servlet-class>germande.ServletRecap</servlet-class>
<init-param>
<param-name>urlReponse</param-name>
<param-value>/WEB-INF/JSP/Recap/reponseRecap.biotech.jsp</param-value>
</init-param>
<init-param>
<param-name>urlErreurs</param-name>
<param-value>/erreursRecap.biotech.jsp</param-value>
</init-param>
<init-param>
<param-name>urlFormulaire</param-name>
<param-value>/WEB-INF/JSP/Recap/formulaireRecap.biotech.jsp</param-value>
</init-param>
<init-param>
<param-name>urlControleur</param-name>
<param-value>ServletRecap</param-value>
</init-param>
<init-param>
<param-name>lienRetourFormulaire</param-name>
<param-value>Retour au formulaire</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>FicheRecap</servlet-name>
<url-pattern>/ServletRecap</url-pattern>
</servlet-mapping>
</web-apps>
Thanks in advance for your idea.
I resume : how can I call a method in my servlet into my response page (in jsp).
the servlet generate this response page and i just want to update the choice of my user.
Thanks !!I resume : how can I call a method in my servlet into my response page (in jsp).Don't do that. Put the message into a plain old Java class which can be called from both the servlet and the JSP.
-
JDev10G: Struts Diagramming and Action calls in JavaScript
I've noticed that a Struts diagram does not reflect actions that are called from within JavaScript methods. Is this something that will be included in JDeveloper 10G 9.0.5 production?
We are not currently going into the code (java or java script) to look for action calls. I will enter an enhancement request for this functionality.
Thanks,
Pete -
How to call method of Component A in Component B
Hi Friends,
I want to use Method A of Component A in Component B. Can some one tell me how to call method A on action of a button in component B.
Regards
SankarHi,
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_method( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
DATA lo_interfacecontroller TYPE REF TO yiwci_sg_method .
lo_interfacecontroller = wd_this->wd_cpifc_method( ).
lo_interfacecontroller->execute_method(
i was able to do the above process successfully but how to bind data to the node of component 2.
In the component 1 : method A i defiend to get records upto 25 rows. now i tried using same method . but how to bind data using this method
Regards
sankar -
Hi,
I was wondering if there was any way to make an action performed method not be void. My action performed methods create booleans which I need the values of to be returned so they can trigger if() statements in another part of the application. Any suggestions would be greatly appreciatedNo. ActionPerformed is an interface that has a set definition. It is unusual for code to explitily call an actionPerformed listener. Usually the listener is added to a component and the component's code makes the call. If you are making explicit calls, you could create your own interface that returns whatever type you want.
-
Error calling methods CL_GUI_FRONTEND_SERVICES
Hi all,
I have a requirement in BAPI (integrating solman to portal) to download file from app. server to local directory. I used the below FM to get temp directory of presntation server.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_TEMP_DIRECTORY
CHANGING
TEMP_DIR = LV_TEMP_DIR
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4.
CALL METHOD cl_gui_cfw=>flush.
It works fine in R3, but when i called it from portal it shows Access not possible using 'NULL' object reference with a short dump .
st22 shows
Error in ABAP application program.
The current ABAP program "CL_GUI_FRONTEND_SERVICES======CP" had to be
terminated because one of the
statements could not be executed.
This is probably due to an error in the ABAP program.
An exception occurred. This exception is dealt with in more detail belo
. The exception, which is assigned to the class 'CX_SY_REF_IS_INITIAL',
neither
caught nor passed along using a RAISING clause, in the procedure
"GET_TEMP_DIRECTORY" "(METHOD)"
Since the caller of the procedure could not have expected this exceptio
to occur, the running program was terminated.
The reason for the exception is:
Attempt to access a component using 'NULL' object reference (points
to nothing).
An object reference must point to an object (an instance of a class)
before you can use it to access components (variable:
"CL_GUI_FRONTEND_SERVICES=>HANDLE").
Either the reference has not yet been set, or it has been reset to
'NULL' by a CLEAR statement.
When i put external break point and the dump comes during execution of CALL METHOD cl_gui_cfw=>flush.
Is it not possible to use CL_GUI_FRONTEND_SERVICES in RFC ??.
thanks and regards
JijoHi,
the dump is because you cannot use that function from a BSP application, which runs in internet or intranet. The procedure in this case is different:
DATA: flights TYPE flighttab,
flight LIKE LINE OF flights,
appl TYPE string,
filetype TYPE string,
output TYPE string,
output2 TYPE xstring,
response TYPE REF TO if_http_response,
l_len TYPE i,
seatsmax TYPE string,
seatsocc TYPE string.
appl = 'application/msexcel'.
filetype = 'attachment;filename=mi archivo.xls'.
SELECT * FROM sflight
INTO TABLE flights
UP TO 20 ROWS.
LOOP AT flights INTO flight.
seatsmax = flight-seatsmax. CONDENSE seatsmax.
seatsocc = flight-seatsocc. CONDENSE seatsocc.
CONCATENATE output
flight-carrid cl_abap_char_utilities=>horizontal_tab
flight-connid cl_abap_char_utilities=>horizontal_tab
flight-fldate cl_abap_char_utilities=>horizontal_tab
flight-planetype cl_abap_char_utilities=>horizontal_tab
seatsmax cl_abap_char_utilities=>horizontal_tab
seatsocc cl_abap_char_utilities=>horizontal_tab
cl_abap_char_utilities=>cr_lf
INTO output.
ENDLOOP.
response = runtime->server->response.
response->delete_header_field( name = if_http_header_fields=>cache_control ).
response->delete_header_field( name = if_http_header_fields=>expires ).
response->delete_header_field( name = if_http_header_fields=>pragma ).
response->set_header_field( name = if_http_header_fields=>content_type
value = appl ).
response->set_header_field( name = 'content-disposition'
value = filetype ).
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = output
mimetype = 'text/unicode; charset=utf-16le'
IMPORTING
buffer = output2.
CONCATENATE cl_abap_char_utilities=>byte_order_mark_little
output2 INTO output2 IN BYTE MODE.
l_len = XSTRLEN( output2 ).
response->set_data( data = output2
length = l_len ).
navigation->response_complete( ).
This is the code for downloading an Excel file. -
CALL METHOD cl_gui_frontend_services= file_save_dialog
Hi,
I want to use 'CALL METHOD cl_gui_frontend_services=>file_save_dialog', to choose a path for saving my txt files. I only want the user to be able to choose the path and not have to supply a filename aswell. My filenames are standard in the program and I don't want them to be changed by the user.
Is there another method which is designed for this or is there a simple parameter I have missed?
Thanks and regards,
Simon.AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_f.
PERFORM f_search_help_pa_f1.
FORM f_search_help_pa_f1 .
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = sy-repid
dynpro_number = sy-dynnr
CHANGING
file_name = pa_f
EXCEPTIONS
mask_too_long = 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.
ENDFORM. " f_search_help_pa_f1
Try this
Regards -
*ERROR IN OLE CALL - METHOD CALL ERROR...*
HI ..
When trying to Upload a file using BDC with Vista OS, we are getting the following error..
ERROR IN OLE CALL - METHOD CALL ERROR...
There is no problem with BDC as its working fine with XP & other OS.
Pls help!!Seems that you are working with microsoft files.
Maybe you are using deprecated functions like WS_EXCEL -
How to call methods from within run()
Seems like this must be a common question, but I cannot for the life of me, find the appropriate topic. So apologies ahead of time if this is a repeat.
I have code like the following:
public class MainClass implements Runnable {
public static void main(String args[]) {
Thread t = new Thread(new MainClass());
t.start();
public void run() {
if (condition)
doSomethingIntensive();
else
doSomethingElseIntensive();
System.out.println("I want this to print ONLY AFTER the method call finishes, but I'm printed before either 'Intensive' method call completes.");
private void doSomethingIntensive() {
System.out.println("I'm never printed because run() ends before execution gets here.");
return;
private void doSomethingElseIntensive() {
System.out.println("I'm never printed because run() ends before execution gets here.");
return;
}Question: how do you call methods from within run() and still have it be sequential execution? It seems that a method call within run() creates a new thread just for the method. BUT, this isn't true, because the Thread.currentThread().getName() names are the same instead run() and the "intensive" methods. So, it's not like I can pause one until the method completes because they're the same thread! (I've tried this.)
So, moral of the story, is there no breaking down a thread's execution into methods? Does all your thread code have to be within the run() method, even if it's 1000 lines? Seems like this wouldn't be the case, but can't get it to work otherwise.
Thanks all!!!I (think I) understand the basics.. what I'm confused
about is whether the methods are synced on the class
type or a class instance?The short answer is; the instance for non-static methods, and the class for static methods, although it would be more accurate to say against the instance of the Class for static methods.
The locking associated with the "sychronized" keyword is all based around an entity called a "monitor". Whenever a thread wants to enter a synchronized method or block, if it doesn't already "own" the monitor, it will try to take it. If the monitor is owned by another thread, then the current thread will block until the other thread releases the monitor. Once the synchronized block is complete, the monitor is released by the thread that owns it.
So your question boils down to; where does this monitor come from? Every instance of every Object has a monitor associated with it, and any synchronized method or synchonized block is going to take the monitor associated with the instance. The following:
synchronized void myMethod() {...is equivalent to:
void myMethod() {
synchronized(this) {
...Keep in mind, though, that every Class has an instance too. You can call "this.getClass()" to get that instance, or you can get the instance for a specific class, say String, with "String.class". Whenever you declare a static method as synchronized, or put a synchronized block inside a static method, the monitor taken will be the one associated with the instance of the class in which the method was declared. In other words this:
public class Foo {
synchronized static void myMethod() {...is equivalent to:
public class Foo{
static void myMethod() {
synchronized(Foo.class) {...The problem here is that the instance of the Foo class is being locked. If we declare a subclass of Foo, and then declare a synchronized static method in the subclass, it will lock on the subclass and not on Foo. This is OK, but you have to be aware of it. If you try to declare a static resource of some sort inside Foo, it's best to make it private instead of protected, because subclasses can't really lock on the parent class (well, at least, not without doing something ugly like "synchronized(Foo.class)", which isn't terribly maintainable).
Doing something like "synchronized(this.getClass())" is a really bad idea. Each subclass is going to take a different monitor, so you can have as many threads in your synchronized block as you have subclasses, and I can't think of a time I'd want that.
There's also another, equivalent aproach you can take, if this makes more sense to you:
static final Object lock = new Object();
void myMethod() {
synchronized(lock) {
// Stuff in here is synchronized against the lock's monitor
}This will take the monitor of the instance referenced by "lock". Since lock is a static variable, only one thread at a time will be able to get into myMethod(), even if the threads are calling into different instances. -
Call method http_client- response- get_header_fields for PDF and for TIFF
Hi,
I am using a Function Module..
APAR_EBPP_GET_INVOICE_DETAIL to display the TIFF images on the Biller Direct side.
The above function module is used to retrieve the PDF documents from the document repository.
In Similar way I am trying to do the TIFF Images too.
But in this method
call method http_client->response->get_header_fields
changing fields.
For PDF the table fields is as follows
NAME VALUE
1 ~response_line----
|HTTP/1.1 200 (OK) |
2 ~server_protocol----
|HTTP/1.1 |
3 ~status_code----
|200 |
4 ~status_reason----
|(OK) |
5 content-length----
|7136 |
6 content-type----
|application/pdf |
7 server |Microsoft-IIS/6.0 |
8 x-powered-by |ASP.NET |
9 date |Tue, 24 Feb 2009 18:09:35 GMT |
10 connection |close |
For TIFF the table fields are as follows:
1 ~response_line----
|HTTP/1.1 500 (internal server error) |
2 ~server_protocol----
|HTTP/1.1 |
3 ~status_code----
|500 |
4 ~status_reason----
|(internal server error) |
5 content-length----
|105 |
6 content-type----
|text/plain |
7 server----
|Microsoft-IIS/6.0 |
8 x-powered-by |ASP.NET |
9 date |Tue, 24 Feb 2009 18:26:39 GMT |
10 connection |close |
The error message is Internal Server error..
This is in HTTP2_Get Function Module.
What would be the reason for HTTP/1.1 500 Internal Server error.
Any suggestions are welcome..
Thanks,
ChaitanyaHi Niranjan,
can you please check if you have imported the whole chain of certificates. Certificates usually diplayed in 3 levels in the Explorer. like
Verisign - L1
>>> Versign-- L2
>>>>>>>>>>>>XYZ.com -- L3
Extract all the 3 certificates and Put in Strust and do exit soft and hard in SMICM and restart the service.
Its better to create a RFC destination of Type H and Do the Connection test for HTTPS configuration. If the connection test comes OK then u can be sure of the configuration. -
How to Call Methods in Ecatt?
Hello Gurus,
I dont find CALLMETHOD or CALLSTATIC commands in Ecatt. I am using R/3 4.7 version of SAP.
My question also is how to call methods. I have a scenario where my test script execution depends on the return type of method. Say if the return type of method is A only then I should run the script else the script should not be executed.
Your help in this regard is highly appreciated.
Regards,
GS.>
Get Started wrote:
> Hello Gurus,
>
> I dont find CALLMETHOD or CALLSTATIC commands in Ecatt. I am using R/3 4.7 version of SAP.
>
> My question also is how to call methods. I have a scenario where my test script execution depends on the return type of method. Say if the return type of method is A only then I should run the script else the script should not be executed.
>
> Your help in this regard is highly appreciated.
>
> Regards,
> GS.
Hi GS,
Please use the command "CallMethod" and it is available with latest SAP version.
You have to provide the Object Instance Parameter and Instance Method.
Regards,
SSN. -
Syntax for how to call method of one comp in other comp wd java.
Let us assume,
there is method1 in view1 comp1.
tell me syntax for calling method 1 in view2 comp2
thanks in advance.
Edited by: madhu1011 on Nov 9, 2011 11:31 AMHi Madhu,
This is the situation:
comp1-> method 1 , view1
comp2-> view2
You need to access method1 in view2 of comp2.
For that, do the following steps:
1.) First create a method (for eg: method1) in comp1 (under implementation of view1).
eg: public void method1(){
<......some logic...>
2.)Save the meta data.
3.) In comp2, you will find an option called used components. In that right click and add the component comp2. (Carefully select comp1 itslef).
4.)Save the meta data.
5.) Then go to view2 of comp2 and take implementaion part and right the following logic in wddoinit() (or any other standard or custom method).
wdThis.wdGetComp2Interface().getMethod("method1");
By this way, we can access the method1 of comp1 in comp2.
Regards,
Jithin
Maybe you are looking for
-
Approval for deviation from credit limit
Hi Guys Approval for deviation from credit limit does not work in the following scenario. Credit Limit = R20000 Balance = 0 Sales order added for R18000, no approval needed as less than credit limit. Then user changes the Sales order amount to more t
-
Upgraded my iTunes & now it won't open at all
I just upgraded my iTunes to 9.02 from a really old version, about 10 minutes ago. I am fairly certain I followed all the steps correctly. I now cannot open iTunes at all from the table at the bottom of my desktop. The icon is there but it will not o
-
Error in account coding allocation - Service Entry
Hi, While doing service entry I am facing a error called error in account coding allocation. Please can any one suggest me how to go about it. Thanks & Regards kiran
-
Inactive InfoObject after Transport
We modified an InfoObject and transported the change; however, our BWQ system still does not recognize the InfoObject has active. And the InfoObject is active in BWD. Our BWD system has the automatic transport connection active; then we went back a
-
Multi Flip paper stock on MX922
I need to print DVD label on Multi Flip paper stock on MX922. 183 mm Width x 270 mm Length with 11mm top border and 10 mm left/right border and 12 mm in between DVD label spacing. I was be able to create custom paper size but not the page layout.