Re: Calling action passed via biding in subcomponent.
Re: Calling action passed via biding in subcomponent.
- Subject: Re: Calling action passed via biding in subcomponent.
- From: Chuck Hill <email@hidden>
- Date: Sat, 03 Nov 2012 13:03:15 -0700
I think only the one for the button pressed is sent. Or there is a special value sent. I have not looked at this in a while.
Chuck
On Nov 3, 2012, at 11:05 AM, Miguel Torres <email@hidden> wrote:
>
> On 03/11/2012, at 11:46, Chuck Hill <email@hidden> wrote:
>
>>
>> On 2012-11-03, at 10:40 AM, Miguel Torres wrote:
>>
>>>
>>> On 03/11/2012, at 10:46, Chuck Hill <email@hidden> wrote:
>>>
>>>> Hi Miguel
>>>>
>>>> On 2012-11-03, at 9:32 AM, Miguel Torres wrote:
>>>>
>>>>> Thanks for the response Chuck,
>>>>>
>>>>> This is the rendered HTML
>>>>>
>>>>> <form name="f_0_5_11_1" method="post" class="form-inline" id="form-login" action="/cgi-bin/WebObjects/aplicacionbase.woa/-55550/wo/N9l418Wx25eGL6kgGhK3Aw/0.0.5.11.1">
>>>>>
>>>>>
>>>>> <input id="versionNavegador" type="hidden" name="0.5.11.1.3.1" />
>>>>>
>>>>> <div class="container logintry">
>>>>> <div id="content">
>>>>>
>>>>> <div id="element-box" class="login well">
>>>>> <h2 style="color: #666;">Login</h2>
>>>>> <hr />
>>>>> <fieldset class="loginform">
>>>>> <div class="control-group">
>>>>> <div class="controls">
>>>>> <div class="input-prepend">
>>>>> <span class="add-on"><i class="icon-user"></i></span><input tabindex="1" placeholder="Username" class="input-large" id="usuario" type="text" name="0.5.11.1.3.5" />
>>>>> </div>
>>>>> </div>
>>>>> </div>
>>>>> <div class="control-group">
>>>>> <div class="controls">
>>>>> <div class="input-prepend">
>>>>> <span class="add-on"><i class="icon-lock"></i></span><input tabindex="2" placeholder="Password" class="input-large" type="password" name="0.5.11.1.3.7" />
>>>>> </div>
>>>>> </div>
>>>>> </div>
>>>>> <div class="control-group">
>>>>> <div class="controls">
>>>>> <button name="0.5.11.1.3.9"tabindex="3" class="btn btn-primary btn-large" type="submit"><i class="icon-lock" > </i> Login</button>
>>>>> </div>
>>>>> </div>
>>>>> </fieldset>
>>>>>
>>>>> </div>
>>>>> <noscript>
>>>>> Warning! JavaScript must be enabled for proper operation of the Administrator backend. </noscript>
>>>>>
>>>>> </div>
>>>>> </div>
>>>>>
>>>>> I am assigning the context.elementID() to the button's name.
>>>>>
>>>>> When I click on the button the context.elementID() is 0.5.11.1.3.9, which is correct.
>>>>>
>>>>> But the context.senderID() is 0.5.11.1
>>>>>
>>>>> This is the URL with the context's ID
>>>>>
>>>>> http://localhost/cgi-bin/WebObjects/aplicacionbase.woa/-55550/wo/w46py2RT6cjHT2iRyyRib0/0.0.5.11.1
>>>>>
>>>>> I am not sure Who is the owner of the 0.5.11.1 ID.
>>>>
>>>> It is the form:
>>>> <form name="f_0_5_11_1" method="post" class="form-inline" id="form-login" action="/cgi-bin/WebObjects/aplicacionbase.woa/-55550/wo/N9l418Wx25eGL6kgGhK3Aw/0.0.5.11.1">
>>>>
>>>> set multipleSubmit = true; on the WOForm bindings and try again. I think that will give you the correct 5.11.1.3.9.
>>>>
>>>
>>> It is already set to true.
>>>
>>> This is the declaration of the WOForm in the .wod file
>>>
>>> form: WOForm {
>>> multipleSubmit = true;
>>> id="form-login";
>>> class="form-inline";
>>> }
>>>
>>> I tried using the <input type="submit"> instead of <button> tag with same results. I changed it to <a> tag and then it works.
>>>
>>> It is clear that in the two first cases the sender is the form, and I guess that's why the multipleSubmit binding exits, but for some reason is not working properly.
>>
>> Right, that element ID get sent as a form value. I am trying to recall what the form does with it to get it to an submit button action.
>>
>> You could look through the submitted form values for your elementID().
>>
>
> If I understand your recommendation, the approach would be to search for the elementID inside of the form and if it is present then return the WOActionResults.
>
> But if I have two submit buttons both are inside the form and both actions would be triggered.
>
> Am I right?
>
>
>
>
>
>>
>> Chuck
>>
>>>
>>> I will continue doing tests trying to understand what's happening.
>>>
>>> Thanks.
>>>
>>>
>>>>
>>>>
>>>> Chuck
>>>>
>>>>
>>>>>
>>>>>
>>>>> On 02/11/2012, at 17:41, Chuck Hill <email@hidden> wrote:
>>>>>
>>>>>>
>>>>>> On 2012-11-02, at 3:02 PM, Miguel Torres wrote:
>>>>>>
>>>>>>> Hi List,
>>>>>>>
>>>>>>> I am creating a Component to use <button > HTML tag in my apps.
>>>>>>>
>>>>>>> I am implementing Bootstrap in my WO application and I want to create buttons with icons.
>>>>>>>
>>>>>>> I followed the example in the book Practical WebObjects, chapter 6 that creates a Hyperlink Component.
>>>>>>>
>>>>>>> This is my code based on the book's example:
>>>>>>>
>>>>>>> public class BootstrapSubmitButton extends ERXComponent {
>>>>>>> public BootstrapSubmitButton(WOContext context) {
>>>>>>> super(context);
>>>>>>> }
>>>>>>>
>>>>>>> @Override
>>>>>>> public void appendToResponse(WOResponse response, WOContext context) {
>>>>>>> String tabindex = stringValueForBinding("tabindex");
>>>>>>> String cssClass = "btn "+stringValueForBinding("class", "");
>>>>>>> String icon = stringValueForBinding("icon");
>>>>>>>
>>>>>>> response.appendContentString("<button name=\""+context.elementID()+"\"");
>>>>>>> if(tabindex != null){
>>>>>>> response.appendContentString("tabindex=\""+tabindex+"\" ");
>>>>>>> }
>>>>>>> response.appendContentString("class=\""+cssClass+"\" type=\"submit\">");
>>>>>>> if(icon != null){
>>>>>>> response.appendContentString("<i class=\""+stringValueForBinding("icon")+"\" > </i> ");
>>>>>>> }
>>>>>>> response.appendContentString(stringValueForBinding("value"));
>>>>>>> response.appendContentString("</button>");
>>>>>>> }
>>>>>>>
>>>>>>> @Override
>>>>>>> public boolean synchronizesVariablesWithBindings() {
>>>>>>> return false;
>>>>>>> }
>>>>>>>
>>>>>>> @Override
>>>>>>> public WOActionResults invokeAction(WORequest request, WOContext context) {
>>>>>>> if(context.elementID().startsWith(context.senderID())){
>>>>>>> return (WOActionResults)valueForBinding("action");
>>>>>>> }
>>>>>>> return null;
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> I just changed a line:
>>>>>>>
>>>>>>>
>>>>>>> if(context.elementID().startsWith(context.senderID())){
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> The example in the book is coded like this:
>>>>>>> if(context.elementID().equals(context.senderID())){
>>>>>>>
>>>>>>>
>>>>>>> I had to changed it because it was not working, debugging the code I found that the element's ID is never equals to the sender's ID. It sounds logic because they are two different objects.
>>>>>>
>>>>>> Why are they different objects? Look at the page content, what matches the senderID()? Your code is saying "if the action is from me, or from any of my children". Is there something else embedded in your button?
>>>>>>
>>>>>>
>>>>>>> I think my change is correct.
>>>>>>>
>>>>>>> Am I right and that's an error in the book's example?
>>>>>>>
>>>>>>> Did I misunderstand the concepts in the book and I am doing something dangerous for my application?
>>>>>>
>>>>>> I am pretty sure the book is correct, I don't understand why you are seeing the results that you are seeing.
>>>>>>
>>>>>>
>>>>>> Chuck
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Chuck Hill Senior Consultant / VP Development
>>>>>>
>>>>>> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
>>>>>> http://www.global-village.net/gvc/practical_webobjects
>>>>>>
>>>>>> Global Village Consulting ranks 13th in 2012 in BIV's Top 100 Fastest Growing Companies in B.C!
>>>>>> Global Village Consulting ranks 76th in 24th annual PROFIT 200 ranking of Canada’s Fastest-Growing Companies by PROFIT Magazine!
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>> --
>>>> Chuck Hill Senior Consultant / VP Development
>>>>
>>>> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
>>>> http://www.global-village.net/gvc/practical_webobjects
>>>>
>>>> Global Village Consulting ranks 13th in 2012 in BIV's Top 100 Fastest Growing Companies in B.C!
>>>> Global Village Consulting ranks 76th in 24th annual PROFIT 200 ranking of Canada’s Fastest-Growing Companies by PROFIT Magazine!
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>> --
>> Chuck Hill Senior Consultant / VP Development
>>
>> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
>> http://www.global-village.net/gvc/practical_webobjects
>>
>> Global Village Consulting ranks 13th in 2012 in BIV's Top 100 Fastest Growing Companies in B.C!
>> Global Village Consulting ranks 76th in 24th annual PROFIT 200 ranking of Canada’s Fastest-Growing Companies by PROFIT Magazine!
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden