Micky Kr

Greenhorn
+ Follow
since Apr 28, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Micky Kr

Good One...So How Many In Batch You Cover
13 years ago
Hi ,
Iam using rich:panelMenu it working fine but in the target jsp(conferenceCall.jsp) when iam trying to use a4j:commandButton/h:commandButton action not working in this page !
Below is my code and cinfiguration
================================================================================================================

LeftMenu.jsp
===========



============================================

Help me please

14 years ago
JSF
I Have to Implement file Upload and Download functionality in my current application Technology I am using is JSF+Richfaces+Spring+Hibenrate+MYSQL

Till Now i am able to implement file upload functionality successfully and facing problem in Downloading the file below is my Code ;


---------------------------------------JSP File Upload-------------------------------------------
<rich:fileUpload id="upload" fileUploadListener="#{projectDetailManageBean.fileUploadListener}" maxFilesQuantity="5" listHeight="180" listWidth="420"/>


---------------------------------------fileUploadListener-------------------------------------------

public void fileUploadListener(UploadEvent event) throws Exception{
UploadItem item = event.getUploadItem();
String FullfileName = item.getFileName();
String fileName=FullfileName.substring(FullfileName.lastIndexOf("\\")1);
System.out.println("File Name :" fileName);
ExternalContext con = FacesContext.getCurrentInstance().getExternalContext();
ServletContext sCon = (ServletContext) con.getContext();
String filepath = sCon.getRealPath("/");
try{
java.io.File uploadFile = new java.io.File(filepath, fileName);
FileInputStream fis = new FileInputStream(item.getFile());
FileOutputStream out = new FileOutputStream(filepath+fileName);
int bytes = 0;
byte[] bteFile = new byte[(int)event.getUploadItem().getFile().length()];
UploadFileDetail uploadFileDetail = new UploadFileDetail();
uploadFileDetail.setDistroContent( fis );
uploadFileDetail.setUploadFileName(item.getFileName());
uploadFileDetail.setFileSize(event.getUploadItem().getFile().length());
uploadFileDetailList.add(uploadFileDetail);

}
uploadsAvailable--;

} catch(Exception ex){

ex.printStackTrace();

}finally{
//ps.close();
//fis.close();

}
}


===============================Java ============================================


for(Iterator<UploadFileDetail> it =uploadFileDetailList.iterator();it.hasNext();){
UploadFileDetail uploadFileDetail=it.next();

uploadFileDetail.setProject(proForPD);
uploadFileDetail.setReferenceId(revisionNo);
uploadFileDetail.setReferenceName("Add Revision");
uploadFileDetail.setEneteredBy(getSessionUser());
uploadFileDetail.setEneteredOn(FacesUtil.time());
fileUploadDao.saveUploadedFiles(uploadFileDetail);


uploadFileDetailList=new ArrayList<UploadFileDetail>();
}

===============================Dao Implementaion============================================
public class FileUploadDaoImpl extends HibernateDaoSupport implements FileUploadDao {

public void saveUploadedFiles(UploadFileDetail uploadFileDetail) {
Session session = getHibernateTemplate().getSessionFactory().getCurrentSession();
Transaction transaction = session.beginTransaction();
transaction.begin();
session.save(uploadFileDetail);
session.flush();
session.refresh(uploadFileDetail);
transaction.commit();
}

public List<UploadFileDetail> getFilesDetailList(int projectId, int pdNumber) {
Session session = getHibernateTemplate().getSessionFactory().getCurrentSession();
Transaction transaction = session.getTransaction();
transaction.begin();
List<UploadFileDetail> downloadFileList = session.createQuery("from UploadFileDetail order by eneteredOn desc").list();
transaction.commit();
return downloadFileList;
}

}




============================================================================================================================================
===============================FileUploadDetail Bean============================================

package pil.pdm.model.businessobject.project;

import java.sql.Timestamp;
import pil.pdm.view.util.;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.sql.Blob;
import java.sql.SQLException;
import org.hibernate.Hibernate;
import pil.pdm.model.businessobject.user.User;



