You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Le Van <lv...@it.fts-vn.com> on 2006/05/04 05:01:42 UTC
t:commandButton action method not called
Hi all,
I got a problem with t:commandButton. I have Search screen. First, I
push Search button to get data from DB. Then I push OutputCSV button to
get data results as csv file. Everything is OK.Now I push search again,
but action is not been called for all command button on the screen (
except h:commandLink can take an action). Here is my code to get data as
csv.
public String outputCSVAction() {
FacesContext facesContext =
FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse)
facesContext.getExternalContext().getResponse();
ByteArrayOutputStream arrayOutputStream = new
ByteArrayOutputStream();
List dataList = pageObject.getDataList();
for (Iterator iter = dataList.iterator(); iter.hasNext();) {
TM00403ItemRow element = (TM00403ItemRow) iter.next();
prepareCSV(element, arrayOutputStream);
}
response.setContentType("application/x-download;
charset=shift_jis");
response.setHeader("Content-disposition","attachment;
filename=\"" + TMCommonConstants.OUTPUT_CSV + "\"");
ServletOutputStream outputStream =
response.getOutputStream();
outputStream.write(arrayOutputStream.toByteArray());
response.setContentLength(arrayOutputStream.size());
outputStream.flush();
outputStream.close();
facesContext.responseComplete();
}
Could anyone help me ?
Thanks for advance,
Van Le
Re: t:commandButton action method not called
Posted by Le Van <lv...@it.fts-vn.com>.
Thanks for your advice. I try your code but I can't solved the problem.
I port that code to other screen, it work fine. So I think the problem
maybe from .jsp. :-) Life goes on.
Murat Hazer wrote:
> sorry accidently sent the mail...
>
> last line should be like this;
>
> outputStream.close();
> outputStream.flush();
> facesContext.getApplication
> ().getStateManager().saveSerializedView(facesContext);
> facesContext.responseComplete();
>
>
>
> On 5/4/06, *Murat Hazer* <murathazer@gmail.com
> <ma...@gmail.com>> wrote:
>
> I had the same issue with jasper reports and
> facesContext.getApplication().getStateManager().saveSerializedView(facesContext)
> solved my problem, i took a look at the your code and it's same as
> mine, only difference is there is outputStream.flush() after the
> outputStream.close(), so your code's last lines should be like this;
>
> outputStream.close();
> outputStream.flush();
>
> facesContext.responseComplete ();
> facesContext.getApplication
> ().getStateManager().saveSerializedView(facesContext);
>
> I hope it works...
>
> regards...
>
>
> On 5/4/06, *Le Van* < lvan@it.fts-vn.com
> <ma...@it.fts-vn.com>> wrote:
>
> I did it before but the problem still occur. So do u think the
> reason is
> JSF or I get wrong somewhere ?. I checked my code. Uhm...I'm
> not sure all.
> Do you have any idea more ??
> Murat Hazer wrote:
>
>> add this line just before facesContext.responseComplete()
>>
>> facesContext.getApplication
> ().getStateManager().saveSerializedView(
>> facesContext);
>>
>> regards...
>>
>> On 5/4/06, *Le Van* < lvan@it.fts-vn.com
> <ma...@it.fts-vn.com> <mailto: lvan@it.fts-vn.com
> <ma...@it.fts-vn.com>>>
>> wrote:
>>
>> Hi all,
>> I got a problem with t:commandButton. I have Search screen.
>> First, I push Search button to get data from DB. Then I push
>> OutputCSV button to get data results as csv file.
> Everything is
>> OK.Now I push search again, but action is not been called
> for all
>> command button on the screen ( except h:commandLink can
> take an
>> action). Here is my code to get data as csv.
>> public String outputCSVAction() {
>> FacesContext facesContext =
>> FacesContext.getCurrentInstance();
>> HttpServletResponse response =
>> (HttpServletResponse)
> facesContext.getExternalContext().getResponse();
>> ByteArrayOutputStream arrayOutputStream = new
>> ByteArrayOutputStream();
>> List dataList = pageObject.getDataList();
>> for (Iterator iter = dataList.iterator();
>> iter.hasNext();) {
>> TM00403ItemRow element = (TM00403ItemRow)
>> iter.next ();
>> prepareCSV(element, arrayOutputStream);
>> }
>>
> response.setContentType("application/x-download;
>> charset=shift_jis");
>>
>> response.setHeader("Content-disposition","attachment;
> filename=\""
>> + TMCommonConstants.OUTPUT_CSV + "\"");
>> ServletOutputStream outputStream =
>> response.getOutputStream();
>>
> outputStream.write(arrayOutputStream.toByteArray());
>>
> response.setContentLength(arrayOutputStream.size());
>> outputStream.flush();
>> outputStream.close();
>> facesContext.responseComplete();
>> }
>> Could anyone help me ?
>> Thanks for advance,
>> Van Le
>>
>>
>>
>>
>> --
>> Murat HAZER
>> Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
>> Tel - Phone: +90 222 335 05 80 - 1395
>> Cep Tel - Mobile Phone: +90 532 472 00 63
>> Blog URL: http://www.projedunyasi.org
>> Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/
>
>
>
>
>
> --
> Murat HAZER
> Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
> Tel - Phone: +90 222 335 05 80 - 1395
> Cep Tel - Mobile Phone: +90 532 472 00 63
> Blog URL: http://www.projedunyasi.org
> Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/
>
>
>
>
> --
> Murat HAZER
> Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
> Tel - Phone: +90 222 335 05 80 - 1395
> Cep Tel - Mobile Phone: +90 532 472 00 63
> Blog URL: http://www.projedunyasi.org
> Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/
Re: t:commandButton action method not called
Posted by Murat Hazer <mu...@gmail.com>.
sorry accidently sent the mail...
last line should be like this;
outputStream.close();
outputStream.flush();
facesContext.getApplication().getStateManager().saveSerializedView(facesContext);
facesContext.responseComplete();
On 5/4/06, Murat Hazer <mu...@gmail.com> wrote:
>
> I had the same issue with jasper reports and facesContext.getApplication().getStateManager().saveSerializedView(facesContext)
> solved my problem, i took a look at the your code and it's same as mine,
> only difference is there is outputStream.flush() after the
> outputStream.close(), so your code's last lines should be like this;
>
> outputStream.close();
> outputStream.flush();
>
> facesContext.responseComplete();
> facesContext.getApplication().getStateManager().saveSerializedView(facesContext);
>
> I hope it works...
>
> regards...
>
>
> On 5/4/06, Le Van < lvan@it.fts-vn.com> wrote:
> >
> > I did it before but the problem still occur. So do u think the reason is
> >
> > JSF or I get wrong somewhere ?. I checked my code. Uhm...I'm not sure
> > all.
> > Do you have any idea more ??
> > Murat Hazer wrote:
> >
> > > add this line just before facesContext.responseComplete()
> > >
> > > facesContext.getApplication ().getStateManager().saveSerializedView(
> > > facesContext);
> > >
> > > regards...
> > >
> > > On 5/4/06, *Le Van* <lvan@it.fts-vn.com <mailto: lvan@it.fts-vn.com>>
> > > wrote:
> > >
> > > Hi all,
> > > I got a problem with t:commandButton. I have Search screen.
> > > First, I push Search button to get data from DB. Then I push
> > > OutputCSV button to get data results as csv file. Everything is
> > > OK.Now I push search again, but action is not been called for all
> > > command button on the screen ( except h:commandLink can take an
> > > action). Here is my code to get data as csv.
> > > public String outputCSVAction() {
> > > FacesContext facesContext =
> > > FacesContext.getCurrentInstance();
> > > HttpServletResponse response =
> > > (HttpServletResponse) facesContext.getExternalContext
> > ().getResponse();
> > > ByteArrayOutputStream arrayOutputStream = new
> > > ByteArrayOutputStream();
> > > List dataList = pageObject.getDataList();
> > > for (Iterator iter = dataList.iterator();
> > > iter.hasNext();) {
> > > TM00403ItemRow element = (TM00403ItemRow)
> > > iter.next ();
> > > prepareCSV(element, arrayOutputStream);
> > > }
> > > response.setContentType("application/x-download;
> > > charset=shift_jis");
> > >
> > > response.setHeader("Content-disposition","attachment; filename=\""
> > > + TMCommonConstants.OUTPUT_CSV + "\"");
> > > ServletOutputStream outputStream =
> > > response.getOutputStream();
> > > outputStream.write(arrayOutputStream.toByteArray
> > ());
> > > response.setContentLength(arrayOutputStream.size
> > ());
> > > outputStream.flush();
> > > outputStream.close();
> > > facesContext.responseComplete();
> > > }
> > > Could anyone help me ?
> > > Thanks for advance,
> > > Van Le
> > >
> > >
> > >
> > >
> > > --
> > > Murat HAZER
> > > Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
> > > Tel - Phone: +90 222 335 05 80 - 1395
> > > Cep Tel - Mobile Phone: +90 532 472 00 63
> > > Blog URL: http://www.projedunyasi.org
> > > Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/
> >
> >
> >
>
>
> --
> Murat HAZER
> Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
> Tel - Phone: +90 222 335 05 80 - 1395
> Cep Tel - Mobile Phone: +90 532 472 00 63
> Blog URL: http://www.projedunyasi.org
> Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/
>
--
Murat HAZER
Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
Tel - Phone: +90 222 335 05 80 - 1395
Cep Tel - Mobile Phone: +90 532 472 00 63
Blog URL: http://www.projedunyasi.org
Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/
Re: t:commandButton action method not called
Posted by Murat Hazer <mu...@gmail.com>.
I had the same issue with jasper reports and
facesContext.getApplication().getStateManager().saveSerializedView(facesContext)
solved my problem, i took a look at the your code and it's same as mine,
only difference is there is outputStream.flush() after the
outputStream.close(), so your code's last lines should be like this;
outputStream.close();
outputStream.flush();
facesContext.responseComplete();
facesContext.getApplication
().getStateManager().saveSerializedView(facesContext);
I hope it works...
regards...
On 5/4/06, Le Van <lv...@it.fts-vn.com> wrote:
>
> I did it before but the problem still occur. So do u think the reason is
> JSF or I get wrong somewhere ?. I checked my code. Uhm...I'm not sure
> all.
> Do you have any idea more ??
> Murat Hazer wrote:
>
> > add this line just before facesContext.responseComplete()
> >
> > facesContext.getApplication().getStateManager().saveSerializedView(
> > facesContext);
> >
> > regards...
> >
> > On 5/4/06, *Le Van* <lvan@it.fts-vn.com <ma...@it.fts-vn.com>>
> > wrote:
> >
> > Hi all,
> > I got a problem with t:commandButton. I have Search screen.
> > First, I push Search button to get data from DB. Then I push
> > OutputCSV button to get data results as csv file. Everything is
> > OK.Now I push search again, but action is not been called for all
> > command button on the screen ( except h:commandLink can take an
> > action). Here is my code to get data as csv.
> > public String outputCSVAction() {
> > FacesContext facesContext =
> > FacesContext.getCurrentInstance();
> > HttpServletResponse response =
> > (HttpServletResponse) facesContext.getExternalContext
> ().getResponse();
> > ByteArrayOutputStream arrayOutputStream = new
> > ByteArrayOutputStream();
> > List dataList = pageObject.getDataList();
> > for (Iterator iter = dataList.iterator();
> > iter.hasNext();) {
> > TM00403ItemRow element = (TM00403ItemRow)
> > iter.next();
> > prepareCSV(element, arrayOutputStream);
> > }
> > response.setContentType("application/x-download;
> > charset=shift_jis");
> >
> > response.setHeader("Content-disposition","attachment; filename=\""
> > + TMCommonConstants.OUTPUT_CSV + "\"");
> > ServletOutputStream outputStream =
> > response.getOutputStream();
> > outputStream.write(arrayOutputStream.toByteArray());
> > response.setContentLength(arrayOutputStream.size());
> > outputStream.flush();
> > outputStream.close();
> > facesContext.responseComplete();
> > }
> > Could anyone help me ?
> > Thanks for advance,
> > Van Le
> >
> >
> >
> >
> > --
> > Murat HAZER
> > Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
> > Tel - Phone: +90 222 335 05 80 - 1395
> > Cep Tel - Mobile Phone: +90 532 472 00 63
> > Blog URL: http://www.projedunyasi.org
> > Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/
>
>
>
--
Murat HAZER
Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
Tel - Phone: +90 222 335 05 80 - 1395
Cep Tel - Mobile Phone: +90 532 472 00 63
Blog URL: http://www.projedunyasi.org
Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/
Re: t:commandButton action method not called
Posted by Le Van <lv...@it.fts-vn.com>.
I did it before but the problem still occur. So do u think the reason is
JSF or I get wrong somewhere ?. I checked my code. Uhm...I'm not sure all.
Do you have any idea more ??
Murat Hazer wrote:
> add this line just before facesContext.responseComplete()
>
> facesContext.getApplication().getStateManager().saveSerializedView(
> facesContext);
>
> regards...
>
> On 5/4/06, *Le Van* <lvan@it.fts-vn.com <ma...@it.fts-vn.com>>
> wrote:
>
> Hi all,
> I got a problem with t:commandButton. I have Search screen.
> First, I push Search button to get data from DB. Then I push
> OutputCSV button to get data results as csv file. Everything is
> OK.Now I push search again, but action is not been called for all
> command button on the screen ( except h:commandLink can take an
> action). Here is my code to get data as csv.
> public String outputCSVAction() {
> FacesContext facesContext =
> FacesContext.getCurrentInstance();
> HttpServletResponse response =
> (HttpServletResponse) facesContext.getExternalContext().getResponse();
> ByteArrayOutputStream arrayOutputStream = new
> ByteArrayOutputStream();
> List dataList = pageObject.getDataList();
> for (Iterator iter = dataList.iterator();
> iter.hasNext();) {
> TM00403ItemRow element = (TM00403ItemRow)
> iter.next();
> prepareCSV(element, arrayOutputStream);
> }
> response.setContentType("application/x-download;
> charset=shift_jis");
>
> response.setHeader("Content-disposition","attachment; filename=\""
> + TMCommonConstants.OUTPUT_CSV + "\"");
> ServletOutputStream outputStream =
> response.getOutputStream();
> outputStream.write(arrayOutputStream.toByteArray());
> response.setContentLength(arrayOutputStream.size());
> outputStream.flush();
> outputStream.close();
> facesContext.responseComplete();
> }
> Could anyone help me ?
> Thanks for advance,
> Van Le
>
>
>
>
> --
> Murat HAZER
> Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
> Tel - Phone: +90 222 335 05 80 - 1395
> Cep Tel - Mobile Phone: +90 532 472 00 63
> Blog URL: http://www.projedunyasi.org
> Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/
Re: t:commandButton action method not called
Posted by Murat Hazer <mu...@gmail.com>.
add this line just before facesContext.responseComplete()
facesContext.getApplication().getStateManager().saveSerializedView(
facesContext);
regards...
On 5/4/06, Le Van <lv...@it.fts-vn.com> wrote:
>
> Hi all,
> I got a problem with t:commandButton. I have Search screen. First, I push
> Search button to get data from DB. Then I push OutputCSV button to get data
> results as csv file. Everything is OK.Now I push search again, but action
> is not been called for all command button on the screen ( except
> h:commandLink can take an action). Here is my code to get data as csv.
> public String outputCSVAction() {
> FacesContext facesContext =
> FacesContext.getCurrentInstance();
> HttpServletResponse response = (HttpServletResponse)
> facesContext.getExternalContext().getResponse();
> ByteArrayOutputStream arrayOutputStream = new
> ByteArrayOutputStream();
> List dataList = pageObject.getDataList();
> for (Iterator iter = dataList.iterator(); iter.hasNext();)
> {
> TM00403ItemRow element = (TM00403ItemRow) iter.next();
> prepareCSV(element, arrayOutputStream);
> }
> response.setContentType("application/x-download;
> charset=shift_jis");
> response.setHeader("Content-disposition","attachment;
> filename=\"" + TMCommonConstants.OUTPUT_CSV + "\"");
> ServletOutputStream outputStream =
> response.getOutputStream();
> outputStream.write(arrayOutputStream.toByteArray());
> response.setContentLength(arrayOutputStream.size());
> outputStream.flush();
> outputStream.close();
> facesContext.responseComplete();
> }
> Could anyone help me ?
> Thanks for advance,
> Van Le
>
--
Murat HAZER
Elektrik-Elektronik Mühendisi - Electrical-Electronics Engineer
Tel - Phone: +90 222 335 05 80 - 1395
Cep Tel - Mobile Phone: +90 532 472 00 63
Blog URL: http://www.projedunyasi.org
Yahoo Group: http://groups.yahoo.com/group/malatyafenlisesi/