How Can I remove backstack till the required pagename in Wp7.1 - windows-phone-7.1

I want to remove pages from backstack till a particular page say "C" has reached when I am on some other page say "F".
Is Its posiible to remove backstack upon pagename?
Thanks and Regards,
Kanaya

You can easily traverse the backstack and check the page names and remove items like this:
while (NavigationService.CanGoBack)
{
if (NavigationService.BackStack.First().Source.OriginalString == "/C.xaml")
{
break;
}
NavigationService.RemoveBackEntry();
}

You can keep a record a all the pages you have navigated in the code like a screen manager. That contain the pages in the same order as the default stack. So you can find the position of the desired page from that list and call remove back entry function that many times.

Related

IBM BPM 8.5.6 Client-Side human service visibility script

I have a table that when I select one or more rows and click a button I go to a service that when finish remove those rows from the table. My problem is that button must appear when I select one or more rows otherwise disappear.
My visibility script for the button is:
if(local.get("pSuspendedTasks").get("listAllSelected")[0] == null){
return "HIDDEN";
}
return "DEFAULT";
When I call the service and return without the rows that I selected before the button still there.
NOTE: I use responsive coaches toolkit
You must clear the selection items on the list pSuspendedTasks.
You can do it calling method listClearAllSelected on server side as below:
tw.local.pSuspendedTasks.listClearAllSelected()
To works fine, don't forget to pass and return the entire list to the service.
Regards,
Bernardo Baumblatt.

Displaying Grails domains in jquery tabs

