Win a copy of Terraform in Action this week in the Cloud forum!

Subhrangshu Samanta

Greenhorn
+ Follow
since Jul 30, 2012
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Subhrangshu Samanta

Hi Andreas,

Can you provide us the entire code in "MeasuringDeviceWizardAction.jsp" and "struts.xml".

Thanks.
Subhrangshu
8 years ago

Hi All,

Regarding the Roles interceptor in Strust2, I have found only the below section from everywhere.

In struts-default.xml, we can find the below definition of Roles Interceptor.



Now, in the struts.xml of our application, we can mention the below code section in order to work with Roles interceptor.



Could you please tell me if it is the proper way to check if the user's role is the allowed one for some action.

Also, I couldn't find any method or something like that to populate user's role for Roles interceptor.

Can anyone let me know a complete example for Roles interceptor in Struts2 (specially how to populate roles in this interceptor which will be checked later with the help of request.isUserInRole(...) method).
8 years ago
Hi Kemal,

Thanks a lot. But can you please give me some light about the display of message many times for one button click in console.
Thanks
9 years ago
Hi,

Yes, I have used SwingWorker. It's great. Thanks a lot.

But, still the flickering continues as I have described before. In my JFrame, there are JPanel. Within JPanel, there are only JButton, JLabel. Is there any issue with JPanel ??

Also, after doing 1 update to database I have put some characters in System.out.println in order to test how many times it is happening for one single click in the JButton. But, with my surprise, I can see the message is coming in console many times instead of one.
Could you please allow me to know if this is a charactiristic of Swing or I am doing something wrong.


Thanks.
9 years ago
Hi Michael,

In the background means in ActionListener section I need to do all the db stuff..???
Thanks.
9 years ago
Hi,

I have succeeded to update data in JFrame properly. But, when I move to a new JFrame from the previous one (by clicking a button in the old frame), the older one is still running in background.
I am following the 4 main hints provided in internet. They are:

1. frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
2. frame.setVisible(false)
3. frame.dispose()
4. frame = null

I am using JPanel for keeping the JFrame. When I update a value twice and move to the JFrame containing the JTable, it is flickering once and then getting visible. Again, if I go for update, the JFrame is flickering twice and then getting visible. In this manner, the number of flickering increases and it slows the application.

In console, I have found that the value is updated twice. For three time, thrice this happens. Although, I am getting the correct output in my JTable (inside JFrame), but my point of view is for larger data the application will be extremely slow.

Please let me know if there is any way to completely destroy a JFrame when I am moving to a new one (so that the I can re-create the older one....and run the application in a faster way)...
Thanks.
9 years ago
Hi,

Thanks for your valuable time. But the issue is still not resolved. I think it will be better if you can see the situation I am facing. Shall I upload the project & all details of it so that you can judge better ??
Thanks.
9 years ago
Hi,

Do you mean to put the code

tmodel.fireTableDataChanged();

after data insert into database or after JTable....???
9 years ago
Hi All,

At first, when JTable is coming for the first time, it has been populated perfectly. But, after updating any existing data or inserting any new data the new result is not getting reflected into JTable. It contains the old result (displayed for the first time). Please find the code below.


I have checked & found that the ResultSet has been updated fine(data.add(d);). But, the JTable is not getting updated.

Please help me.
9 years ago
Hi,

Please find the code in my Bean class below:---



/**
*
*/
package entpkg;

import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;
import java.util.Collection;





/**
* <!-- begin-xdoclet-definition -->
* @ejb.bean name="enti"
* jndi-name="enti"
* type="CMP"
* primkey-field="id"
* schema="entiSCHEMA"
* cmp-version="2.x"
*
* @ejb.persistence
* table-name="JAVAMAN.TESTING"
*
* @ejb.finder
* query="SELECT OBJECT(a) FROM entiSCHEMA as a"
* signature="java.util.Collection findAll()"
*
* @ejb.pk class="java.math.BigDecimal"
*
*
* <!-- end-xdoclet-definition -->
* @generated
**/

