myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno Aranda" <brunoara...@gmail.com>
Subject Re: Post form to external url with method invocation
Date Tue, 16 Dec 2008 09:06:56 GMT
If using trinidad, you could do that as well by creating the form
dynamically with javascript in your backing bean method and register the
script with the ExtendedRenderKitService:

public void yourAction(ActionEvent evt) {
      FacesContext facesContext = FacesContext.getCurrentInstance();
      ExtendedRenderKitService service = Service.getRenderKitService(
facesContext, ExtendedRenderKitService.class );

      service.addScript( facesContext, createMyForm() );
}

private String createMyForm( String baseUrl, String selectedIds, String
forwardPage ) {

        StringBuilder sb = new StringBuilder( 1024 );
        sb.append( "myform = document.createElement('form');" );
        sb.append( "myform.method='post';\n" );
        sb.append( "myform.action='" ).append( baseUrl ).append( "';\n" );
        sb.append( "myform.enctype='multipart/form-data';\n" );
        sb.append( "myform.name='helloForm';\n" );
        sb.append( "myform.target='_blank';" );

        createInputHidden(sb, "myform", "MID", 123);

        sb.append("document.forms[0].parentNode.appendChild(myform);");
        sb.append( "myform.submit();\n" );

        return sb.toString();
    }

Cheers,

Bruno

2008/12/15 <jiri.pejchal@gmail.com>

>
> Hi,
>
> I'm implementing a payment to a bank from JSF application. I need to
> pass some prameters to an external https URL of the bank by POST method.
>
> I could do it with just plain form:
>
> <FORM name="form" action="https://address.cz" METHOD=POST>
> <INPUT TYPE="HIDDEN" name="MID" value="123">
> <INPUT TYPE="HIDDEN" name="AMT" value="12345.60">
> ....
>
>
> But I also need to call a bean method that logs the submitted values to
> database.
>
> Maybe I could post the form from bean action method but how?
>
>
>
> Thanks.
>
> Jiri Pejchal
>
>
>
>
>

Mime
View raw message