What would be the best way to display data from Grails database in JQuery UI tabs? What I would like is to have a tab interface and on each tab is a list of the records from a different domain. For instance, Tab1 displays the record list from Domain1, Tab2 displays the record list from Domain2, etc.
I have the JQuery UI tab interface set up and working and am currently using createLink to call the method from the controller to return the model of the appropriate domain. The tabs look like this:
<div id="tabs">
<ul>
<li>Hardware records</li>
<li>Model records</li>
<li>Building records</li>
</ul>
</div>
The method from the controller looks like this:
def listHardware() {
[hardwareList:Hardware.list(), hardwareInstanceTotal:Hardware.count()]
}
I've also played around with rendering a whole GSP within the tab by using "render(view:'HardwareList', model:[hardwareList:Hardware.list(), hardwareInstanceTotal:Hardware.count()]", but that takes a VERY long time (at least 5 seconds) to load each time the tab is selected and is not at all ideal, especially if it were to take that long for each tab.
UPDATE
As noted in one of my answers to Rimero's answer below, I was able to use templates to display tables of my domains' data. I'm also trying to implement pagination on each tab using the tag, but each time I click on one of the pages to view another page, it takes me to the full template itself outside of the tab interface. Any thoughts on how to format the tag so that everything stays within the tab??
Here's my suggestion:
You can fetch everything at once in your controller in your index method for example.
You can implement your tab contents as templates
(g render template). Each tab == 1 template.
You can fetch your domain objects buildingList,
etc. from the index method of your controller.
The g:render template code for each tab may only need to be passed a map or a collection for rendering.
In this case you don't need hyperlinks to controllers endpoints. You just keep anchors to the tab(div id) as in the default example here -> http://jqueryui.com/tabs/.
UPDATED ANSWER
As you said that sending all the data at once takes a long time, you could fetch it asynchronously. If possible populate the data only for the first tab directly.
Create a business method for each tab, that will return the model as JSON, data is only fetched if not already retrieved from the server (Need to keep state or see for example if the tab id has some DOM nodes.
Using JQuery, when the DOM is ready, get the current tab and if you didn't fetch the data for the first tab eagerly, fetch it at this moment with the busy image spinning.
As soon as you select a new tab, you need to check if the data was already fetched, if not, you send an ajax call and your callback function populate the data in the tab div container for example.
Hope it helps.

Grails webflow - converting action based to web flow

Our app is working using the normal actions in the controller, but there are some difficulties in going backward from one page to another. I've been tasked with converting this to use web flows instead and I'm hitting all kinds of road blocks. Suggestions and insights greatly appreciated.
The controller has actions for list, view, create, sign and print. I've done this:
def index = {
redirect (action: "someFlow")
}
def someFlow = {
init {
// some object settings
}
on("success").to("list")
list {
}
on("create").to "create"
on("view).to "view"
create {
}
on("next").to "sign"
on("cancel).to "list"
view {
}
on("edit").to "create"
on("back").to "list"
sign {
}
on("done").to "list"
on("back").to "create"
edit {
}
on("done").to "view"
}
When I trace through this with the debugger it appears to hit every state in succession without doing anything or stopping on any page. Then it goes back to the list state.
If I click the link for 'create' I get a web page telling me the "resource (/directory path/create) is not available."
But if it could find the list.gsp, why can't it find the create.gsp?
I feel like I'm groping blindly in the dark; none of the books seems to address any of this and I can't find any other resources to indicate why it behaves this way. Anyone have an idea?
Thanks.
The "on" statements need to be inside of the closures. For example, this:
list {
}
on("create").to "create"
on("view").to "view"
should be this:
list {
on("create").to "create"
on("view").to "view"
}
That should at least fix the issue with flying through the whole flow. As for the GSPs not being found, you'll need to create a folder (named "some") in the folder for your controller. Place the GSPs for each of the actions in your flow inside here.
That being said, I agree with Rob that it doesn't really seem like a good candidate for a webflow.

Asp.net MVC eCommerce app - Add To Cart implementation

Let say I am rendering list of products with Add To Cart link / button next to each.
I also have a CartController with AddToCart Action that accept a parameter of Product type.
After product is added to cart user should stay on the same page (Product list) - not to be redirected to Cart or something.
I am rendering Cart summary partial view that should update itself.
So my question is about implementation of the Add To Cart link / button.
Should I use: Html.ActionLink(...)
or Html.BeginForm() and Submit button.
Maybe there is other ways...
How do I send Product info in each case?
Thanks
I suggest using a jQuery.post() request to your CartController.AddToCart. Make AddToCart a partial view. And then show a modal popup (div on top of your page) that shows that the product was added to the cart...then do a fade out!
Keep it simple.
Now keep in mind that some of your users won't be able to support jquery/javascript. So make the initial add to cart button post to an add to cart page (not partial page..full page)...which can return them to the original page. Then spot weld your jquery function on top of the add to cart button. This way you cover both worlds nicely.
Take a look at the concept of unobtrusive javascript/jquery.
The way I do it is to have a form for each add button (with maybe the quantity also), since you want your AddToCart action only receive POST actions anyway, that way you process all the add to cart logic and then redirect to your main catalog view (or something like that :)
Again I'd take into consideration what happens if the user doesn't have javascript. It's not very likely these days, but do you want to lose a sale just because someone accidently turned off javascript?
So what I'd do is create the somewhat typical AddToCart link (<a class="add" href="/Shop/AddToCart/5">). The AddToCart controller would then do it's stuff and redirect back to the product listing page (you might have to pass a parameter to specify which page to go back to).
So that's the first step to consider -- javascript turned off. Now you can think about how to do it with javascript.
Capture the click event ( $('a.add').click(...) ) and then you can do two things. One would be to call the URL (you can get it out of the event object) and then separately update the cart. You can also add a parameter to the URL so that it displays the cart partial view, doing something like (written from memory):
$('a.add').click(function(event) { $('#cart').load(event.target.attr('href') + '&showcart=1');
James

How would you implement StackOverflow's profile page in ASP.NET MVC?

I'm guessing the StackOverflow code has something along the lines of a UsersController that defines a function like this:
public ActionResult Profile(string id, string username, string sort)
{
}
From what I can tell, there's two ways to go about implementing the Profile function. One is to use a switch statement on the sort parameter and render a different view based on what is being displayed (e.g. stats, recent, responses). These views would then render a partial user control to handle the display of the top half of the profile page (gravatar, username, last seen, etc).
The other way I could see implementing this would be to always render one view and have the logic for showing / hiding its different sections based on the sort. This would lead to a pretty monstrous view page, but it should work as well.
Are there any other ways of implementing the StackOverflow profile page that I'm missing? The reason I ask is because my current ASP.NET MVC page has a similar profile page and I want to make sure I'm not going about this the wrong way.
Personally, I would create an action and view for each tab section and use a partial view for the top part that is shared across the others. I'm just getting started with MVC though, so I don't have a lot of experience to back up that suggestion.
The URL route scheme I would use is /{controller}/{id}/{section} e.g. /users/123/recent /users/123/responses, etc.
You could build the view name from the sort value
<% RenderPartial(sort + "View") %>
However, it does default back to the stats view if the parameter doesn't exist so I don't think they are doing that.
A switch on sort would probably work just fine with the default on the switch going back to the stats view.

Resources