public abstract class MyBean implements javax.ejb.EntityBean {

/**
*
* <!-- begin-user-doc -->
* The ejbCreate method.
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
* @ejb.create-method
* <!-- end-xdoclet-definition -->
* @generated
*/
public java.math.BigDecimal ejbCreate(java.math.BigDecimal id, java.lang.String name, java.lang.String address, java.lang.String company) throws javax.ejb.CreateException {
// EJB 2.0 spec says return null for CMP ejbCreate methods.
// TODO: YOU MUST INITIALIZE THE FIELDS FOR THE BEAN HERE.
// setMyField("Something");
// begin-user-code
setId(id);
setName(name);
setAddress(address);
setCompany(company);
return null;
// end-user-code
}

/**
* <!-- begin-user-doc -->
* The container invokes this method immediately after it calls ejbCreate.
* <!-- end-user-doc -->
*
* @generated
*/
public void ejbPostCreate(java.math.BigDecimal id, java.lang.String name, java.lang.String address, java.lang.String company) throws javax.ejb.CreateException {
// begin-user-code
// end-user-code
}

/**
*
*
* <!-- begin-user-doc -->
* CMP Field id
*
* Returns the id
* @return the id
*
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="ID"
* jdbc-type="INTEGER"
* sql-type="NUMBER"
* read-only="false"
* @ejb.pk-field
*
* @ejb.interface-method
*
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract java.math.BigDecimal getId();

/**
* <!-- begin-user-doc -->
* Sets the id
*
* @param java.math.BigDecimal the new id value
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
* @ejb.interface-method
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract void setId(java.math.BigDecimal id);

/**
*
*
* <!-- begin-user-doc -->
* CMP Field name
*
* Returns the name
* @return the name
*
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="NAME"
* jdbc-type="VARCHAR"
* sql-type="VARCHAR2"
* read-only="false"
*
*
* @ejb.interface-method
*
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract java.lang.String getName();

/**
* <!-- begin-user-doc -->
* Sets the name
*
* @param java.lang.String the new name value
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
* @ejb.interface-method
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract void setName(java.lang.String name);

/**
*
*
* <!-- begin-user-doc -->
* CMP Field address
*
* Returns the address
* @return the address
*
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="ADDRESS"
* jdbc-type="VARCHAR"
* sql-type="VARCHAR2"
* read-only="false"
*
*
* @ejb.interface-method
*
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract java.lang.String getAddress();

/**
* <!-- begin-user-doc -->
* Sets the address
*
* @param java.lang.String the new address value
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
* @ejb.interface-method
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract void setAddress(java.lang.String address);

/**
*
*
* <!-- begin-user-doc -->
* CMP Field company
*
* Returns the company
* @return the company
*
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="COMPANY"
* jdbc-type="VARCHAR"
* sql-type="VARCHAR2"
* read-only="false"
*
*
* @ejb.interface-method
*
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract java.lang.String getCompany();

/**
* <!-- begin-user-doc -->
* Sets the company
*
* @param java.lang.String the new company value
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
* @ejb.interface-method
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract void setCompany(java.lang.String company);

/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbActivate()
*/

public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbLoad()
*/
public void ejbLoad() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbPassivate()
*/
public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbRemove()
*/
public void ejbRemove() throws RemoveException, EJBException,
RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbStore()
*/
public void ejbStore() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
*/
public void setEntityContext(EntityContext arg0) throws EJBException,
RemoteException {
// TODO Auto-generated method stub

}

/* (non-Javadoc)
* @see javax.ejb.EntityBean#unsetEntityContext()
*/
public void unsetEntityContext() throws EJBException, RemoteException {
// TODO Auto-generated method stub

}

/**
*
*/
public MyBean() {
// TODO Auto-generated constructor stub
}

}



Thanks.
Yes...I agree with you about ejbPostCreate. Please find the details of ejbCreate and ejbPostCreate method below:-

/**
*
* <!-- begin-user-doc -->
* The ejbCreate method.
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
* @ejb.create-method
* <!-- end-xdoclet-definition -->
* @generated
*/
public java.math.BigDecimal ejbCreate(java.math.BigDecimal id, java.lang.String name, java.lang.String address, java.lang.String company) throws javax.ejb.CreateException {
// EJB 2.0 spec says return null for CMP ejbCreate methods.
// TODO: YOU MUST INITIALIZE THE FIELDS FOR THE BEAN HERE.
// setMyField("Something");
// begin-user-code
setId(id);
setName(name);
setAddress(address);
setCompany(company);
return null;
// end-user-code
}



/**
* <!-- begin-user-doc -->
* The container invokes this method immediately after it calls ejbCreate.
* <!-- end-user-doc -->
*
* @generated
*/
public void ejbPostCreate(java.math.BigDecimal id, java.lang.String name, java.lang.String address, java.lang.String company) throws javax.ejb.CreateException {
// begin-user-code
// end-user-code
}

Can you please help me to know what I should need to do in order to insert data into the database....(The Bean has been generated successfully but there is no data in the database)....

.....I am using JBOSS server.....my ejb-jar.xml is given below.....please allow me to know if I need to modify it....or need to do something more to insert data in the database...........



<?xml version="1.0" encoding="UTF-8"?>

<ejb-jar id="ejb-jar_1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd" version="2.1">

<description><![CDATA[EntityEJB generated by eclipse wtp xdoclet extension.]]></description>
<display-name>EntityEJB</display-name>