/*

@author Ajay
*/
public class UploadFileDetail implements Serializable {

private long id;
private String uploadFileName;
private Blob distro = null;
private long fileSize;
private Blob fileUploded;

private int referenceId;
private String referenceName;

private Project project;

private User eneteredBy;
private User updatedBy;

private java.sql.Timestamp eneteredOn;
private java.sql.Timestamp updatedOn;


public long getFileSize() {
return fileSize;
}

public void setFileSize(long fileSize) {
this.fileSize = fileSize;
}

public Blob getFileUploded() {
return fileUploded;
}

public void setFileUploded(Blob fileUploded) {
this.fileUploded = fileUploded;
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getUploadFileName() {
return uploadFileName;
}

public void setUploadFileName(String uploadFileName) {
this.uploadFileName = uploadFileName;
}



public Blob getDistro() {
return distro;
}

public void setDistro(Blob distro) {
this.distro = distro;
}


public InputStream getDistroStream()
throws SQLException
{
if (getDistro() == null)
return null;

return getDistro().getBinaryStream();
}


public void setDistroContent( InputStream sourceStream )
throws IOException
{
setDistro( Hibernate.createBlob( sourceStream ) );
}

public User getEneteredBy() {
return eneteredBy;
}

public void setEneteredBy(User eneteredBy) {
this.eneteredBy = eneteredBy;
}

public Timestamp getEneteredOn() {
return eneteredOn;
}

public void setEneteredOn(Timestamp eneteredOn) {
this.eneteredOn = eneteredOn;
}

public int getReferenceId() {
return referenceId;
}

public void setReferenceId(int referenceId) {
this.referenceId = referenceId;
}

public String getReferenceName() {
return referenceName;
}

public void setReferenceName(String referenceName) {
this.referenceName = referenceName;
}

public User getUpdatedBy() {
return updatedBy;
}

public void setUpdatedBy(User updatedBy) {
this.updatedBy = updatedBy;
}

public Timestamp getUpdatedOn() {
return updatedOn;
}

public void setUpdatedOn(Timestamp updatedOn) {
this.updatedOn = updatedOn;
}

public Project getProject() {
return project;
}

public void setProject(Project project) {
this.project = project;
}




}

===============================hbm File============================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="pil.pdm.model.businessobject.project.UploadFileDetail" table="pdmfiles">
<id name="id">
<generator class="increment"/>
</id>
<property column="reference_id" name="referenceId"/>
<property column="reference_name" name="referenceName"/>
<property column="file_name" name="uploadFileName"/>
<property column="file_size" name="fileSize"/>
<property name="distro" not-null="true">
<column name="file_blob" sql-type="LONGBLOB" />
</property>
<property column="enetered_on" name="eneteredOn" type="timestamp"/>
<property column="updated_on" name="updatedOn" type="timestamp"/>
<many-to-one class="pil.pdm.model.businessobject.project.Project" column="project_id" lazy="false" name="project"/>
<many-to-one class="pil.pdm.model.businessobject.user.User" column="enetered_by" lazy="false" name="eneteredBy"/>
<many-to-one class="pil.pdm.model.businessobject.user.User" column="updated_by" lazy="false" name="updatedBy"/>
</class>
</hibernate-mapping>

=========================Table ==============================================================================

CREATE TABLE pdmfiles (
id int NOT NULL auto_increment,
project_id int(11),
reference_id int,
reference_name varchar(100),
file_name varchar(64) NOT NULL,
file_size int(10) unsigned NOT NULL,
file_blob longblob NOT NULL,
enetered_by int,
enetered_on date,
updated_by int,
updated_on date,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
======================================================================================================================

=================For Download My Code is In my Managed Bean======================

downloadFileDetailList=new ArrayList<UploadFileDetail>();

downloadFileDetailList=fileUploadDao.getFilesDetailList(id, Integer.parseInt(tabIndex));
==================================================================


=================My JSP======================

<tr><td>
<rich:dataTable id="downloadTable" width="50%" var="downLoadFile" value="#{projectDetailManageBean.downloadFileDetailList}">

<rich:column width="55">
<f:facet name="header"><h:outputText value="Revision #"/></f:facet>
<h:outputText value="#{downLoadFile.referenceId}" />
</rich:column>
<rich:column width="55">
<h:outputLink value="downLoadFile?#{downLoadFile.id}">
<h:outputText value="#{downLoadFile.uploadFileName}" />
</h:outputLink>
</rich:column>
</rich:dataTable>
</td></tr>


=====================================
Some one help me now its giving HTTP Status 404 error

Thank you
14 years ago
JSF
Thank you ! But I Did not understand .can you advise me please some reference or what approach according to you i should follow . actually i have not worked much on here but now its My Responsibility to handle every thing and iam confused.Please guide me.
14 years ago
JSF
Sorry ! For Delay i Did it Now ..Thank You !
14 years ago
JSF
=====================
error
=====================
java.lang.Thread.run(Thread.java:619)
08:19:40,152 ERROR BaseXMLFilter:199 - Exception in the filter chain
javax.servlet.ServletException: viewId:/login.jsp - View /login.jsp could not be restored.
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:249)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:301)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.faces.application.ViewExpiredException: viewId:/login.jsp - View /login.jsp could not be restored.
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:187)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
... 21 more




=====================
web.xml
=====================

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">


<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<context-param>
<param-name>com.sun.faces.verifyObjects</param-name>
<param-value>false</param-value>
</context-param>

<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>

<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/faces-managed-beans.xml,/WEB-INF/faces-navigation.xml</param-value>
</context-param>

<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>

<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>

<context-param>
<param-name>com.backbase.bjsf.INVALIDATE_SESSION_ON_REFRESH</param-name>
<param-value>false</param-value>
</context-param>

<!-- Richfaces filter entry here -->
<filter>
<display-name>Ajax4jsf Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>


<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
<init-param>
<param-name>uploadMaxFileSize</param-name>
<param-value>20m</param-value>
</init-param>
</filter>



<!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>

<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

<!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>

<filter>
<filter-name>sessionFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>sessionFactoryBeanName</param-name>
<param-value>sessionFactory</param-value>
</init-param>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>sessionFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>

<session-config>
<session-timeout>30</session-timeout>
</session-config>


<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/faces/viewExpired.jsp</location>
</error-page>

<welcome-file-list>
<welcome-file>faces/login.jsp</welcome-file>
</welcome-file-list>
</web-app>




Can Any One help me please

Iam Using JSF1.2 Spring Hibernate Tomcat
14 years ago
JSF
Ok .Sure ..I Will Do it as per instruction ..But i Am Still Not getting the solution . :
14 years ago
JSF
Iam Trying to change my Name But not able to do it now will do it later np Thax
14 years ago
JSF
Hi
When Iam Log in application onward opening a new tab it redirects to Login Page ..or Entereing the URL of login page it asks for log in user id pwd again .it does not check user name and pwd

My Web.xml is







and faces.config.xml as folllows
===============================




------------
PLzz Help
14 years ago
JSF