Form action problem

Splash Forums PrettyFaces Users Form action problem

This topic contains 14 replies, has 2 voices, and was last updated by  Ildar 1 year, 2 months ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #27162

    Ildar
    Participant

    I want to put the form <form action = “https://demomoney.yandex.ru/eshop.xml”&gt; in the JSF file, but after address initiation, “https://demomoney.yandex.ru/eshop.xml&#8221; is replaced by the internal address system. How can I fix it?

    #27163

    What do you mean with “internal address system”?

    #27164

    Ildar
    Participant

    Hello. Sorry for my English. Inside the JSF file I described the default HTML form (not h:form): <form id = “paymentForm” action = “https://demomoney.yandex.ru/eshop.xml”&gt;. But when rendering pages,instead of “https://demomoney.yandex.ru/eshop.xml&#8221; the “/payment/5765” is contained, ie the address of the current page. How can I correct this? Thanks.

    #27165

    I don’t think that this is related to Rewrite. If you are not using h:form, Rewrite won’t process the response and perform any “replacements”.

    #27166

    Ildar
    Participant

    I can say without any doubts that the error started to appear after the implementation of “prettyfaces ” in the project

    #27167

    Which dependencies did you add to your project and could you share your configuration?

    #27177

    Ildar
    Participant

    <dependency>
    <groupId>org.ocpsoft.rewrite</groupId>
    <artifactId>rewrite-servlet</artifactId>
    <version>2.0.12.Final</version>
    </dependency>
    <dependency>
    <groupId>org.ocpsoft.rewrite</groupId>
    <artifactId>rewrite-config-prettyfaces</artifactId>
    <version>2.0.12.Final</version>
    </dependency>

    #27181

    First, you should also add:

    <dependency>
      <groupId>org.ocpsoft.rewrite</groupId>
      <artifactId>rewrite-integration-faces</artifactId>
      <version>2.0.12.Final</version>
    </dependency>
    <dependency>
      <groupId>org.ocpsoft.rewrite</groupId>
      <artifactId>rewrite-integration-cdi</artifactId>
      <version>2.0.12.Final</version>
    </dependency>
    

    The first one is required by the PrettyFaces module and if you add the second dependency, you should be able to remove the @BeanName annotation.

    Any other configuration? A ConfigurationProvider or a pretty-config.xml?

    #27182

    Ildar
    Participant

    Bean controller

    @Named("payment")
    @ItsSessionScope
    @URLBeanName("payment")
    @URLMappings(mappings = {
        @URLMapping(id = PaymentModuleController.PAYMENT_FORM_MAPPING_ID, pattern = "/payment/#{type: payment.type}/#{id: payment.id}", viewId = "/pages/payment/form.xhtml")
    })
    #27183

    Ildar
    Participant

    JSF form

    <form id="paymentForm" action="https://demomoney.yandex.ru/eshop.xml">
                <ui:decorate template="#{cc.attrs.decorator}">
    
                    <ui:define name="payment-form">
                        <input name="shopId" value="#{incareerPaymentComponent.shopID}" type="hidden"/>
                        <input name="scid" value="#{incareerPaymentComponent.siteID}" type="hidden"/>
                        <input name="shopSuccessURL" value="#{incareerPaymentComponent.shopSuccessURL}" type="hidden"/>
                        <input name="shopFailURL" value="#{incareerPaymentComponent.shopFailURL}" type="hidden"/>
                        <input name="customerNumber" value="#{cc.attrs.currentUser.uuid}" type="hidden"/>
                        <h:panelGroup id="order_id">
                            <input name="sum" value="#{incareerPaymentComponent.getCostWithDiscount()}" type="hidden"/>
                            <input name="serviceTitle" value="#{incareerPaymentComponent.getServiceTitle()}" type="hidden"/>
                            <input type="hidden" name="orderNumber" value="#{incareerPaymentComponent.getPaymentServiceUUID()}"/>
                        </h:panelGroup>
    
                        <ui:fragment rendered="#{not empty cc.attrs.currentUser.email}">
                            <input name="cps_email" value="#{cc.attrs.currentUser.email}" type="hidden"/>
                        </ui:fragment>
                        <ui:fragment rendered="#{not empty cc.attrs.currentUser.phone}">
                            <input name="cps_phone" value="#{cc.attrs.currentUser.phone}" type="hidden"/>
                        </ui:fragment>
                    </ui:define>
    
                    <ui:define name="payment-type">
                        <ui:repeat value="#{incareerPaymentComponent.getAvailablePaymentType()}"
                                   var="paymentType">
                            <label>
                                <input type="radio" name="paymentType" value="#{paymentType.getCode()}"
                                       onclick="this.checked = true;
                                               createOrder();"/>
                                <span class="img-overlay">                             
                                    <h:graphicImage
                                        name="#{paymentType.image}"
                                        alt="#{paymentType.getDescription()}"
                                        title="#{paymentType.getDescription()}"/>
                                </span>
                            </label>
                        </ui:repeat>
                    </ui:define>
    
                </ui:decorate>
    
                <script type="text/javascript">
                    function submitForm() {
                        $("#paymentForm").submit();
                    }
                </script>
    
            </form>
    
            <h:form>
                <p:remoteCommand
                    name="createOrder"
                    actionListener="#{incareerPaymentComponent.createOrder(cc.attrs.currentUser, null)}"
                    update=""
                    process="@this"
                    oncomplete="submitForm();"/>
            </h:form>
    #27185

    And you say that

    <form id="paymentForm" action="https://demomoney.yandex.ru/eshop.xml">
    

    is changed to:

    <form id="paymentForm" action="/payment/5765">
    

    just by including Rewrite in your project? There is absolutely no way I could think of that would lead Rewrite to replace the URL in a plain HTML form.

    #27186

    Ildar
    Participant

    Form
    <form id="paymentForm" action="https://demomoney.yandex.ru/eshop.xml">

    is changed to

    <form id="j_id_x_f:j_id_x_g_1:j_id_x_g_5" name="j_id_x_f:j_id_x_g_1:j_id_x_g_5" method="post" action="/payment/TEST/0cfb8774-1725-4a31-acaf-bbaa481f6ed9" enctype="application/x-www-form-urlencoded">

    At the beginning we implemented our project without using Prettyfaces, but after the implementation of the prettyfaces the bug appeared in this form. This is the only plain html form in the project

    #27187

    Ildar
    Participant

    Is there any filtering mechanism of html form in prettyfaces?

    #27188

    The modified form looks like JSF did modify it. Especially because the id change to a JSF client ID.

    You *could* implement a filtering mechanism with Rewrite. But as you didn’t, PrettyFaces/Rewrite won’t change the response HTML.

    #27189

    Ildar
    Participant

    It seems the problem is not connected with pRettyfaces. I created a simple test project and there is no such problem. I’ll keep you posted if I find something. Thanks for everything.

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.

Comments are closed.