Does Java package has Model class?

I found the following code below from http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/web-tier/web-tier5.html. The problem is there is no Model class during the java compilation. I thought it is included in the Java package. Anyway, I was fail to import the Model class from java.lang.Object, java.awt, java.awt.event.*, javax.swing.*, java.util.*, and so on. Does Model class belong to Java package or self create?
// Action.java:
public abstract class Action {
  protected Model model;
  public Action(Model model) { this.model = model; }
  public abstract String getName();
  public abstract Object perform(HttpServletRequest req);
// CreateUserAction.java:
public class CreateUserAction extends Action {
  public CreateUserAction(Model model) {
    super(model);
  public String getName() { return "createUser"; }
  public Object perform(HttpServletRequest req) {
    return model.createUser(req.getAttribute("user"),
                  req.getAttribute("pass"));
}

No, it's not a Java SDK class, and it doesn't self-create. It must be part of the blueprints download, so you'll have to find where it is (a JAR file you've downloaded, perhaps) and put it in the CLASSPATH.

Similar Messages

  • Does java import loads the class?

    Hi,
    Acc common practive {not mentioned in Sun java convention} if a class is using more than three classes from a pacakage then its ideal to import all the classes from tht package instead of importing individual classes. i.e., import pacakage.*;
    1) Does this kind of load all the classes into memory?
    2) Does import statement actually loads a class into memory
    isnt import jst to use class name instead of complete package name in the code?
    3) Does a class get loaded only when its object/ its static memebers are invoked?
    Would appreciate if anyone can answer these queries.
    Thanks
    Deepak

    Acc common practive {not mentioned in Sun java
    convention} And not mentioned or usually followed anywhere else. Who says this?
    if a class is using more than three
    classes from a pacakage then its ideal to import all
    the classes from tht package instead of importing
    individual classes. i.e., import pacakage.*;
    1) Does this kind of load all the classes into
    memory?imports have no influence on anything but the length of written code. Thanks for being the second person this hour to ask this question without researching first.
    2) Does import statement actually loads a class into
    memoryNo. It does nothing at all.
    isnt import jst to use class name instead of complete
    package name in the code?Yes.
    3) Does a class get loaded only when its object/ its
    static memebers are invoked?Yes.

  • Does Java Fx has internal Frame?

    Hi It's my first time using javafx and I'm using on my project application, just wondering if JavaFx has internal frame ? and how to create it thanks in advance

    No, JavaFX 2.2 does not have an Internal Frame built into the platform.
    See [url https://forums.oracle.com/forums/thread.jspa?threadID=2443001]Thread: Like JFrames and JInternalFrames
    Also look at the windowing system in [url http://jfxtras.org/]jfxtras, which provides similar support (it's a later version of [url http://mihosoft.eu/?p=365]VFXWindows).

  • Struts 2: Doesn't populate an array of java beans in action classes

    Hello,
    Currently i am working on Struts 2 based application, in which i need to populate an array of Java beans from the form.
    The problem, I am facing is:
    Struts 2 is not instantiating an array of beans
    I have gone through the Data transfer and Type Conversion of struts of 1.2, but every where I can see only following:
    1 An array of primitive data types
    2 List of primitive / Java bean
    3 Map of primitive / Java bean
    but i can't see the docs on An array of Java Beans.
    What I can't do in my application is:
    1 Can not convert an array of beans into java.util.List<beans>
    2 Can not instantiate the bean array (As the number of elements will be decided by the front end - form)
    Please have a look at my configuration file:
    struts.xml:+
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
    <constant name="struts.devMode" value="true" />
    <include file="test/test.xml"/>
    </struts>
    test.xml:+
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
    <package name="test" namespace="/test" extends="struts-default">
    <action name="TestInput">
    <result>/test/input.jsp</result>
    </action>     
    <action name="TestOutput" class="test.Controller">
    <result name="SUCCESS">/test/output.jsp</result>
    </action>
    </package>
    </struts> Controller.java+
    package test;
    public class Controller {
    private String id = null;
    private Contact[] contacts = null;
    public String execute()  {
    System.out.println("***********************************");
    System.out.println("id::: " + getId());
    System.out.println("contacts::: " + getContacts());
    System.out.println("***********************************");
    return "SUCCESS";
    public Contact[] getContacts() {
    return contacts;
    public void setContacts(Contact[] contacts) {
    this.contacts = contacts;
    public String getId() {
    return id;
    public void setId(String id) {
    this.id = id;
    } Contact.java:+
    package test;
    public class Contact {
    private String name = null;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    }+ input.jsp:+
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ taglib prefix="s" uri="/struts-tags" %>
    <html>
    <head>
    <title>Test Form</title>
    </head>
    <SCRIPT type="text/javascript">
    // Total number of contacts in the mail request form
    var totalContacts = 0;
    function addContact() {
    var tbody = document.getElementById('testTable').getElementsByTagName('tbody')[0];
    var row = document.createElement('TR');
    var td1 = document.createElement('TD');
    var td2 = document.createElement('TD');
    var inputBox = document.createElement('INPUT');
    td1.innerHTML = new String('Contact ' + (totalContacts + 1) + ' :');
    inputBox.type = 'text';
    inputBox.name = 'contacts['+totalContacts+'].name';
    //inputBox.name = 'contacts.name';
    td2.appendChild(inputBox);
    row.appendChild(td1);
    row.appendChild(td2);
    tbody.appendChild(row);
    // Add to the total number of contacts
    totalContacts += 1;
    </SCRIPT>
    <body>
    <h4>Mail Request Form</h4>      
    <s:form action="TestOutput">
    <table border="1" id="testTable">
    <tr>
    <td colspan="2">
    <s:textfield name="id" label="Request Id"/>
    </td>
    </tr>
    <tr>
    <td align="left">
    <input type="button" value="Add Contact" onklick="javascript:addContact();"/>
    </td>                              
    <td align="right">
    <s:submit/>                         
    </td>     
    </tr>     
    </table>
    </s:form>
    </body>
    </html>
    + output.jsp:+ Not concerned right now
    Exception got in the logs after submitting the form:+
    java.lang.InstantiationException: [Ltest.Contact;
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:123)
    at com.opensymphony.xwork2.util.InstantiatingNullHandler.createObject(InstantiatingNullHandler.java:123)
    at com.opensymphony.xwork2.util.InstantiatingNullHandler.nullPropertyValue(InstantiatingNullHandler.java:104)
    at ognl.ASTProperty.getValueBody(ASTProperty.java:94)
    at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at ognl.SimpleNode.getValue(SimpleNode.java:210)
    at ognl.ASTChain.setValueBody(ASTChain.java:168)
    at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
    at ognl.SimpleNode.setValue(SimpleNode.java:246)
    at ognl.Ognl.setValue(Ognl.java:476)
    at com.opensymphony.xwork2.util.OgnlUtil.setValue(OgnlUtil.java:186)
    at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java:158)
    at com.opensymphony.xwork2.util.OgnlValueStack.setValue(OgnlValueStack.java:146)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:193)
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:159)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:105)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:207)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:74)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:127)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.interceptor.ProfilingActivationInterceptor.intercept(ProfilingActivationInterceptor.java:107)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:206)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:115)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:143)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121)
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:123)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
    at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
    at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
    at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Unknown Source)
    Please give me suggestions to move forward
    Thanks in advance
    Vikas Parikh

    I am having the same issue. It appears that the RequestProcessor.processValidate adds the errors (ActionMessages) to the request the does a forward. As such the errors are not available to the jsp page. Does any one know a way to get round this?

  • Activation error : context model node has not been bound to a model class

    Hi All,
    I have DC project, which i am able to run without error, But when i try to activate this DC project, I am getting below error in activation log : Please help me out, It's very urgent...
    [wdgen] [Info]    Generating packages/com/ltli/crtmachineord/models/zp3019_dealer_default_valuesmodel/Zp3019_Dealer_Default_Values_Output.java
         [wdgen] [Error]   com.ltli.crtmachineord.components.crtmachineordcomp.CrtMachineOrdComp --> ContextModelNode Zp3019_Salesorder_Mac_Texts_Input [modelClass]: The context model node has not been bound to a model class (Hint: A Context model node has to be bound to a model class or mapped to a model node of another controller.)
         [wdgen] [Error]   com.ltli.crtmachineord.components.crtmachineordcomp.CrtMachineOrdComp --> ContextModelNode Output_Text [modelClass]: The context model node has not been bound to a model class (Hint: A Context model node has to be bound to a model class or mapped to a model node of another controller.)
         [wdgen] [Info]    com.ltli.crtmachineord.components.crtmachineordcomp.CrtMachineOrdComp --> ContextModelNode Output_Text [supplyingRelationRole]: Supply function or supplying relation role missing (Hint: A child node which is not mapped must have either a supplying relation role or a supply function or one of its parent nodes must have a supply function.)
         [wdgen] [Error]   com.ltli.crtmachineord.components.crtmachineordcomp.CrtMachineOrdComp --> ContextModelNode T_Contract_Note_Text [modelClass]: The context model node has not been bound to a model class (Hint: A Context model node has to be bound to a model class or mapped to a model node of another controller.)
         [wdgen] [Info]    com.ltli.crtmachineord.components.crtmachineordcomp.CrtMachineOrdComp --> ContextModelNode T_Contract_Note_Text [supplyingRelationRole]: Supply function or supplying relation role missing (Hint: A child node which is not mapped must have either a supplying relation role or a supply function or one of its parent nodes must have a supply function.)
         [wdgen] [Error]   com.ltli.crtmachineord.components.crtmachineordcomp.CrtMachineOrdComp --> ContextModelNode Zp3019_Get_Employee_Name_Input [modelClass]: The context model node has not been bound to a model class (Hint: A Context model node has to be bound to a model class or mapped to a model node of another controller.)
         [wdgen] [Error]   com.ltli.crtmachineord.components.crtmachineordcomp.CrtMachineOrdComp --> ContextModelNode Output_Name [modelClass]: The context model node has not been bound to a model class (Hint: A Context model node has to be bound to a model class or mapped to a model node of another controller.)
         [wdgen] [Info]    com.ltli.crtmachineord.components.crtmachineordcomp.CrtMachineOrdComp --> ContextModelNode Output_Name [supplyingRelationRole]: Supply function or supplying relation role missing (Hint: A child node which is not mapped must have either a supplying relation role or a supply function or one of its parent nodes must have a supply function.)
         [wdgen] [Info]    com.ltli.crtmachineord.components.crtmachineordcomp.CustnoView --> Caption grp_equipmentnumber_Header: UIElement does not have a label
         [wdgen] [Warning] com.ltli.crtmachineord.views.longtextview.LongTextView --> TextEdit txe_LongText: UIElement does not have a label
         [wdgen] [Info]    com.ltli.crtmachineord.components.crtmachineordcomp.MatnoView --> Caption grp_equipmentnumber_Header: UIElement does not have a label
         [wdgen] [Warning] com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> Label SalesDocType_Lbl [labelFor]: Value is not valid
         [wdgen] [Warning] com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> Label SalesOrg_Lbl [labelFor]: Value is not valid
         [wdgen] [Warning] com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> Label DistChannel_Lbl [labelFor]: Value is not valid
         [wdgen] [Warning] com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> Label Division_Lbl [labelFor]: Value is not valid
         [wdgen] [Warning] com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> Label SalesOffice_Lbl [labelFor]: Value is not valid
         [wdgen] [Warning] com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> Label SalesGroup_Lbl [labelFor]: Value is not valid
         [wdgen] [Warning] com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> Label Plant_lbl [labelFor]: labelFor is not set
         [wdgen] [Error]   com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> TextView txv_Ename [text]: Context element and property are not compatible
         [wdgen] [Warning] com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> Label lbl_CustNo [labelFor]: labelFor is not set
         [wdgen] [Warning] com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> Label lbl_ConsigneeTo [labelFor]: labelFor is not set
         [wdgen] [Warning] com.ltli.crtmachineord.views.crtmachineordview.CrtMachineOrdView --> Label lbl_Pin [labelFor]: labelFor is not set
    Thanks
    Sandy

    We could resolved the problem by creating new DC project
    and copying the content of existing Dc project into new DC.
    (Also created new activity for this new DC), Build & Deploy the project.
    Now we are able to activate the new activity without any error.
    Thanks
    Sandy

  • How to find classes in a java package

    i am writing a java IDE. i want to extract all class names from a java package eg. java.lang (through coding). how can i do that.
    Thanks in advance

    File file = new File("path to your jar file");
    JarFile jf = new JarFile(file);
    Enumeration e = jf.entries();
    ZipEntry ze = null;
    while(e.hasMoreElements()){
    ze = (ZipEntry) e.nextElement();
    ze.toString(); // gives you the file name
    you have to understand java.util.jar java.util.zip packages for working with jar/zip files.
    Hope this helps

  • Does Java have an object model for the actual .java files?

    OK, you know how you can use the Document Object Model (DOM) in JavaScript or PHP to access and modify specific parts of an HTML document? Is there anything similar for .java files? Can I load a .java file into some kind of Java Code Object Model (JCOM?) and then manipulate that code as if it were an object.
    Note: I am not asking how to instantiate and use a regular object as defined by the .java file. I am wondering about modifying the actual .java file itself as an object that represents the actual text of the code in the .java file.

    GrantSR wrote:
    Not the code, per se, but the classes they define... Yessum, most certainly: ASM, among others.
    Also Google [java parser|http://www.google.com.au/search?q=java+parser]... one of them might do what you're after.
    So, one would parse the Java code into XML using one of these many and
    varied parsers, then access that XML via the DOM? Well, I guess a two
    step process is good enough.
    Thanks for your help.
    No wuckers!
    But I don't know if I did much. If you do get something working please post back, and outline your approach.
    Cheers. Keith.

  • Moving Model Class to different package

    Hi,
    How can i move the model class to a different package in CE 7.1
    Regards,
    Senthil

    Hi Senthil
    I thinks this should be possible to realize on the file system level.
    - Find the folder where your model as well as the model classes are located.
    - Search for all files (.) that contain the model class name. Typically it'll find (*.wdmodel and *.wdmodellclass). Change manually the package name within/near the found lines.
    But why do you need to change the model class package separately from the model package?
    BR, Siarhei

  • ContextException  the assigned model class info has no property

    Hello,
    Please someone can help me?
    1. I've changed a WSDL Model (new attributes)
    2. I've have cheked and add the new atrributes to the mapping (component & view)
    3. I've rebuild the project succesfuly.
    4. When I try to run the wd app I have the following error,
    com.sap.tc.webdynpro.progmodel.context.ContextException: AttributeInfo(path=Wdhrsolposv2_Comp/Wdhrsolposv2_Comp.Request_NewOperation.NewOperation.In.JTipoJornada, class=com.sap.tc.webdynpro.progmodel.context.DataAttributeInfo): the assigned model class info has no property JTipoJornada
    Caused by: com.sap.tc.webdynpro.progmodel.context.ContextException: AttributeInfo(path=Wdhrsolposv2_Comp/Wdhrsolposv2_Comp.Request_NewOperation.NewOperation.In.JTipoJornada, class=com.sap.tc.webdynpro.progmodel.context.DataAttributeInfo): the assigned model class info has no property JTipoJornada
    Any ideas? What else I have to do?
    Thanks & Regards
    SU

    You'r right!! Same case of my other thread.
    Thanks
    Best Regards
    SU

  • Does java has problem storing floating point numbers?

    Hi just a quick question. I have been programming in java at least 4, 5 year by now and I feel rather comfortable with programming in java. However, just other day I hit problem with java which I was hoping someone on this forum can fill in for me.
    Now please consider following simple statement:
    double d = 3.0 / 5 / 3;
    and lets say I printed this number
    why does java compute it as 0.19999999999999998 rather than 0.2
    and 2.44 � 7.006 as -4.566000000000001 instead of �4.566
    Frankly, until now I never know java behaved this way and it seems so bizarre.
    I�ve wrote similar program in c and perl just see what happens and they produced an expected result.
    Anyway the program I was writing at the time was really trivial stuff and this problem does not need argent solution but I would like know why did is happening and what might be the solution for it.
    Oh, just in case, the version of JDK I am using right now is (build 1.4.2-b28)
    Thanks

    Take a look at some of these links:
    http://java.sun.com/developer/JDCTechTips/2003/tt0204.html#2
    http://java.sun.com/developer/JDCTechTips/2001/tt0807.html#tip1

  • Migrate to the Java 2 security model

    Hi, I've tried to use signed applets but I always get the following message:
    Java (TM) Plug-in: Version 1.3.1_02
    Netscape security model is no longer supported.
    Please migrate to the Java 2 security model instead.
    Netscape security model is no longer supported.
    Please migrate to the Java 2 security model instead.
    Netscape security model is no longer supported.
    Please migrate to the Java 2 security model instead.
    Netscape security model is no longer supported.
    Please migrate to the Java 2 security model instead.
    Netscape security model is no longer supported.
    Please migrate to the Java 2 security model instead.
    I'm using IExplorer 5.5 with the Java Plug-In 1.3.1_02.
    What does it mean 'migrate to the Java 2 security model'?
    How can I migrate?
    thanks in advance.

    So you mean your applet is working in Netscape 6.2 after editing prefs.js. In that case, one possible solution is take away the support of netscape.security.* in your applet . Because netscape.* packages 'might' use the Netscape Security model, which is no longer supported(check out). Hence the system asks you to migrate to the current java security model. Even if you remove the netscape.* support, your applet will work, if you have signed it properly. In that case, you don't have to touch prefs.js or java.policy or anything from your client machine.(provided you use standard certificates like verisign).
    Since you have only class file of the applet and not the source, decompile the class file and make the alteration and compile it back. A decompiler Jad is available here http://midlet.org/jsp/category.jsp?parentLevel=137.
    Let me know if this has helped you.
    Rajesh

  • I am trying to use java  file as Model layer and jsf as presentation layer

    I am trying to use java file as Model layer and jsf as presentation layer and need some help
    I successfully get the value of h:outputText from java file by doing simple binding operation but I am facing problems when I am trying to fill h:dataTable
    I create java file
    package oracle.model;
    import java.sql.;*
    import java.util.;*
    *public class TableBean {*
    Connection con ;
    Statement ps;
    ResultSet rs;
    private List perInfoAll = new ArrayList();
    *public List getperInfoAll() {*
    perInfoAll.add(0,new perInfo("name","username","blablabla"));
    return perInfoAll;
    *public class perInfo {*
    String uname;
    String firstName;
    String lastName;
    *public perInfo(String firstName,String lastName,String uname) {*
    this.uname = uname;
    this.firstName = firstName;
    this.lastName = lastName;
    *public String getUname() {*
    return uname;
    *public String getFirstName() {*
    return firstName;
    *public String getLastName() {*
    return lastName;
    right click on the file and choose 'create data control'
    then i wrote the jsf file:
    *<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>*
    *<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>*
    *<f:view>*
    *<h:dataTable id="dt1" value="#{bindings.perInfoAll}"*
    var="item" bgcolor="#F1F1F1" border="10"
    cellpadding="5" cellspacing="3" rows="4" width="50%"
    dir="LTR" frame="hsides" rules="all"
    *>*
    *<f:facet name="header">*
    *<h:outputText value="This is 'dataTable' demo" id="ot6"/>*
    *</f:facet>*
    *<h:column id="c2">*
    *<f:facet name="header">*
    *<h:outputText value="First Name" id="ot1"/>*
    *</f:facet>*
    *<h:outputText style="" value="#{item.firstName}"*
    id="ot2"/>
    *</h:column>*
    *<h:column id="c4">*
    *<f:facet name="header">*
    *<h:outputText value="Last Name" id="ot9"/>*
    *</f:facet>*
    *<h:outputText value="#{item.lastName}" id="ot8"/>*
    *</h:column>*
    *<h:column id="c3">*
    *<f:facet name="header">*
    *<h:outputText value="Username" id="ot7"/>*
    *</f:facet>*
    *<h:outputText value="#{item.uname}" id="ot4"/>*
    *</h:column>*
    *<f:facet name="footer">*
    *<h:outputText value="The End" id="ot3"/>*
    *</f:facet>*
    *</h:dataTable>*
    *</center>*
    *</af:document>*
    *</f:view>*
    but nothing is appear in my table
    I know that there is something wrong in calling the binding object
    I need help pls and where can i find some help to deal with another tag types
    thanks

    i dragged the "perInfoAll" from my "Data Controls" and choosed adf table (even I know that new table with adf tags well be generated and i want table with jsf tags)
    and this code is generated
    *<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"*
    *"http://www.w3.org/TR/html4/loose.dtd">*
    *<%@ page contentType="text/html;charset=UTF-8"%>*
    *<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>*
    *<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>*
    *<%@ taglib uri="http://xmlns.oracle.com/adf/faces/rich" prefix="af"%>*
    *<f:view>*
    *<af:document id="d1">*
    *<af:messages id="m1"/>*
    *<af:form id="f1">*
    *<af:table value="#{bindings.perInfoAll1.collectionModel}" var="row"*
    *rows="#{bindings.perInfoAll1.rangeSize}"*
    *emptyText="#{bindings.perInfoAll1.viewable ? 'No data to display.' : 'Access Denied.'}"*
    *fetchSize="#{bindings.perInfoAll1.rangeSize}"*
    *rowBandingInterval="0"*
    *selectionListener="#{bindings.perInfoAll1.collectionModel.makeCurrent}"*
    *rowSelection="multiple" id="t1">*
    *<af:column sortProperty="uname" sortable="false"*
    *headerText="#{bindings.perInfoAll1.hints.uname.label}"*
    *id="c1">*
    *<af:inputText value="#{row.bindings.uname.inputValue}"*
    *label="#{bindings.perInfoAll1.hints.uname.label}"*
    *required="#{bindings.perInfoAll1.hints.uname.mandatory}"*
    *columns="#{bindings.perInfoAll1.hints.uname.displayWidth}"*
    *maximumLength="#{bindings.perInfoAll1.hints.uname.precision}"*
    *shortDesc="#{bindings.perInfoAll1.hints.uname.tooltip}"*
    *id="it3">*
    *<f:validator binding="#{row.bindings.uname.validator}"/>*
    *</af:inputText>*
    *</af:column>*
    *<af:column sortProperty="firstName" sortable="false"*
    *headerText="#{bindings.perInfoAll1.hints.firstName.label}"*
    *id="c2">*
    *<af:inputText value="#{row.bindings.firstName.inputValue}"*
    *label="#{bindings.perInfoAll1.hints.firstName.label}"*
    *required="#{bindings.perInfoAll1.hints.firstName.mandatory}"*
    *columns="#{bindings.perInfoAll1.hints.firstName.displayWidth}"*
    *maximumLength="#{bindings.perInfoAll1.hints.firstName.precision}"*
    *shortDesc="#{bindings.perInfoAll1.hints.firstName.tooltip}"*
    *id="it2">*
    *<f:validator binding="#{row.bindings.firstName.validator}"/>*
    *</af:inputText>*
    *</af:column>*
    *<af:column sortProperty="lastName" sortable="false"*
    *headerText="#{bindings.perInfoAll1.hints.lastName.label}"*
    *id="c3">*
    *<af:inputText value="#{row.bindings.lastName.inputValue}"*
    *label="#{bindings.perInfoAll1.hints.lastName.label}"*
    *required="#{bindings.perInfoAll1.hints.lastName.mandatory}"*
    *columns="#{bindings.perInfoAll1.hints.lastName.displayWidth}"*
    *maximumLength="#{bindings.perInfoAll1.hints.lastName.precision}"*
    *shortDesc="#{bindings.perInfoAll1.hints.lastName.tooltip}"*
    *id="it1">*
    *<f:validator binding="#{row.bindings.lastName.validator}"/>*
    *</af:inputText>*
    *</af:column>*
    *</af:table>*
    *</af:form>*
    *</af:document>*
    *</f:view>*
    but when run it i see the following errors
    *Class oracle.adf.model.adapter.bean.BeanDataControl can not access a member of class nl.amis.hrm.EmpManager with modifiers "private"*
    *Object EmpManager of type DataControl is not found.*
    *java.lang.NullPointerException*
    *Class oracle.adf.model.adapter.bean.BeanDataControl can not access a member of class nl.amis.hrm.EmpManager with modifiers "private"*
    *Object EmpManager of type DataControl is not found.*
    *java.lang.NullPointerException*
    :(

  • Can't fill ByteArray in EJB-Method with generated Model-Class from WD-Model

    Hello everybody,
    i try to call an ejb-method with data from an FileUpload-UI-Element in WD. The EJB-Method is receiving the byte-data to create a document in KM via a Web-Service.
    The ebj-methid has the following signature:
    public FObject putFileDataSimple (byte [] btContent, String fullFileName, String username, String password)
    After importing the Model and creating a context node i have the following structure:
    Request_X_putFileDataSimple
    +---btContent (Node)
          +-- item
    + fullFileName
    + username
    + password
    btContent is of the generated Type Byte_Item, which is itself a generated Model-Class of modelClassType ARRAY
    item is of Type byte
    But i simply have problems to fill the context node (or the binded model-object). i tried different ways and looked at thread [https://www.sdn.sap.com/irj/scn/thread?messageID=1954223] but i cant get it work.
    So my Method in WD looks like this to fill the structure and start the ejb-method:
    public boolean putKMDataSimple( com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource fin )  {
    try
      wdContext.currentRequest_X_putFileDataSimpleElement().setFullFileName("abc");
      wdContext.currentRequest_X_putFileDataSimpleElement().setUsername("def");
      wdContext.currentRequest_X_putFileDataSimpleElement().setPassword("xxx");
      byte[] buffer = new byte[1];
      InputStream in = fin.read(false);
      int i = 1;
      int j = 0;
      while (i!=-1)
         i = in.read(buffer);
         if (i!=-1)
           Byte_Item bi = new Byte_Item(mAlf);     // mAlf ist global defined Model-Class-Instance
           bi.setItem(buffer[0]);
            wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().addBtContent(bi);
      wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().execute();
    Doing this results in Error-Messages like:
    Model-Object is not a complex type for every byte added this way.
    And finally an IllegalArgumentException at java.lang.reflect.Array.set(Native Method)
    The second way i tried is:
    public boolean putKMDataSimple( com.sap.tc.webdynpro.services.sal.datatransport.api.IWDResource fin )  {
    try
      wdContext.currentRequest_X_putFileDataSimpleElement().setFullFileName("abc");
      wdContext.currentRequest_X_putFileDataSimpleElement().setUsername("def");
      wdContext.currentRequest_X_putFileDataSimpleElement().setPassword("xxx");
      byte[] buffer = new byte[1];
      ArrayList<Byte> btlist = new ArrayList<Byte>();
      InputStream in = fin.read(false);
      int i = 1;
      int j = 0;
      while (i!=-1)
         i = in.read(buffer);
         if (i!=-1)
              btList.add(buffer[0]);
      wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().setBtContent(btList);
      wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().execute();
    Trying so results in:
    java.lang.ClassCastException: class java.lang.Byte:null incompatible with interface com.sap.tc.cmi.model.ICMIModelClass:library:com.sap.tc.cmi(at-sign)[email protected]@alive
    whenn calling the setBtContent Method
    I don't what to do now to fill the context/model-object the right way.
    Any helpfull hints are very welcome
    Edited by: Matthias Hayk on Dec 1, 2008 5:51 PM
    Edited by: Matthias Hayk on Dec 2, 2008 10:56 AM

    Ok Vesselin and thanx for your idea,
    so i adapted the source in the way you told like the following:
                     ArrayList<Byte_Item> btlist = new ArrayList<Byte_Item>();
                     byte[] buffer = new byte[1];
                     InputStream in = fin.read(false);
                     int i = 1;
                     int j = 0;
                     while (i!=-1)
                          i = in.read(buffer);
                          if (i!=-1)
                               // Byte gelesen
                               Byte_Item bi = new Byte_Item(mAlf);
                               bi.setItem(buffer[0]);
                               btlist.add(bi);
                               j++;
                     wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().setBtContent(btlist);     
                     wdContext.currentRequest_X_putFileDataSimpleElement().modelObject().execute();
    This results also in the following Exception when exceuting the WS-proxy:
    execute
    [EXCEPTION]
    java.lang.IllegalArgumentException
    at java.lang.reflect.Array.set(Native Method)
    at com.sap.tc.webdynpro.model.ejb.model.EJBGenericModelClassExecutable.getInputParameters(EJBGenericModelClassExecutable.java:215)
    at com.sap.tc.webdynpro.model.ejb.model.EJBGenericModelClassExecutable.execute(EJBGenericModelClassExecutable.java:112)

  • C calling java package fails....

    Hello;
    I created a C program to call a native java program. I have the program in a directory named world. I works great,but when I change the program and create a package and try to execute the FindClass to the package version I can not find it. Since I am new to Java, I need some guidance on this topic.
    set CLASSPATH=c:\world
    Here is a sample of my code:
    ================================
    /* Load the Java VM DLL */
    memset (&vm_args, 0, sizeof(vm_args));
    vm_args.version=JNI_VERSION_1_2;
    vm_args.options = options;
    vm_args.nOptions = 1;
    options[0].optionString = "-Djava.class.path=.";
    vm_args.ignoreUnrecognized = TRUE;
    res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);
    if (res < 0) {
    fprintf(stderr, "Can't create Java VM\n");
              return 0;
    cls = env->FindClass("world.HelloWorld");
    ====================================
    I do not get a return address.

    From the spec:
    FindClass
    jclass FindClass(JNIEnv *env, const char *name);
    This function loads a locally-defined class. It searches the directories and zip files specified by the CLASSPATH environment variable for the class with the specified name.
    PARAMETERS:
    env: the JNI interface pointer.
    name: a fully-qualified class name (that is, a package name, delimited by �/�, followed by the class name). If the name begins with �[� (the array signature character), it returns an array class.
    RETURNS:
    Returns a class object from a fully-qualified name, or NULL if the class cannot be found.
    THROWS:
    ClassFormatError: if the class data does not specify a valid class.
    ClassCircularityError: if a class or interface would be its own superclass or superinterface.
    NoClassDefFoundError: if no definition for a requested class or interface can be found.
    OutOfMemoryError: if the system runs out of memory. Therefore leave the slash there, it has nothing to do with Windows file separators.
    It's probably related with the classpath.
    Can you post here the HelloWorld.java contents and all the relevant directory contents?
    And in which directory you are excatly when you execute the exe?

  • System.load(PATH_TO_LIB) issue inside java package

    Hi all,
    sorry if this has been asked somewhere, but I just could not find any answer of it. I simply want to load a library by using System.load(ABSOLUTE_PATH_TO_LIB) and call its native function. I could get this to work if I call this function in a class without having any package to it.
    However, when I moved the class into a package, e.g. com.test package, I will get java.lang.UnsatisfiedLinkError exception. I am certain the System.load could still reference to the lib I pointed to, just that the library is not really loaded and resulting in this error when I call the native method. Any help would be greatly appreciated, thanks in advance.
    Sudi

    Hi, thanks for the reply.
    I have found the problem, the problem was not in the System.load, as I mentioned earlier, I can load the library, but I got unsatisfied link error when I call the native function inside a java package.
    The reason to this is the C native function actually does not allow me to call the function from a java package. If I want to call it from a package, then I have to regenerate the header file and the C source code, namely every functions gonna have the package name follow, e.g. au_com_siab_java_helloworld. something similiar to that. Too bad, this is an existing library that I am trying to use and I don't have the source code to change. Thanks all.

Maybe you are looking for