getting form FORM to Java Object (JSF)

View: New views
4 Messages — Rating Filter:   Alert me  

getting form FORM to Java Object (JSF)

by sudheerp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

   I am new two DWR, I am using dwr-1.1.1 with JSF (myfaces 1.1.4). I want to
populcate the Category object from the following JSF form.


<h:panelGrid columns="3">

    <h:outputLabel styleClass="desc" for="category" value="#{text['category.category']}"/>

    <h:inputText styleClass="text large" id="catCategory" value="#{categoryForm.category.category}"/>

    <h:panelGroup styleClass="buttonBar bottom">
        <h:commandButton type="button" value="#{text['button.save']}" onclick="assignCategory();" id="save" styleClass="button"/>

        <c:if test="${not empty categoryForm.category.id}">
        <h:commandButton value="#{text['button.delete']}" action="#{categoryForm.delete}"
            id="delete" styleClass="button" onclick="bCancel=true; return confirmDelete('Category')"/>
        </c:if>

        <h:commandButton value="#{text['button.cancel']}" action="cancel" immediate="true"  
            id="cancel" styleClass="button" onclick="bCancel=true"/>
    </h:panelGroup>
    <h:outputText/><h:outputText/>
</h:panelGrid>

   I tried the following piece of code to get values from form fields to Category object.

        var cat = { catId:"", catCategory:"" };
        DWRUtil.getValues( cat );


   but I am getting null values here.

   Please help.

   Thank you.

Sudheer.


RE: getting form FORM to Java Object (JSF)

by mikewse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Sudheer,

I have two suggestions:
- use the latest stable release of DWR, which is 2.0.3 (with 2.0.4
  coming out soon)
- show us the resulting HTML in the browser of your input form (do
  a View Source and cut out the interesting part) and it will be
  easier for us to help you

Best regards
Mike Wilson

> -----Original Message-----
> From: sudheerp [mailto:p_sudheers@...]
> Sent: den 24 april 2008 12:26
> To: users@...
> Subject: [dwr-user] getting form FORM to Java Object (JSF)
>
>
> Hello,
>
>    I am new two DWR, I am using dwr-1.1.1 with JSF (myfaces
> 1.1.4). I want
> to
> populcate the Category object from the following JSF form.
>
>
> <h:panelGrid columns="3">
>
>     <h:outputLabel styleClass="desc" for="category"
> value="#{text['category.category']}"/>
>
>     <h:inputText styleClass="text large" id="catCategory"
> value="#{categoryForm.category.category}"/>
>
>     <h:panelGroup styleClass="buttonBar bottom">
>         <h:commandButton type="button" value="#{text['button.save']}"
> onclick="assignCategory();" id="save" styleClass="button"/>
>
>         <c:if test="${not empty categoryForm.category.id}">
>         <h:commandButton value="#{text['button.delete']}"
> action="#{categoryForm.delete}"
>             id="delete" styleClass="button"
> onclick="bCancel=true; return
> confirmDelete('Category')"/>
>         </c:if>
>
>         <h:commandButton value="#{text['button.cancel']}"
> action="cancel"
> immediate="true"  
>             id="cancel" styleClass="button" onclick="bCancel=true"/>
>     </h:panelGroup>
>     <h:outputText/><h:outputText/>
> </h:panelGrid>
>
>    I tried the following piece of code to get values from
> form fields to
> Category object.
>
> var cat = { catId:"", catCategory:"" };
> DWRUtil.getValues( cat );
>
>
>    but I am getting null values here.
>
>    Please help.
>
>    Thank you.
>
> Sudheer.
>
>
> --
> View this message in context:
> http://www.nabble.com/getting-form-FORM-to-Java-Object-%28JSF%
> 29-tp16849569p16849569.html
> Sent from the DWR - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


RE: getting form FORM to Java Object (JSF)

by sudheerp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Mike,

   Thanks for your reply. Now I tried the table editing example of DWR with dwr 2.0.1 (appfuse-jsf 2.0). It works well, but when I change the

   <input id="name"

     to

   <h:inputText id="name" (JSF)

   And the resulting HTML source prefix "j_id2:" with the JSF component.

   <input id="j_id2:name" name="j_id2:name" type="text" value="" class="text" />
   <input id="salary" type="text" size="20" />
   <input type="text" id="address" size="40" />

   The dwr.util.setValues(person) is not showing the name field value.

    How to handle this situation ?

    Thank you.

Sudheer

   




Hi Sudheer,

I have two suggestions:
- use the latest stable release of DWR, which is 2.0.3 (with 2.0.4
  coming out soon)
- show us the resulting HTML in the browser of your input form (do
  a View Source and cut out the interesting part) and it will be
  easier for us to help you

Best regards
Mike Wilson
>
> Hello,
>
>    I am new two DWR, I am using dwr-1.1.1 with JSF (myfaces
> 1.1.4). I want
> to
> populcate the Category object from the following JSF form.
>
>
> <h:panelGrid columns="3">
>
>     <h:outputLabel styleClass="desc" for="category"
> value="#{text['category.category']}"/>
>
>     <h:inputText styleClass="text large" id="catCategory"
> value="#{categoryForm.category.category}"/>
>
>     <h:panelGroup styleClass="buttonBar bottom">
>         <h:commandButton type="button" value="#{text['button.save']}"
> onclick="assignCategory();" id="save" styleClass="button"/>
>
>         <c:if test="${not empty categoryForm.category.id}">
>         <h:commandButton value="#{text['button.delete']}"
> action="#{categoryForm.delete}"
>             id="delete" styleClass="button"
> onclick="bCancel=true; return
> confirmDelete('Category')"/>
>         </c:if>
>
>         <h:commandButton value="#{text['button.cancel']}"
> action="cancel"
> immediate="true"  
>             id="cancel" styleClass="button" onclick="bCancel=true"/>
>     </h:panelGroup>
>     <h:outputText/><h:outputText/>
> </h:panelGrid>
>
>    I tried the following piece of code to get values from
> form fields to
> Category object.
>
> var cat = { catId:"", catCategory:"" };
> DWRUtil.getValues( cat );
>
>
>    but I am getting null values here.
>
>    Please help.
>
>    Thank you.
>
> Sudheer.
>
>
> --

RE: getting form FORM to Java Object (JSF)

by mikewse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Now I tried the table editing example of DWR with
> dwr 2.0.1 (appfuse-jsf 2.0). It works well, but when I change the
>
>    <input id="name"
>
>      to
>
>    <h:inputText id="name" (JSF)
>
>    And the resulting HTML source prefix "j_id2:" with the JSF
>    component.
>
>    <input id="j_id2:name" name="j_id2:name" type="text" value="" />
>    <input id="salary" type="text" size="20" />
>    <input type="text" id="address" size="40" />
>
>    The dwr.util.setValues(person) is not showing the name field value.

Ok, your problem here is with JSF's generated id/name attributes. Your
specified id="name" is prepended with a parent's id acting as naming
container.

As DWR's get/setValue[s] functions are purely client-side implementations,
and not dependent on your server-side framework, they can only consider
the resulting id/name and these are now different from the property names
in your person object.

Possible solutions:

1) Ask JSF not to rewrite the ids on these elements. I'm by no means a JSF
   expert but I've seen this:
     JSF 1.2: form prependId=false
     Myfaces: input forceId=true
   Check what your chosen JSF implementation can offer. It's probably
   better to ask further questions on this subject in a JSF forum but it
   would be nice if you can report back your findings here.
   [Not rewriting the ids assume you don't have any other elements with
   the same id that may interfere.]

2) Change the members of your person object to match the generated ids.
   Probably not desired, but anyway:
     person["j_id2:name"] = "Donald";
     dwr.util.setValues(person);

3) Use setValue calls for every property instead of setValues:
     dwr.util.setValue("j_id2:name", person.name);
     ... etc ...

4) Updating setValues() in 2.0.4 as it currently has almost the support
   you need:
     dwr.util.setValues(person, {prefix:"j_id2"});
   The above will map
     person.name -> id "j_id2.name"
   and so forth. Note the separating dot instead of colon. We could add
   a new option for configuring the separator character:
     dwr.util.setValues(person, {prefix:"j_id2",separator:":"});
   that would then map
     person.name -> id "j_id2:name"
   What does everybody think - is this the correct (and desired) way
   of tackling this issue or is the JSF id thingie too complex to
   handle properly anyway, and should be avoided?

Best regards
Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...