You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Simion Ursache <si...@gmail.com> on 2007/02/03 09:11:56 UTC

Blank Struts Page after Submit

Hi !

I am learning to work with struts, after i click on submit button (in a
form) i get a blank page. This thing is annoying me because i can't find the
solution for a week !

The page has 2 hmtl list option. The first list loads info about a company
compartiments, and after hitting "Refresh Employees", the second list should
shouw data about all the employees from the selected department.

What is happening ? After hitting "Refresh Employees" i get a blank
selectAngajat.do page. If i go Back and Refresh(F5) the second list option
shows all the employees from that department.

Does anyone have any idea about this ? I posted some code down:

PersonalBody.jsp
[code]
<%@ page import="databeans.*"%>
<%@ page import="java.sql.Connection"%>
<jsp:useBean id="ss_PersSelected" class="databeans.CompartPersSelectedBean"
scope="session"/>
<html:form action="/selectAngajat.do">
<table width="600" border="1">
<tr>
<td width="174">Selectati un Compartiment:</td>
<td width="213">
<html:select property="compartid">
<%
Connection conn=Utilitati.getConexiune();
java.util.ArrayList listaCompartimente=
    ObiectPersistent.getObjects(Compartimente.class,conn,null);
conn.close();
for(int i=0;i<listaCompartimente.size();i++) {
%>
<html:option
value="<%=((Compartimente)listaCompartimente.get(i)).getCompartid()%>">
<%=((Compartimente)listaCompartimente.get(i)).getNumecompart()%>
</html:option>
<%}%> <%-- s-a inchis for-ul--%>
</html:select>

</td>
<td width="191">
<input type="submit" name="Submit" value="Refresh Employees">
</td>
</tr>
<tr>
<td width="174">Selectati Angajatul:</td>
<td width="213">
<html:select property="marcaselectata">
<% Connection conn=Utilitati.getConexiune();
if (ss_PersSelected.getCompartid() != null) //exista un compartiment
selectat
{ java.util.ArrayList listaAngajati =
    ObiectPersistent.getObjects(Personal.class,conn,
" where compartid='"+ss_PersSelected.getCompartid()+"' ");
conn.close();
for(int i=0;i<listaAngajati.size();i++){%>
<html:option
value="<%=((Personal)listaAngajati.get(i)).getMarca().toString()%>">
<%=((Personal)listaAngajati.get(i)).getNumepren()%>
</html:option>
<%}}%> <%-- inchidem FOR si IF --%>
</html:select>
</td>
<td width=" 191 ">
<input type="submit" name="Submit2" value="Show Employee">
</td>
</tr>
</table>

</html:form>

<%if (request.getSession().getAttribute("ss_DatePers") != null){%>
<tiles:insert page="/tiles/bodys/DateAngajatBody.jsp"/> <%}
    else if (ss_PersSelected.getCompartid() != null){%>
    <html:form action="/dateAngajat.do">
<html:hidden property="actiune" value="newObject"/>
<html:submit property="add" value="Angajat Nou" />
</html:form>
<%}%>
[/code]

struts-config.xml
[code]
<struts-config>

<form-beans>
    <form-bean name="loginBean" type="databeans.LoginExistingUserForm"/>
        <form-bean name="ss_PersSelected" type="
databeans.CompartPersSelectedBean"/>
 <form-bean name="ss_DatePers" type="databeans.Personal"/>
</form-beans>

<action-mappings>
<action path="/selectAngajat" type="formactions.SelectAngajatAction"
name="ss_PersSelected" input="/tiles/bodys/PersonalBody.jsp"
scope="session">
<forward name="succes" path="/pages/DatePersonal.jsp" redirect="true"/>
</action>
</action-mappings>
</struts-config>
[/code]

SelectAngajatAction.class
[code]
package formactions;

import databeans.CompartPersSelectedBean;

import databeans.ObiectPersistent;
import databeans.Personal;
import databeans.Utilitati;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class SelectAngajatAction extends Action {

    public ActionForward perform(ActionMapping mapping, ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) throws
IOException,

ServletException {
        CompartPersSelectedBean formBean = (CompartPersSelectedBean)form;
        java.sql.Connection conn = null;

        if (formBean.getMarcaselectata() != null &&
            formBean.getMarcaselectata().intValue() != -1)
            try { // incarc in sesiune obiectul Personal corespunzator
marcii selectate de utilizator
                conn = Utilitati.getConexiune();
                Personal objPersCurent =
                    (Personal)ObiectPersistent.getObjects(Personal.class,
conn,
                                                          "where marca=" +

formBean.getMarcaselectata().toString()).get(0);
                // ATENTIE! Identificatorul atributului trebuie sl fie cel
definit in Struts-Contig.xml
                request.getSession().setAttribute("ss_DatePers",
                                                  objPersCurent);


                conn.close();

            } catch (Exception e) {
                e.printStackTrace();
                if (conn != null)
                    try {
                        conn.close();
                    } catch (Exception err) {
                    err.printStackTrace();
                    }
                return mapping.findForward("eroareBD");
            }
        else // daca marca e null elimin eventualul atribut ss_DatePers
anterior
            request.getSession().removeAttribute("ss_DatePers");

        return mapping.findForward("success");
    }
}
[/code]

Re: Blank Struts Page after Submit

Posted by Dave Newton <ne...@yahoo.com>.
--- Simion Ursache <si...@gmail.com> wrote:
> Oh my god ! That was it !

Don't you hate that?! :)

I think we've *all* had that happen... I know I have,
over and over again.

IIRC a bad ActionForward will show something in the
logs, but sometimes with tiles it will just fail
silently, so I tend to look for forwarding and tiles
mis-configurations really early in the game when the
browser and logs go dark.

Dave



 
____________________________________________________________________________________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Blank Struts Page after Submit

Posted by Simion Ursache <si...@gmail.com>.
Oh my god ! That was it !

I was so tired after recoding and so on that i missed a simple one like this
!

Thank you man ! God bless you !

On 2/3/07, Dave Newton <ne...@yahoo.com> wrote:
>
> --- Simion Ursache <si...@gmail.com> wrote:
> > [... wow ...]
> > <forward name="succes"
> > [...]
> > return mapping.findForward("success");
>
> Is the snippet from the struts-config file a typo?
>
> d.
>
>
>
>
>
> ____________________________________________________________________________________
> Sucker-punch spam with award-winning protection.
> Try the free Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/features_spam.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Blank Struts Page after Submit

Posted by Dave Newton <ne...@yahoo.com>.
--- Simion Ursache <si...@gmail.com> wrote:
> [... wow ...]
> <forward name="succes"
> [...]
> return mapping.findForward("success");

Is the snippet from the struts-config file a typo?

d.



 
____________________________________________________________________________________
Sucker-punch spam with award-winning protection. 
Try the free Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/features_spam.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org