Thank you Igor and Alex for your answers.
   
  I managed to send the itemId parameter to WebRequestCycle, by modifying
the URL inside wicketAjaxGet, generated by AjaxLink.
  
  The code looks like this:
    c.add(new AbstractBehavior() {
                                        @Override
                                        public void onComponentTag(Component 
component,
                                                        ComponentTag tag) {
                                                
                                                inservAdvIdInAjaxLink(tag, 
advertisementId);
                                        }

                                        /**
                                         * Insert advId at the end of the url 
inside wicketAjaxGet from tag
attribute onclick.
                                         * @param tag ComponentTag
                                         * @param advId advertisement id
                                         */
                                        private void 
inservAdvIdInAjaxLink(ComponentTag tag,
                                                        String advId) {
                                                String onclickElement = 
(String) tag.getAttributes().get("onclick");
                                                
                                                String elementToModify = 
"wicketAjaxGet('";
                                                String subOnclickElement =
onclickElement.substring(onclickElement.indexOf(elementToModify) +
elementToModify.length());
                                                String ajaxHref = 
subOnclickElement.substring(0,
subOnclickElement.indexOf("'"));
                                                onclickElement = 
onclickElement.replace(ajaxHref, ajaxHref +
"&itemId=" + advId);
                                                
                                                tag.put("href", ajaxHref + 
"&itemId=" + advId);
                                                tag.put("onclick", 
onclickElement);
                                        }
                                }); 
                                
        The 'onclick' attribute changed from:                   
                                
        wicketShow('id10--ajax-indicator');var
wcall=wicketAjaxGet('?wicket:interface=:2:10:::0:',function(){;wicketHide('id10--ajax-indicator');}.bind(this),function()
{ ;wicketHide('id10--ajax-indicator');}.bind(this), function() {return
Wicket.$('id10') != null;}.bind(this));return !wcall;
  
  to:
  
  wicketShow('id10--ajax-indicator');var
wcall=wicketAjaxGet('?wicket:interface=:2:10:::0:&itemId=xxx',function(){;wicketHide('id10--ajax-indicator');}.bind(this),function()
{ ;wicketHide('id10--ajax-indicator');}.bind(this), function() {return
Wicket.$('id10') != null;}.bind(this));return !wcall;                   
                                
                                
        If someone have a more elegant solution, please post it.        
  Marius Anton


Alexandru Objelean wrote:
> 
> I think this is not enough...
> The generated markup looks like this:
> 
> <li wicket:id="tabs" class="tab2 last"> 
>               < a
> href="?wicket:interface=:2:tabs:tabs-container:tabs:2:link::ILinkListener::&amp;itemId=2"
> wicket:id="link" id="link8" onclick="var
> wcall=wicketAjaxGet('?wicket:interface=:2:tabs:tabs-container:tabs:2:link::IBehaviorListener:0:',null,null,
> function() {return Wicket.$('link8') != null;}.bind(this));return
> !wcall;">< span wicket:id="title">third tab</ a> 
>       </ li> 
> </pre>
> 
> In order to make it work, the wicketAjaxGet url should also contain the
> itemId parameter appended.. Otherwise it will work only when javascript is
> disabled.
> 
> Alex Objelean
> 
> 
> igor.vaynberg wrote:
>> 
>> c.add(new abstractbehavior() {
>>   oncomponenttag(tag) {
>>     tag.put("href", tag.getattributes().get("href")+"&itemid=xxx");
>>   }
>> }
>> 
>> -igor
>> 
>> 
>> On Thu, Aug 6, 2009 at 6:05 AM, marius1maru<[email protected]> wrote:
>>>
>>>  Thank you for your answer Igor.
>>>
>>>  I did not manage to append the id to the url. I tried something like
>>> this:
>>>
>>>                tabbedPanel = new AjaxTabbedPanel("mytabpanel", tabs) {
>>>
>>>                       �...@override
>>>                        protected WebMarkupContainer newLink(String
>>> linkId, final int index) {
>>>
>>>                                final WebMarkupContainer c = new
>>> IndicatingAjaxLink(linkId) {
>>>
>>>                                       �...@override
>>>                                        public void
>>> onClick(AjaxRequestTarget target) {
>>>                                                setSelectedTab(index);
>>>                                                if (target != null) {
>>>                                                      
>>>  target.addComponent(MyTabbedPanel.this);
>>>                                                }
>>>                                                onAjaxUpdate(target);
>>>                                        }
>>>                                };
>>>
>>>                                c.add(new SimpleAttributeModifier("href",
>>> "&itemId=xxx"));
>>>
>>>                                return c;
>>>                        }
>>>
>>>  I also tried:
>>>                        final IModel<String> model = new
>>> AbstractReadOnlyModel<String>() {
>>>                                       @Override
>>>                                       public String getObject() {
>>>                                                return "&itemId=xxx";
>>>                                       }
>>>                        };
>>>
>>>                        add(new AttributeModifier("href", model) {
>>>                               @Override
>>>                               protected String newValue(String
>>> currentValue, String
>>> replacementValue) {
>>>                                  return currentValue + replacementValue;
>>>                               }
>>>                        });
>>>
>>>  but in WebRequestCycle, the URL is always without "&itemId=xxx" at the
>>> end.
>>>
>>> Can you please tell me what am I missing here? Or what should I do to
>>> modify
>>> the url generated by ajaxtabpanel?
>>>
>>> Thank you,
>>> Marius Anton
>>>
>>>
>>> igor.vaynberg wrote:
>>>>
>>>> your request cycle has access to the url that caused the page expired
>>>> exception. at that point you cannot know anything else because there
>>>> is no longer a session either.
>>>>
>>>> what you might want to do is append itemid to the urls generated by
>>>> the ajaxtabbedpanel.
>>>>
>>>> -igor
>>>>
>>>> On Wed, Aug 5, 2009 at 1:52 AM, Marius Anton<[email protected]>
>>>> wrote:
>>>>> Hello everybody,
>>>>>
>>>>> I hope that someone can help me on this.
>>>>>
>>>>>  I have a page that displays information about a particular item. On
>>>>> that
>>>>> page there is also an ajax tab panel (from wicket.extensions).
>>>>>  For every item, the url looks like this:
>>>>> http://mysite?itemId=xxxx-xxxxx. After the page expires I want the
>>>>> current page to be refreshed.
>>>>>
>>>>>  After the page expires, and the user clicks on one of the tabs, a
>>>>> page
>>>>> expired exception is thrown. I have a custom request cycle, witch
>>>>> extends
>>>>> WebRequestCycle, that caches that exception,
>>>>>  but the problem is that I can not redirect the user to the same page
>>>>> because there in my request cycle I am not able to see the parameter
>>>>>  "itemId". Inside RequstCycle, if I try request.getUrl, I get
>>>>> something
>>>>> like this:
>>>>> mypage?wicket:interface=:5:10:::0:&random=0.8618006417527795.
>>>>>
>>>>>  My question is: can I somehow send a parameter(itemId) to the request
>>>>> cycle when a page expired exception is thrown?
>>>>> Or how can I refresh the current page(witch has the itemId as
>>>>> parameter)
>>>>> when the user clicks on an ajax link(in this case a tab)
>>>>> after the page expired?
>>>>>
>>>>> Any sugestion will be apreciated.
>>>>>
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Can-I-send-a-parameter-value-to-RequestCycle--tp24823173p24846158.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Can-I-send-a-parameter-value-to-RequestCycle--tp24823173p24863532.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to