Hi Johnny,
I reviewed the code of ERXLinkButton5 and found what I guess the code to do
what Chuck suggested.
This is the code that did the trick:
public WOActionResults invokeAction(WORequest request, WOContext context) {
WOActionResults anActionResult = null;
if(context.wasFormSubmitted()) {
if(context.isMultipleSubmitForm()) {
if(request.formValueForKey(context.elementID())
!= null) {
context.setActionInvoked(true);
anActionResult =
(WOActionResults)valueForBinding("action");
}
} else {
context.setActionInvoked(true);
anActionResult =
(WOActionResults)valueForBinding("action");
}
}
return anActionResult;
}
Thanks.
On 03/11/2012, at 16:38, Johnny Miller <[email protected]> wrote:
> Hi Miguel,
>
> I believe what you are looking for is ERXLinkButton5 in
> er.extensions.components
>
> Best,
>
> Johnny
>
> On Nov 2, 2012, at 12:02 PM, Miguel Torres <[email protected]> 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.
>>
>> 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?
>>
>> Thanks in advance.
>>
>> Miguel Torres.
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/webobjects-dev/jlmiller%40kahalawai.com
>>
>> This email sent to [email protected]
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]