Hi  Michael,

not a common way, but there is always something you can do :-)

But how exact depends on the concrete situation.

You can put a tc:command  with action 1 as facet eg. inside the box2
and use the onclick attribute of the button:

On the button in box 1 remove the actionListner and add
onClick="Tobago.reloadComponent('page:form2:box2', 'page:form2:action1');"

in box2 add a tc:command as facet:

<f:facet name="action1Facet">
  <tc:command id="action1" actionListener="#{controller.action1}">
    <tc:attribute name="renderedPartially" value="box2"/>
 </tc:command>
</f:facet>

but now is the box1 not processed, so you cant get the value of string1.

If you need this then you can put the action facet on the surrounding panel.


Regards,
    Volker




2010/4/14 Michael Kakuschky <kakusc...@elbe-net.de>:
> Hello Volker, I think I need the forms.
>
> I have an application which use tabs with different formulars. If I don't
> use subforms and set the "required" attribute on some elements on one tab
> and I want to submit a fomular on another tab it does not work because the
> element on the other tab is not completely filled and the set require
> attribute does not allow to submit the main form..
>
> That the reason I subforms. Is there another common way to solve this kind
> of problem?
>
> Thanks and best regards Michael
>
>
> Volker Weber schrieb:
>>
>> Hi Michael,
>>
>> after a more closer view to your jsp i found the problem.
>>
>> The tc:form arround the box is the probem, using subforms you are
>> reduce the validation and modelUpdate
>> only to the subform where the command is in, the other content is not
>> processed and therfore the submitted values are rerenderd.
>>
>> did you really need the forms?
>>
>>
>> Regards,
>>    Volker
>>
>>
>>
>> 2010/4/14 Michael Kakuschky <kakusc...@elbe-net.de>:
>>
>>>
>>> Hello Volker, thanks for the response. Yes I target the panel. I use now
>>> actionListener and return null as return value. I also preset the value
>>> of
>>> string1 so that the value is always already initialized. But
>>> nervertheless
>>> the string2 is set to the new value (I debug that) but after rendering
>>> the
>>> tx:in box is still empty. Maybe you can take a look to the latest version
>>> of
>>> my test page and controller.
>>>
>>> Best regards Michael
>>>
>>> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
>>> <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f" %>
>>> <%@ taglib uri="http://myfaces.apache.org/tobago/component"; prefix="tc"
>>> %>
>>> <%@ taglib uri="http://myfaces.apache.org/tobago/extension"; prefix="tx"
>>> %>
>>> <f:view locale="de">
>>>  <tc:page width="1280" id="page">
>>>
>>>  <f:facet name="layout">
>>>      <tc:gridLayout rows="1*;fixed" columns="fixed"/>
>>>  </f:facet>
>>>
>>>  <tc:panel id="panel1">
>>>  <f:facet name="layout">
>>>      <tc:gridLayout rows="fixed;fixed;1*" columns="fixed"/>
>>>  </f:facet>
>>>    <tc:form id="form1">
>>>  <tc:box label="box1" id="box1">
>>>      <f:facet name="layout">
>>>          <tc:gridLayout rows="fixed;fixed;1*" columns="fixed"/>
>>>      </f:facet>
>>>      <tc:cell>
>>>          <tx:in value="#{myController.string1}" label="string1" />
>>>      </tc:cell>
>>>      <tc:cell>
>>>          <tc:button actionListener="#{myController.action1}"
>>> label="submit1">
>>>              <tc:attribute name="renderedPartially"
>>> value=":page:panel1"/>
>>>          </tc:button>
>>>      </tc:cell>
>>>      <tc:cell/>
>>>  </tc:box>
>>>  </tc:form>
>>>
>>>  <tc:form id="form2">
>>>  <tc:box label="box2" id="box2">
>>>      <f:facet name="layout">
>>>          <tc:gridLayout rows="fixed;fixed;1*" columns="fixed"/>
>>>      </f:facet>
>>>      <tc:cell id="cell2">
>>>          <tx:in value="#{myController.string2}" label="string2"  />
>>>      </tc:cell>
>>>      <tc:cell/>
>>>  </tc:box>
>>>  </tc:form>
>>>
>>>  <tc:cell/>
>>>    </tc:panel>
>>>    <tc:cell>
>>>  </tc:cell>
>>> </tc:page>
>>> </f:view>
>>>
>>> package test1;
>>>
>>> import javax.faces.event.ActionEvent;
>>>
>>> public class MyController {
>>>
>>>  private String string1 = "99";
>>>  private String string2;
>>>    public String action1(ActionEvent actionEvent)
>>>  {
>>>      string2 = string1;
>>>            return null;
>>>  }
>>>  public String getString1() {
>>>      return string1;
>>>  }
>>>  public void setString1(String string1) {
>>>      this.string1 = string1;
>>>  }
>>>  public String getString2() {
>>>      return string2;
>>>  }
>>>  public void setString2(String string2) {
>>>      this.string2 = string2;
>>>  }
>>> }
>>>
>>> Volker Weber schrieb:
>>>
>>>>
>>>> Hi Michael,
>>>>
>>>> for actions used in partial rendering you should always return null!
>>>> I the action returns a string than a full reload is made!
>>>> I suggest using actionListener for partial actions.
>>>>
>>>> When rendering partially only the requested subview (plus the action
>>>> component if outside) is processed on the server.
>>>>
>>>> In your example you request reload of box2, which means the content of
>>>> box2 is processed and stored in the model.
>>>> In the action string2 is set to string1 but string1 was not processed
>>>> so it is still null here.
>>>>
>>>> Have you in helmuts example really changed the value of
>>>> renderedPartially to the suggested panel arround both boxes?
>>>>
>>>>
>>>> Regards,
>>>>   Volker
>>>>
>>>>
>>>>
>>>>
>>>> 2010/4/12  <kakusc...@elbe-net.de>:
>>>>
>>>>
>>>>>
>>>>> Hello,
>>>>>
>>>>> I'm trying to execute an action and partial rendering the result in an
>>>>> <tx:in> field. The tx:button which calls the action and the tx:in
>>>>> elements
>>>>> are in different forms. For some reasons after the new value is set to
>>>>> the
>>>>> underlaying value of the tx:in field the setter of this value is called
>>>>> from somewhere and overwrites the new value with an empty string.  But
>>>>> I
>>>>> want to have the value I set with my action1 method in the field
>>>>> instead
>>>>> an empty string. Can some one tell me what I'm doing wrong?
>>>>>
>>>>> Thanks a lot Michael
>>>>>
>>>>> <%@ page contentType="text/html;charset=UTF-8" language="java" %>
>>>>> <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f" %>
>>>>> <%@ taglib uri="http://myfaces.apache.org/tobago/component"; prefix="tc"
>>>>> %>
>>>>> <%@ taglib uri="http://myfaces.apache.org/tobago/extension"; prefix="tx"
>>>>> %>
>>>>> <f:view locale="de">
>>>>>      <tc:page width="1280" id="page">
>>>>>
>>>>>      <f:facet name="layout">
>>>>>              <tc:gridLayout rows="fixed;fixed;1*" columns="fixed"/>
>>>>>      </f:facet>
>>>>>
>>>>>  <tc:form id="form1">
>>>>>      <tc:box label="box1" id="box1">
>>>>>              <f:facet name="layout">
>>>>>                      <tc:gridLayout rows="fixed;fixed;1*"
>>>>> columns="fixed"/>
>>>>>              </f:facet>
>>>>>          <tc:cell>
>>>>>              <tx:in value="#{testController.string1}" label="string1"
>>>>> />
>>>>>          </tc:cell>
>>>>>          <tc:cell>
>>>>>              <tc:button action="#{testController.action1}"
>>>>> label="submit1">
>>>>>                      <tc:attribute name="renderedPartially"
>>>>> value=":page:form2:box2"/>
>>>>>              </tc:button>
>>>>>          </tc:cell>
>>>>>          <tc:cell/>
>>>>>      </tc:box>
>>>>>      </tc:form>
>>>>>
>>>>>  <tc:form id="form2">
>>>>>      <tc:box label="box2" id="box2">
>>>>>              <f:facet name="layout">
>>>>>                      <tc:gridLayout rows="fixed;fixed;1*"
>>>>> columns="fixed"/>
>>>>>              </f:facet>
>>>>>          <tc:cell id="cell2">
>>>>>              <tx:in value="#{testController.string2}" label="string2"
>>>>>  />
>>>>>          </tc:cell>
>>>>>          <tc:cell/>
>>>>>      </tc:box>
>>>>>      </tc:form>
>>>>>      <tc:cell>
>>>>>      </tc:cell>
>>>>> </tc:page>
>>>>> </f:view>
>>>>>
>>>>>
>>>>> package test;
>>>>>
>>>>> import java.io.File;
>>>>> import java.util.Date;
>>>>>
>>>>> import javax.faces.event.ValueChangeEvent;
>>>>>
>>>>> import org.apache.commons.fileupload.FileItem;
>>>>> import org.apache.myfaces.tobago.model.SelectItem;
>>>>>
>>>>>
>>>>> public class TestController {
>>>>>
>>>>>      private String string1;
>>>>>      private String string2;
>>>>>
>>>>>      // access methods
>>>>>      public String action1()  {
>>>>>
>>>>>              string2 = string1;
>>>>>
>>>>>              return "success";
>>>>>      }
>>>>>
>>>>>      // Getters and Setters
>>>>>      public String getString1() {
>>>>>              return string1;
>>>>>      }
>>>>>      public void setString1(String string1) {
>>>>>              this.string1 = string1;
>>>>>      }
>>>>>      public String getString2() {
>>>>>              return string2;
>>>>>      }
>>>>>      public void setString2(String string2) {
>>>>>              this.string2 = string2;
>>>>>      }
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>>
>
>



-- 
inexso - information exchange solutions GmbH
Bismarckstraße 13      | 26122 Oldenburg
Tel.: +49 441 4082 356 |
FAX:  +49 441 4082 355 | www.inexso.de

Reply via email to