<enterprise-beans>

<!-- Session Beans -->
<!--
To add session beans that you have deployment descriptor info for, add
a file to your XDoclet merge directory called session-beans.xml that contains
the <session></session> markup for those beans.
-->

<!-- Entity Beans -->
<entity id="ContainerManagedEntity_enti">
<description><![CDATA[<!-- begin-xdoclet-definition -->]]></description>

<ejb-name>enti</ejb-name>

<home>entpkg.entiHome</home>
<remote>entpkg.enti</remote>
<local-home>entpkg.entiLocalHome</local-home>
<local>entpkg.entiLocal</local>

<ejb-class>entpkg.entiCMP</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.math.BigDecimal</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>entiSCHEMA</abstract-schema-name>
<cmp-field id="CMPAttribute_1">
<description><![CDATA[<!-- begin-user-doc --> CMP Field id Returns the id]]></description>
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_2">
<description><![CDATA[<!-- begin-user-doc --> CMP Field name Returns the name]]></description>
<field-name>name</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_3">
<description><![CDATA[<!-- begin-user-doc --> CMP Field address Returns the address]]></description>
<field-name>address</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_4">
<description><![CDATA[<!-- begin-user-doc --> CMP Field company Returns the company]]></description>
<field-name>company</field-name>
</cmp-field>
<primkey-field>id</primkey-field>

<query>
<query-method>
<method-name>findAll</method-name>
<method-params>
</method-params>
</query-method>
<ejb-ql><![CDATA[SELECT OBJECT(a) FROM entiSCHEMA as a]]></ejb-ql>
</query>
<!-- Write a file named ejb-finders-MyBean.xml if you want to define extra finders. -->

</entity>

<!--
To add entity beans that you have deployment descriptor info for, add
a file to your XDoclet merge directory called entity-beans.xml that contains
the <entity></entity> markup for those beans.
-->

<!-- Message Driven Beans -->
<!--
To add message driven beans that you have deployment descriptor info for, add
a file to your XDoclet merge directory called message-driven-beans.xml that contains
the <message-driven></message-driven> markup for those beans.
-->

</enterprise-beans>

<!-- Relationships -->

<!-- Assembly Descriptor -->
<!--
To specify your own assembly descriptor info here, add a file to your
XDoclet merge directory called assembly-descriptor.xml that contains
the <assembly-descriptor></assembly-descriptor> markup.
-->

<assembly-descriptor id="AssemblyDescriptor_1">
<!--
To specify additional security-role elements, add a file in the merge
directory called ejb-security-roles.xml that contains them.
-->

<!-- method permissions -->
<!--
To specify additional method-permission elements, add a file in the merge
directory called ejb-method-permissions.ent that contains them.
-->

<!-- transactions -->
<!--
To specify additional container-transaction elements, add a file in the merge
directory called ejb-container-transactions.ent that contains them.
-->

<!-- finder transactions -->

<!-- message destinations -->
<!--
To specify additional message-destination elements, add a file in the merge
directory called ejb-message-destinations.ent that contains them.
-->

<!-- exclude list -->
<!--
To specify an exclude-list element, add a file in the merge directory
called ejb-exclude-list.xml that contains it.
-->
</assembly-descriptor>

</ejb-jar>




Thank You.....
Hi All,

I have successfully created EJB Entity Bean using xdoclet(1.2.3) and JBOSS(5.1.0 GA). Please find the ejbCreate function below :

public java.math.BigDecimal ejbCreate(java.math.BigDecimal id, java.lang.String name, java.lang.String address, java.lang.String company) throws javax.ejb.CreateException {
// EJB 2.0 spec says return null for CMP ejbCreate methods.
// TODO: YOU MUST INITIALIZE THE FIELDS FOR THE BEAN HERE.
// setMyField("Something");
// begin-user-code
setId(id);
setName(name);
setAddress(address);
setCompany(company);
return null;
// end-user-code
}

From the client end I have called the create method in the Bean in the below manner:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html");
PrintWriter pw = response.getWriter();

try
{
Integer t = 2;
String str = t.toString();
BigDecimal bd = new BigDecimal(str);
entiHome h = entiUtil.getHome();
enti ben = h.create(bd, "George", "USA", "sweden");
pw.println("Bean Created.....!!!");
pw.println("Name : "+ben.getName());
pw.println("Address : "+ben.getAddress());
pw.println("Company : "+ben.getCompany());
}
catch(Exception e)
{
System.out.println("The error is : "+e.toString());
}
}

The bean is created but there is no data in the database.

I have attached the structure of the files in Eclipse[color=blue]
. Can anyone help me in this issue..........??.......it has become a nightmare..............!!!

please allow me to know if any more details is required.....
[/color]